diff --git a/build.gradle b/build.gradle index e4b88a4..64f7367 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ sourceSets { } java { - sourceCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_1_8 withJavadocJar() withSourcesJar() registerFeature('dtdparse') { @@ -51,44 +51,44 @@ dependencies { testImplementation "junit:junit:4.13.1" } -tasks.register('jvmVersionAttribute') { - description = "Set the correct 'org.gradle.jvm.version' attribute" - def jvmVersionAttribute = Attribute.of('org.gradle.jvm.version', Integer) - configurations.each { - if (it.canBeConsumed) { - def categoryAttr = it.attributes.getAttribute(Category.CATEGORY_ATTRIBUTE) - if (categoryAttr != null && categoryAttr.name == Category.LIBRARY) { - def usageAttr = it.attributes.getAttribute(Usage.USAGE_ATTRIBUTE) - if (usageAttr != null && (usageAttr.name == Usage.JAVA_API - || usageAttr.name == Usage.JAVA_RUNTIME)) { - it.attributes.attribute(jvmVersionAttribute, 8) - } - } +repositories { + maven { + url = uri('https://repo.maven.apache.org/maven2/') + } + maven { + url "https://css4j.github.io/maven/" + mavenContent { + releasesOnly() + } + content { + includeGroup 'io.sf.carte' + includeGroup 'io.sf.jclf' } } } -compileJava.dependsOn tasks.jvmVersionAttribute +tasks.compileJava { + excludes += ['module-info.java'] + modularity.inferModulePath = false +} -tasks.register('compileLegacyJava', JavaCompile) { - description = 'Compile to Java 8 bytecode, except module-info' +tasks.register('compileModuleInfo', JavaCompile) { + description = 'Compile module-info to Java 11 bytecode' dependsOn tasks.compileJava - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - source = tasks.compileJava.stableSources - classpath = tasks.compileJava.classpath - destinationDirectory = tasks.compileJava.destinationDirectory - modularity.inferModulePath = false - includes = tasks.compileJava.includes - excludes = tasks.compileJava.excludes - excludes += ['module-info.java'] + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + source = sourceSets.main.java + classpath = sourceSets.main.compileClasspath + destinationDirectory = sourceSets.main.java.destinationDirectory + modularity.inferModulePath = true + includes = ['module-info.java'] } -classes.dependsOn compileLegacyJava +classes.dependsOn compileModuleInfo // Check bytecode version, in case some other task screws it tasks.register('checkLegacyJava') { - description = 'Check Java 8 bytecode' + description = 'Check that classes are Java 8 bytecode (except module-info)' def classdir = sourceSets.main.output.classesDirs.files.stream().findAny().get() def classfiles = fileTree(classdir).matching({it.exclude('module-info.class')}).files doFirst() { @@ -108,22 +108,6 @@ tasks.register('checkLegacyJava') { classes.finalizedBy checkLegacyJava -repositories { - maven { - url = uri('https://repo.maven.apache.org/maven2/') - } - maven { - url "https://css4j.github.io/maven/" - mavenContent { - releasesOnly() - } - content { - includeGroup 'io.sf.carte' - includeGroup 'io.sf.jclf' - } - } -} - tasks.register('lineEndingConversion', CRLFConvert) { description 'Convert LICENSE.txt to Windows line endings' file "$rootDir/LICENSE.txt" @@ -149,6 +133,7 @@ tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('encoding', 'UTF-8') options.addStringOption('charset', 'UTF-8') + options.links 'https://docs.oracle.com/en/java/javase/11/docs/api/' } // Reproducible build