Skip to content

Commit 5acbda8

Browse files
authored
Avoid unnecessary Gradle task configuration (#56)
1 parent d6f0e95 commit 5acbda8

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

build.gradle

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jar {
8686
libsDirName = "jar"
8787
}
8888

89-
project.tasks.withType(JavaCompile) {
89+
project.tasks.withType(JavaCompile).configureEach {
9090
sourceCompatibility = project.ext.sourceCompatibility
9191
targetCompatibility = project.ext.targetCompatibility
9292
}
@@ -95,45 +95,46 @@ project.tasks.withType(JavaCompile) {
9595
// artifacts. Its extension is .module, which might get confused with our own .module files.
9696
// We could publish these files for everything but .module files, but for now we disable always
9797
// https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html
98-
project.tasks.withType(GenerateModuleMetadata) {
98+
project.tasks.withType(GenerateModuleMetadata).configureEach {
9999
enabled = false
100100
}
101101

102-
project.task("fatJar",
103-
description: "Generate single jar file containing the api and all its dependent classes",
104-
group: GroupNames.BUILD,
105-
type: Jar,
106-
{
107-
Jar jar ->
108-
jar.from sourceSets.main.output
109-
jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
110-
jar.from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
111-
jar.setArchiveVersion(project.version)
112-
jar.archiveClassifier.set(LabKey.FAT_JAR_CLASSIFIER)
113-
jar.dependsOn project.tasks.jar
114-
}
115-
)
102+
project.tasks.register("fatJar", Jar) {
103+
Jar jar ->
104+
jar.description = "Generate single jar file containing the api and all its dependent classes"
105+
jar.group = GroupNames.BUILD
106+
jar.from sourceSets.main.output
107+
jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
108+
jar.from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
109+
jar.setArchiveVersion(project.version)
110+
jar.archiveClassifier.set(LabKey.FAT_JAR_CLASSIFIER)
111+
jar.dependsOn project.tasks.jar
112+
}
116113

117114
if (project.hasProperty('javaClientDir'))
118115
{
119-
project.task('deployFatJar', description: "Generate java client 'all' jar file and deploy to a given directory. For example, a host app other than LabKey Server",
120-
type: Copy) {
116+
project.tasks.register('deployFatJar', Copy) {
117+
description = "Generate java client 'all' jar file and deploy to a given directory. For example, a host app other than LabKey Server"
121118
from fatJar
122119
into project.javaClientDir
123120
}
124121
}
125122

126-
project.task('javadocJar', description: "Generate jar file of javadoc files", type: Jar) {Jar jar ->
127-
jar.from project.tasks.javadoc.destinationDir
128-
jar.group GroupNames.DISTRIBUTION
129-
jar.archiveClassifier.set(LabKey.JAVADOC_CLASSIFIER)
130-
jar.dependsOn project.tasks.javadoc
131-
}
123+
project.tasks.register('javadocJar', Jar) {
124+
Jar jar ->
125+
jar.description = "Generate jar file of javadoc files"
126+
jar.from project.tasks.javadoc.destinationDir
127+
jar.group GroupNames.DISTRIBUTION
128+
jar.archiveClassifier.set(LabKey.JAVADOC_CLASSIFIER)
129+
jar.dependsOn project.tasks.javadoc
130+
}
132131

133-
project.task('sourcesJar', description: "Generate jar file of source files", type: Jar) {Jar jar ->
134-
jar.from project.sourceSets.main.allJava
135-
jar.group GroupNames.DISTRIBUTION
136-
jar.archiveClassifier.set(LabKey.SOURCES_CLASSIFIER)
132+
project.tasks.register('sourcesJar', Jar) {
133+
Jar jar ->
134+
jar.description = "Generate jar file of source files"
135+
jar.from project.sourceSets.main.allJava
136+
jar.group GroupNames.DISTRIBUTION
137+
jar.archiveClassifier.set(LabKey.SOURCES_CLASSIFIER)
137138
}
138139

139140
project.artifacts {

0 commit comments

Comments
 (0)