Flywheel/buildSrc/simple-java.gradle

59 lines
1.7 KiB
Groovy
Raw Normal View History

boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equalsIgnoreCase('false')
String buildNumber = System.getenv('BUILD_NUMBER')
group = 'com.jozufozu.flywheel'
version = mod_version + (dev && buildNumber != null ? "-${buildNumber}" : '')
base {
archivesName = "flywheel-${name}-${artifact_minecraft_version}"
}
java {
JavaVersion javaVersion = JavaVersion.toVersion(java_version)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
withSourcesJar()
withJavadocJar()
}
// make builds reproducible
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
// module metadata is often broken on multi-platform projects
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
tasks.withType(JavaCompile).configureEach { JavaCompile javaCompile ->
javaCompile.options.encoding = 'UTF-8'
javaCompile.options.release = Integer.parseInt(java_version)
javaCompile.options.compilerArgs = ['-Xdiags:verbose']
}
tasks.named('jar', Jar).configure { Jar jar ->
archiveClassifier = ''
addLicense(jar)
}
tasks.named('sourcesJar', Jar).configure { Jar jar ->
addLicense(jar)
}
tasks.named('javadoc', Javadoc).configure { Javadoc javadoc ->
javadoc.source sourceSets.main.allJava
// prevent java 8's strict doclint for javadocs from failing builds
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
}
static void addLicense(Jar jarTask) {
jarTask.from('LICENSE.md') {
rename '(.*)\\.(.*)', '$1_' + jarTask.archiveBaseName + '.$2'
}
}