Adding module version detection.

This commit is contained in:
a2geek committed 2026-10-10 15:28:55 -05:00
1 parent 4eca8b01d2
commit e3dc65c62a
2 files changed
+19 -1

No files matched your search

+5
View File
@@ -25,6 +25,11 @@ jar {
}
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['--module-path', classpath.asPath]
options.javaModuleVersion = project.version.toString()
}
test {
useJUnitPlatform()
}
@@ -47,7 +47,20 @@ public class AppleSingle {
public static final String VERSION;
static {
VERSION = AppleSingle.class.getPackage().getImplementationVersion();
String version = AppleSingle.class.getPackage().getImplementationVersion();
if (version == null && AppleSingle.class.getModule().getDescriptor() != null) {
// When run under the Java Module system (JPMS) we need to get it a different way.
version = AppleSingle.class.getModule()
.getDescriptor()
.version()
.map(Object::toString)
.orElse("Development Build");
}
// For unit tests, the descriptor (apparently) doesn't exist, so we skip it.
if (version == null) {
version = "Unit Testing";
}
VERSION = version;
}
private Map<Integer,Consumer<Entry>> entryConsumers = new HashMap<>();