LoginSignup
4
3

More than 5 years have passed since last update.

gitignore.ioのAPIを使って、Gradleのタスクからgitignoreファイルを作成する

Posted at

http://gitignore.io/cli を参考にやってみました。

作成方法

以下のタスクを build.gradle に追加します。

build.gradle
task createGitIgnore << {
    def target = ['java', 'gradle', 'eclipse', 'intellij'].join(',')
    file('.gitignore').text = new URL("http://gitignore.io/api/$target").text
}

次に、以下のコマンドを実行します。

$ gradle createGitIgnore

プロジェクト配下に .gitignore が出来ていることを確認して下さい。

一覧

一覧を出力する場合、以下のタスクを追加します。

build.gradle
task showGitIgnoreList << {
    new URL("http://gitignore.io/api/list").text.split(',').each { println it }
}

次に、以下のコマンドを実行します。

$ gradle showGitIgnoreList

ズラッと指定できる項目一覧が表示されます。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3