Updating to set VERSION and TITLE for Java module system.

This commit is contained in:
a2geek committed 2026-10-10 18:19:11 -05:00
1 parent 0303d2f2d5
commit c65b85bd51
2 files changed
+25 -2

No files matched your search

+5
View File
@@ -26,6 +26,11 @@ jar {
}
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['--module-path', classpath.asPath]
options.javaModuleVersion = project.version.toString()
}
javadoc {
title = "bastools ${version}"
source = sourceSets.main.allJava
@@ -25,8 +25,26 @@ public class BasTools {
public static final String VERSION;
public static final String TITLE;
static {
TITLE = BasTools.class.getPackage().getImplementationTitle();
VERSION = BasTools.class.getPackage().getImplementationVersion();
String title = BasTools.class.getPackage().getImplementationTitle();
if (title == null) {
title = "B/BAS Tools API";
}
TITLE = title;
String version = BasTools.class.getPackage().getImplementationVersion();
if (version == null && BasTools.class.getModule().getDescriptor() != null) {
// When run under the Java Module system (JPMS) we need to get it a different way.
version = BasTools.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 BasTools() {}