Skip to content

Commit 24aff1b

Browse files
authoredAug 27, 2021
Add module descriptor inside multi-release jar (Fixes #21) (#23)
1 parent 41cae2a commit 24aff1b

File tree

5 files changed

+130
-3
lines changed

5 files changed

+130
-3
lines changed
 

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dist: bionic
22

33
language: java
4-
jdk: openjdk8
4+
jdk: openjdk11
55

66
install: true
77
script: ./gradlew build

‎build.gradle.kts

+33-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ plugins {
88

99
base.archivesName(project.name.toLowerCase())
1010

11+
sourceSets.create("java11") {
12+
java.srcDir("src/main/java11")
13+
java.srcDir("src/main/java")
14+
}
15+
16+
sourceSets.create("intTest")
17+
18+
configurations["java11CompileClasspath"].extendsFrom(configurations.compileClasspath.get())
19+
configurations["intTestImplementation"].extendsFrom(configurations.api.get())
20+
1121
java {
1222
sourceCompatibility = JavaVersion.VERSION_1_8
1323
}
@@ -17,15 +27,16 @@ repositories {
1727
}
1828

1929
dependencies {
20-
api("org.apache.logging.log4j:log4j-core:2.8.1")
21-
annotationProcessor("org.apache.logging.log4j:log4j-core:2.8.1")
30+
api("org.apache.logging.log4j:log4j-core:2.14.1")
31+
annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1")
2232

2333
api("org.jline:jline-reader:3.20.0")
2434

2535
compileOnly("org.checkerframework:checker-qual:3.17.0")
2636

2737
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.2")
2838
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.2")
39+
"intTestImplementation"(files(tasks.named("jar")))
2940
}
3041

3142
java {
@@ -36,13 +47,33 @@ java {
3647
tasks.jar {
3748
manifest {
3849
attributes("Automatic-Module-Name" to "net.minecrell.terminalconsole")
50+
attributes("Multi-Release" to "true")
51+
}
52+
into("META-INF/versions/11") {
53+
from(sourceSets["java11"].output)
54+
include("module-info.class")
3955
}
4056
}
4157

58+
tasks.named<JavaCompile>("compileJava") {
59+
options.release.set(8)
60+
}
61+
62+
tasks.named<JavaCompile>("compileJava11Java") {
63+
options.release.set(11)
64+
options.javaModuleVersion.set(project.version as String)
65+
}
66+
67+
tasks.named<JavaCompile>("compileIntTestJava") {
68+
options.release.set(11)
69+
}
70+
4271
tasks.withType<Test> {
4372
useJUnitPlatform()
4473
}
4574

75+
tasks.check { dependsOn(tasks.named("compileIntTestJava")) }
76+
4677
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
4778

4879
publishing {

‎src/intTest/java/module-info.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 Minecrell <https://github.com/Minecrell>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
module net.minecrell.terminalconsole.it {
26+
requires net.minecrell.terminalconsole;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 Minecrell <https://github.com/Minecrell>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package net.minecrell.terminalconsole.it.jpms;
26+
27+
import org.apache.logging.log4j.core.LogEvent;
28+
import net.minecrell.terminalconsole.TerminalConsoleAppender;
29+
30+
public class Compilation {
31+
32+
public void useTCA(TerminalConsoleAppender tca) {
33+
tca.append((LogEvent) null);
34+
}
35+
}

‎src/main/java11/module-info.java

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 Minecrell <https://github.com/Minecrell>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
module net.minecrell.terminalconsole {
26+
requires org.apache.logging.log4j;
27+
requires transitive org.apache.logging.log4j.core;
28+
requires static org.checkerframework.checker.qual;
29+
requires transitive org.jline.terminal;
30+
requires transitive org.jline.reader;
31+
32+
exports net.minecrell.terminalconsole;
33+
exports net.minecrell.terminalconsole.util;
34+
}

0 commit comments

Comments
 (0)
Please sign in to comment.