You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/11/30 21:03:39 UTC

[lucene] branch main updated: LUCENE-10234: Change module prefix to org.apache.* (#487)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 20cb681  LUCENE-10234: Change module prefix to org.apache.* (#487)
20cb681 is described below

commit 20cb6817db45d261bf336102f5842674f377d823
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Tue Nov 30 22:03:33 2021 +0100

    LUCENE-10234: Change module prefix to org.apache.* (#487)
---
 gradle/java/jar-manifest.gradle                    | 47 +++++++++++++++++++---
 lucene/CHANGES.txt                                 |  4 +-
 .../distribution/src/binary-release/bin/luke.cmd   |  2 +-
 lucene/distribution/src/binary-release/bin/luke.sh |  2 +-
 lucene/luke/src/distribution/README.md             |  2 +-
 5 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/gradle/java/jar-manifest.gradle b/gradle/java/jar-manifest.gradle
index 2840b8b..d4ab812 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 f1c3d6d..7080a28 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 cb8b1e3..ff9b46b 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 1593ac6..0cc7bd7 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 c23dba0..40e55b3 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!