Hello Gradle
Gradle日本語ドキュメントを見て手を動かす。
$ git clone https://github.com/ikhr/gradlestudy Cloning into 'gradlestudy'... warning: You appear to have cloned an empty repository. $ cd gradlestudy/ $ cat build.gradle task hello { doLast { println 'Hello world!' } } $ gradle -q hello Hello world!
せっかくなのでGitHubで管理しておきたい。
$ git add . $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: .gradle/4.3.1/fileChanges/last-build.bin new file: .gradle/4.3.1/fileHashes/fileHashes.bin new file: .gradle/4.3.1/fileHashes/fileHashes.lock new file: .gradle/4.3.1/taskHistory/taskHistory.lock new file: .gradle/buildOutputCleanup/buildOutputCleanup.lock new file: .gradle/buildOutputCleanup/cache.properties new file: build.gradle
邪魔そうなのがaddされてしまったので、addを取り消す。
$ git reset HEAD . fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
怒られてオプションを減らす。
$ git reset $ cat .gitignore # Gradle .gradle !gradle-wrapper.jar $ git add . $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: .gitignore new file: build.gradle $ git commit -m "first commit" [master (root-commit) 9fc8c18] first commit 2 files changed, 8 insertions(+) create mode 100644 .gitignore create mode 100644 build.gradle $ git push -u origin master Username for 'https://github.com': ikhr Password for 'https://ikhr@github.com': Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 331 bytes | 0 bytes/s, done. Total 4 (delta 0), reused 0 (delta 0) To https://github.com/ikhr/gradlestudy * [new branch] master -> master Branch master set up to track remote branch master from origin.
微妙に修正してcommitしてみる。
$ gradle -q hell Hello world!! $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: build.gradle no changes added to commit (use "git add" and/or "git commit -a") $ git add build.gradle $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: build.gradle $ git diff
add後のdiffは--cached
が必要。
$ git diff --cached diff --git a/build.gradle b/build.gradle index 153d849..3481f2b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ task hello { doLast { - println 'Hello world!' + println 'Hello world!!' } }
GitHubへpushするのも四苦八苦
$ git push -u origin master Branch master set up to track remote branch master from origin. Everything up-to-date $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: build.gradle $ git commit -m "commit" [master 71ff171] commit 1 file changed, 1 insertion(+), 1 deletion(-) $ git push origin master Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 319 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/ikhr/gradlestudy 9fc8c18..71ff171 master -> master