LoginSignup
0
1

More than 5 years have passed since last update.

Gradle

Last updated at Posted at 2018-07-16

インストール

Windows10環境にインストールする。

ダウンロード

以下の公式サイトからダウンロードする
https://gradle.org/releases/
2018/7/16時点の最新版の4.8.1をダウンロードする。

ファイルの展開と環境変数の設定

「D:\gradle-4.8.1」に展開する。
環境変数「GRADLE_HOME」を作成。
PATHに「%GRADLE_HOME%\bin」を追加する。
コマンドプロンプトで「gradle -version」を実行できたら終了。

使い方

参考サイト:https://qiita.com/vvakame/items/83366fbfa47562fafbf4

エラー対応

エラー: この文字は、エンコーディングMS932にマップできません

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

JUnit5用

bild.gradle
plugins {
  id 'java'
}

repositories {
    mavenCentral()
}

test {
    useJUnitPlatform {
        includeEngines 'junit-jupiter'
    }
}

dependencies {
    testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
    testCompile "commons-io:commons-io:2.6"
    testCompile "org.junit.jupiter:junit-jupiter-migrationsupport:5.2.0" 
    testRuntime group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.2.0'
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

JUnit5

以下を参考にする。

https://junit.org/junit5/docs/current/user-guide/
gradle -q test -PincTags=ABC

build.gradle
apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    testCompile('org.junit.jupiter:junit-jupiter-api:5.2.0')
    testRuntime('org.junit.jupiter:junit-jupiter-engine:5.2.0')
    testCompile "commons-io:commons-io:2.6"
}

test {
    useJUnitPlatform{
        if (project.hasProperty('incTags')) {
        includeTags incTags
        }
        if (project.hasProperty('excTags')) {
            excludeTags excTags
        }
    }

    testLogging {
        events "passed", "skipped", "failed"
    }

    reports {
        html.enabled = true
    }
}

task wrapper(type: Wrapper) {
    description = 'Generates gradlew[.bat] scripts'
    gradleVersion = '4.6'
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

Jenkins

テストが実行されない

gradleのTaskに「clean test」と最初にcleanを追加する。

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