LoginSignup
1
1

More than 5 years have passed since last update.

今さらまとめるGradle(編集中)

Last updated at Posted at 2016-08-01

Gradleって何?

  • Java界隈でよく使われるビルドツール
    • Ant -> Maven -> Gradle (諸行無常)
  • 設定ファイルをGroovyで記述する

概念&用語

タスク

gradle tasks # で確認可能

プロパティ

gradle properties # で確認可能

Gradle Wrapper

  • gradleのコマンドをgradleをインストールしていない人でも実行できるようにするツール

TODO もっと書く

プラグイン
タスク

インストール

  • brewで入れたらええねん
    • gvmだかsdkmanだかしらんけどややこしくなるだけやねん
  • windowsは知らない。ごめん

コマンド

# 現在のプロジェクトで実行可能なタスクの一覧を表示。
# わけわからなくなったら、とりあえずこれ叩こう
gradle tasks

build.gradle説明

# プラグインの追加
# プラグインいろいろ -> https://docs.gradle.org/current/userguide/pt05.html

# Javaプラグイン コンパイルやjarの作成などのタスクを使えるようになる
# http://gradle.monochromeroad.com/docs/userguide/java_plugin.html
apply plugin: 'java'

apply plugin: 'eclipse'



sourceCompatibility = 1.5
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

test {
    systemProperties 'property': 'value'
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

# task
# > gradle -q hello
# hello from GreetingTask
# 詳細 -> https://docs.gradle.org/current/userguide/custom_tasks.html
task hello(type: GreetingTask)
class GreetingTask extends DefaultTask {
    @TaskAction
    def greet() {
        println 'hello from GreetingTask'
    }
}

サンプル

  • Javaプロジェクト

- Androidプロジェクト

1
1
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
1
1