④build.gradle
plugins {
id 'application'
}
repositories{
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
//This dependency is used by the application.
implementation 'com.google.guava:guava:30.1.1-jre'
}
application {
// Define the main class for the application.
mainClass = 'demo.App'
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
build.gradle は、project毎に必要
④build.gradle
plugins {
id 'application’
id‘java’ <- 通常はこれ
id ‘org.gradle.java’ <- org.gradle はCore Gradle plugin namespace
}
https://docs.gradle.org/current/userguide/plugins.html
https://docs.gradle.org/current/javadoc/org/gradle/plugin/use/PluginDependenciesSp
ec.html
https://docs.gradle.org/current/dsl/org.gradle.api.invocation.Gradle.html
https://docs.gradle.org/current/dsl/org.gradle.plugin.use.PluginDependenciesSpec.ht
ml
Plugins script block
必ず先頭に記述
Buildに必要な処理を追加
plugins DSLが解決
10.
④build.gradle
repositories {
// UseMaven Central for resolving dependencies.
mavenCentral()
}
https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.htm
l
RepositoryHandlerが、
「https://repo.maven.apache
.org/maven2/」URLへアク
セスしている
11.
④build.gradle
dependencies {
// UseJUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
//This dependency is used by the application.
implementation 'com.google.guava:guava:30.1.1-jre'
}
https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.ht
ml
DependencyHandler
12.
④build.gradle
version = ‘1.0.0’<- versioを追加すると「app-1.0.0.jar」が作成される
https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html
VersionはProject Interfaceで
定義されている