Build.gradle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 6: | Line 6: | ||
=Overview= | =Overview= | ||
build.gradle is the script interface to a [[Gradle_Project#Project_API_and_build.gradle_DSL|Project instance]]. | |||
=Example= | |||
<syntaxhighlight lang='groovy'> | |||
apply plugin: 'java' | |||
// name comes from the directory name or it can be changed in settings.gradle | |||
group = "playground.example" | |||
version = "0.1.0" | |||
description = "A Gradle example project" | |||
repositories { | |||
mavenLocal() | |||
mavenCentral() | |||
} | |||
dependencies { | |||
implementation 'org.slf4j:slf4j-api:1.7.12' | |||
testImplementation 'junit:junit:4.+' | |||
} | |||
configurations { | |||
testImplementation.exclude group: 'com.example' | |||
} | |||
configurations.all { | |||
resolutionStrategy.cacheChangingModulesFor 3600, 'seconds' | |||
} | |||
compileJava { | |||
options.compilerArgs += ['-Xlint'] | |||
} | |||
javadoc { | |||
options.charSet = 'UTF-8' | |||
} | |||
task runMain(type: JavaExec) { | |||
classpath = sourceSets.main.runtimeClasspath | |||
main = "io.novaordis.playground.gradle.java.Main" | |||
} | |||
</syntaxhighlight> | |||
=Comments= | =Comments= |
Revision as of 07:10, 5 October 2020
External
Internal
Overview
build.gradle is the script interface to a Project instance.
Example
apply plugin: 'java'
// name comes from the directory name or it can be changed in settings.gradle
group = "playground.example"
version = "0.1.0"
description = "A Gradle example project"
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation 'org.slf4j:slf4j-api:1.7.12'
testImplementation 'junit:junit:4.+'
}
configurations {
testImplementation.exclude group: 'com.example'
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 3600, 'seconds'
}
compileJava {
options.compilerArgs += ['-Xlint']
}
javadoc {
options.charSet = 'UTF-8'
}
task runMain(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = "io.novaordis.playground.gradle.java.Main"
}
Comments
// This is a comment