prometheus / client_java

Prometheus instrumentation library for JVM applications

Home Page:http://prometheus.github.io/client_java/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JPMS support

solomax opened this issue · comments

Hello,

Would it be possible to release version with Automati-Module-Name?

to avoid warnings like:

[WARNING] *********************************************************************************************************************************************************************************************
[WARNING] * Required filename-based automodules detected: [prometheus-metrics-core-1.0.0.jar, prometheus-metrics-model-1.0.0.jar]. Please don't publish this project to a public artifact repository! *
[WARNING] *********************************************************************************************************************************************************************************************

Sure, thanks for bringing this up. Can you let me know how to do this? We already got this in our pom.xml:

<packaging>bundle</packaging>

What else do I need?

Hello @fstab,

As far as I understand this can be implemented 2 ways:

First Option: special entry in MANIFEST of every module

here is an idea:

diff --git a/pom.xml b/pom.xml
index 2845c00d..2f468daa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,7 @@
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <automatic-module-name>--module-name-need-to-be-overriden--</automatic-module-name>
     </properties>
 
     <distributionManagement>
@@ -192,6 +193,11 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <version>2.4.0</version>
                 <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Automatic-Module-Name>${automatic-module-name}</Automatic-Module-Name>
+                    </instructions>
+                </configuration>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
diff --git a/prometheus-metrics-core/pom.xml b/prometheus-metrics-core/pom.xml
index 25007d1e..a31705c2 100644
--- a/prometheus-metrics-core/pom.xml
+++ b/prometheus-metrics-core/pom.xml
@@ -32,6 +32,9 @@
         </developer>
     </developers>
 
+    <properties>
+        <automatic-module-name>io.prometheus.metrics.core</automatic-module-name>
+    </properties>
     <dependencies>
         <dependency>
             <groupId>io.prometheus</groupId>

as you can see:

  1. special property is defined in parent pom
  2. later on it is set the valid name for this particular module (done for single module to illustrate the idea)

Another Option: module-info.java need to be added to every module

IMO first option is faster and lightweight, with second one you will create real modules :)

Thanks a lot @solomax ,I like option 1. What do people usually choose as a module name? Each module has a unique Java package, so we could use the package name. Or is it more common to use the name of the Maven module?

If you like to create a PR for this please go ahead.

#872

not sure what is DCO :(

@fstab You should use the package name. Maven module names are usually not valid because they have -.

While you are at since I was looking at the manifest you should not have your name in the jar manifest and the bnd timestamp should probably be removed as well.

See this: https://maven.apache.org/guides/mini/guide-reproducible-builds.html

and this:

https://reproducible-builds.org/docs/jvm/

and this:

https://github.com/jvm-repo-rebuild/reproducible-central#readme

Given how important prometheus is it should be on that list.