Skip to content

Apache Lucene open-source search software

LUCENE-10234: Change module prefix to org.apache.* (#487)

Dawid Weiss20cb6817db45
diff --git a/gradle/java/jar-manifest.gradle b/gradle/java/jar-manifest.gradle
index 2840b8b7424..d4ab812cf45 100644
--- a/gradle/java/jar-manifest.gradle
+++ b/gradle/java/jar-manifest.gradle
@@ -1,3 +1,6 @@
+import java.util.jar.JarFile
+import java.util.regex.Matcher
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -47,8 +50,7 @@ subprojects {
}
}
- manifest {
- attributes([
+ def manifestAttrs = [
"Extension-Name" : implementationTitle,
"Implementation-Vendor" : "The Apache Software Foundation",
@@ -64,10 +66,17 @@ subprojects {
"X-Compile-Target-JDK" : "${-> project.targetCompatibility}",
"X-Build-JDK" : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
- "X-Build-OS" : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
+ "X-Build-OS" : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
+ ]
+
+ // Only apply automatic module name to jar task.
+ if (task.name in ["jar"]) {
+ manifestAttrs["Automatic-Module-Name"] =
+ "${-> project.path.replaceFirst(/^:lucene/, Matcher.quoteReplacement(project.group)).replace(':', '.').replace('-', '_')}"
+ }
- "Automatic-Module-Name" : "${-> project.path.replaceFirst(":", "").replace(':', '.').replace("-", "_")}"
- ])
+ manifest {
+ attributes(manifestAttrs)
}
// Copy legalese into META-INF.
@@ -78,4 +87,30 @@ subprojects {
})
}
}
-}
\ No newline at end of file
+}
+
+configure(rootProject) {
+ tasks.register("showModuleNames", { showModuleTask ->
+ def allJarTasks = []
+
+ rootProject.subprojects.each { subproject ->
+ subproject.tasks.matching { it.name == 'jar' }.all {
+ allJarTasks.add it
+ }
+ }
+
+ dependsOn allJarTasks
+
+ doFirst {
+ allJarTasks.each { jarTask ->
+ File jarFile = jarTask.outputs.files.singleFile
+ try (def jar = new JarFile(jarFile)) {
+ logger.lifecycle(String.format(Locale.ROOT,
+ "%-50s -> %s",
+ jarFile.name,
+ jar.manifest.mainAttributes.getValue("Automatic-Module-Name")))
+ }
+ }
+ }
+ })
+}
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index f1c3d6d4524..7080a282141 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -254,7 +254,9 @@ API Changes
Improvements
---------------------
-* LUCENE-10234: Added Automatic-Module-Name to all JARs. (Dawid Weiss)
+* LUCENE-10234: Added Automatic-Module-Name to all JARs. This is the first step to enable full Java
+ module system (JMS) support in later Lucene versions. At the moment, the automatic names should
+ not be considered stable. (Dawid Weiss, Uwe Schindler)
* LUCENE-10182: TestRamUsageEstimator used RamUsageTester.sizeOf throughout, making some of the
tests trivial. Now, it compares results from RamUsageEstimator with those from RamUsageTester.
diff --git a/lucene/distribution/src/binary-release/bin/luke.cmd b/lucene/distribution/src/binary-release/bin/luke.cmd
index cb8b1e3ece3..ff9b46b04a4 100644
--- a/lucene/distribution/src/binary-release/bin/luke.cmd
+++ b/lucene/distribution/src/binary-release/bin/luke.cmd
@@ -17,5 +17,5 @@
SETLOCAL
SET MODULES=%~dp0..
-start javaw --module-path "%MODULES%\modules;%MODULES%\modules-thirdparty" --add-modules org.apache.logging.log4j --module lucene.luke
+start javaw --module-path "%MODULES%\modules;%MODULES%\modules-thirdparty" --add-modules org.apache.logging.log4j --module org.apache.lucene.luke
ENDLOCAL
diff --git a/lucene/distribution/src/binary-release/bin/luke.sh b/lucene/distribution/src/binary-release/bin/luke.sh
index 1593ac6d804..0cc7bd76e38 100644
--- a/lucene/distribution/src/binary-release/bin/luke.sh
+++ b/lucene/distribution/src/binary-release/bin/luke.sh
@@ -17,4 +17,4 @@
MODULES=`dirname "$0"`/..
MODULES=`cd "$MODULES" && pwd`
-java --module-path "$MODULES/modules:$MODULES/modules-thirdparty" --add-modules org.apache.logging.log4j --module lucene.luke
+java --module-path "$MODULES/modules:$MODULES/modules-thirdparty" --add-modules org.apache.logging.log4j --module org.apache.lucene.luke
diff --git a/lucene/luke/src/distribution/README.md b/lucene/luke/src/distribution/README.md
index c23dba02875..40e55b3a416 100644
--- a/lucene/luke/src/distribution/README.md
+++ b/lucene/luke/src/distribution/README.md
@@ -27,7 +27,7 @@ java -jar ${luke.cmd}
or, using Java modules:
```
-java --module-path . --add-modules org.apache.logging.log4j --module lucene.luke
+java --module-path . --add-modules org.apache.logging.log4j --module org.apache.lucene.luke
```
Happy index hacking!