Skip to content

Commit e293823

Browse files
committed
Gradle: slighltly simpler build.
1 parent 7d6443f commit e293823

File tree

1 file changed

+29
-44
lines changed

1 file changed

+29
-44
lines changed

build.gradle

+29-44
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ sourceSets {
3333
}
3434

3535
java {
36-
sourceCompatibility = JavaVersion.VERSION_11
36+
sourceCompatibility = JavaVersion.VERSION_1_8
3737
withJavadocJar()
3838
withSourcesJar()
3939
registerFeature('dtdparse') {
@@ -51,44 +51,44 @@ dependencies {
5151
testImplementation "junit:junit:4.13.1"
5252
}
5353

54-
tasks.register('jvmVersionAttribute') {
55-
description = "Set the correct 'org.gradle.jvm.version' attribute"
56-
def jvmVersionAttribute = Attribute.of('org.gradle.jvm.version', Integer)
57-
configurations.each {
58-
if (it.canBeConsumed) {
59-
def categoryAttr = it.attributes.getAttribute(Category.CATEGORY_ATTRIBUTE)
60-
if (categoryAttr != null && categoryAttr.name == Category.LIBRARY) {
61-
def usageAttr = it.attributes.getAttribute(Usage.USAGE_ATTRIBUTE)
62-
if (usageAttr != null && (usageAttr.name == Usage.JAVA_API
63-
|| usageAttr.name == Usage.JAVA_RUNTIME)) {
64-
it.attributes.attribute(jvmVersionAttribute, 8)
65-
}
66-
}
54+
repositories {
55+
maven {
56+
url = uri('https://repo.maven.apache.org/maven2/')
57+
}
58+
maven {
59+
url "https://css4j.github.io/maven/"
60+
mavenContent {
61+
releasesOnly()
62+
}
63+
content {
64+
includeGroup 'io.sf.carte'
65+
includeGroup 'io.sf.jclf'
6766
}
6867
}
6968
}
7069

71-
compileJava.dependsOn tasks.jvmVersionAttribute
70+
tasks.compileJava {
71+
excludes += ['module-info.java']
72+
modularity.inferModulePath = false
73+
}
7274

73-
tasks.register('compileLegacyJava', JavaCompile) {
74-
description = 'Compile to Java 8 bytecode, except module-info'
75+
tasks.register('compileModuleInfo', JavaCompile) {
76+
description = 'Compile module-info to Java 11 bytecode'
7577
dependsOn tasks.compileJava
76-
sourceCompatibility = JavaVersion.VERSION_1_8
77-
targetCompatibility = JavaVersion.VERSION_1_8
78-
source = tasks.compileJava.stableSources
79-
classpath = tasks.compileJava.classpath
80-
destinationDirectory = tasks.compileJava.destinationDirectory
81-
modularity.inferModulePath = false
82-
includes = tasks.compileJava.includes
83-
excludes = tasks.compileJava.excludes
84-
excludes += ['module-info.java']
78+
sourceCompatibility = JavaVersion.VERSION_11
79+
targetCompatibility = JavaVersion.VERSION_11
80+
source = sourceSets.main.java
81+
classpath = sourceSets.main.compileClasspath
82+
destinationDirectory = sourceSets.main.java.destinationDirectory
83+
modularity.inferModulePath = true
84+
includes = ['module-info.java']
8585
}
8686

87-
classes.dependsOn compileLegacyJava
87+
classes.dependsOn compileModuleInfo
8888

8989
// Check bytecode version, in case some other task screws it
9090
tasks.register('checkLegacyJava') {
91-
description = 'Check Java 8 bytecode'
91+
description = 'Check that classes are Java 8 bytecode (except module-info)'
9292
def classdir = sourceSets.main.output.classesDirs.files.stream().findAny().get()
9393
def classfiles = fileTree(classdir).matching({it.exclude('module-info.class')}).files
9494
doFirst() {
@@ -108,22 +108,6 @@ tasks.register('checkLegacyJava') {
108108

109109
classes.finalizedBy checkLegacyJava
110110

111-
repositories {
112-
maven {
113-
url = uri('https://repo.maven.apache.org/maven2/')
114-
}
115-
maven {
116-
url "https://css4j.github.io/maven/"
117-
mavenContent {
118-
releasesOnly()
119-
}
120-
content {
121-
includeGroup 'io.sf.carte'
122-
includeGroup 'io.sf.jclf'
123-
}
124-
}
125-
}
126-
127111
tasks.register('lineEndingConversion', CRLFConvert) {
128112
description 'Convert LICENSE.txt to Windows line endings'
129113
file "$rootDir/LICENSE.txt"
@@ -149,6 +133,7 @@ tasks.withType(Javadoc) {
149133
options.addStringOption('Xdoclint:none', '-quiet')
150134
options.addStringOption('encoding', 'UTF-8')
151135
options.addStringOption('charset', 'UTF-8')
136+
options.links 'https://docs.oracle.com/en/java/javase/11/docs/api/'
152137
}
153138

154139
// Reproducible build

0 commit comments

Comments
 (0)