[Git][java-team/maven-repo-helper][master] 4 commits: Set the language level to Java 8

Emmanuel Bourg (@ebourg) gitlab at salsa.debian.org
Tue Oct 27 17:35:20 GMT 2026



Emmanuel Bourg pushed to branch master at Debian Java Maintainers / maven-repo-helper


Commits:
5c2d3660 by Emmanuel Bourg at 2026-10-27T15:07:00+01:00
Set the language level to Java 8

- - - - -
53f22bfb by Emmanuel Bourg at 2026-10-27T18:26:43+01:00
Resolve the ${revision}, ${sha1} and ${changelist} properties used in the versions (Closes: #1035884)

- - - - -
8188e644 by Emmanuel Bourg at 2026-10-27T18:30:45+01:00
Move to version 1.13

- - - - -
591191d3 by Emmanuel Bourg at 2026-10-27T18:32:34+01:00
Upload to unstable

- - - - -


11 changed files:

- debian/changelog
- pom.xml
- src/main/java/org/debian/maven/repo/POMReader.java
- src/test/java/org/debian/maven/repo/POMReaderTest.java
- + src/test/resources/versions-with-properties/app/pom.xml
- + src/test/resources/versions-with-properties/bom/pom.xml
- + src/test/resources/versions-with-properties/legacy/pom.xml
- + src/test/resources/versions-with-properties/libs/core/pom.xml
- + src/test/resources/versions-with-properties/libs/pom.xml
- + src/test/resources/versions-with-properties/pom.xml
- + src/test/resources/versions-with-properties/tools/pom.xml


Changes:

=====================================
debian/changelog
=====================================
@@ -1,10 +1,12 @@
-maven-repo-helper (1.13) UNRELEASED; urgency=medium
+maven-repo-helper (1.13) unstable; urgency=medium
 
+  * Resolve the ${revision}, ${sha1} and ${changelist} properties used in the
+    versions (Closes: #1035884)
   * Sort the variables written in the substvars files
   * Standards-Version updated to 4.7.4
   * Removed the Priority field
 
- -- Emmanuel Bourg <ebourg at apache.org>  Tue, 27 Oct 2026 13:23:35 +0100
+ -- Emmanuel Bourg <ebourg at apache.org>  Tue, 27 Oct 2026 18:32:06 +0100
 
 maven-repo-helper (1.12) unstable; urgency=medium
 


=====================================
pom.xml
=====================================
@@ -5,7 +5,7 @@
     <artifactId>maven-repo-helper</artifactId>
     <name>Maven Repo helper</name>
     <packaging>jar</packaging>
-    <version>1.10</version>
+    <version>1.13</version>
     <description>Provides support for managing the Maven repository in a Debian distribution.</description>
 
     <inceptionYear>2009</inceptionYear>
@@ -53,8 +53,8 @@
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>2.3.2</version>
                 <configuration>
-                    <source>7</source>
-                    <target>7</target>
+                    <source>8</source>
+                    <target>8</target>
                 </configuration>
             </plugin>
             <plugin>


=====================================
src/main/java/org/debian/maven/repo/POMReader.java
=====================================
@@ -22,9 +22,12 @@ import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamConstants;
@@ -54,10 +57,89 @@ public class POMReader {
         if (!originalPom.exists()) {
             System.err.println("Cannot find pom file " + originalPom.getAbsolutePath());
         }
-        return readPom(Readers.read(originalPom));
+        POMInfo info = readPom(Readers.read(originalPom));
+
+        // The ${revision}, ${sha1} and ${changelist} properties allowed in the versions since
+        // Maven 3.5 may be defined in the parent POM, so the POM is read again with its properties
+        if (hasUnresolvedVersion(info)) {
+            Map<String, String> inheritedProperties = readInheritedProperties(originalPom, info.getParent(), new HashSet<File>());
+            if (!inheritedProperties.isEmpty()) {
+                info = readPom(Readers.read(originalPom), inheritedProperties);
+            }
+        }
+
+        return info;
+    }
+
+    private boolean hasUnresolvedVersion(POMInfo info) {
+        return info.getParent() != null
+                && (isUnresolved(info.getThisPom().getVersion()) || isUnresolved(info.getParent().getVersion()));
+    }
+
+    private boolean isUnresolved(String value) {
+        return value != null && value.contains("${");
+    }
+
+    /**
+     * Collects the properties defined by the parent POMs found in the project tree.
+     *
+     * @param pomFile the POM inheriting the properties
+     * @param parent  the parent declared by the POM
+     * @param visited the parent POMs already read, to stop on a cycle of relative paths
+     */
+    private Map<String, String> readInheritedProperties(File pomFile, Dependency parent, Set<File> visited) throws XMLStreamException, IOException {
+        Map<String, String> properties = new TreeMap<>();
+
+        File parentFile = getParentFile(pomFile, parent);
+        if (parentFile == null || !visited.add(parentFile.getCanonicalFile())) {
+            return properties;
+        }
+
+        POMInfo parentInfo = readPom(Readers.read(parentFile));
+        Dependency parentPom = parentInfo.getThisPom();
+        if (!parent.getGroupId().equals(parentPom.getGroupId()) || !parent.getArtifactId().equals(parentPom.getArtifactId())) {
+            return properties;
+        }
+
+        if (parentInfo.getParent() != null) {
+            properties.putAll(readInheritedProperties(parentFile, parentInfo.getParent(), visited));
+        }
+        properties.putAll(parentInfo.getProperties());
+
+        return properties;
+    }
+
+    /**
+     * Returns the file of the parent POM in the project tree, or null if the parent is only
+     * available from a repository.
+     *
+     * @param pomFile the POM declaring the parent
+     * @param parent  the parent declared by the POM
+     */
+    private File getParentFile(File pomFile, Dependency parent) {
+        String relativePath = parent.getRelativePath();
+        if (relativePath == null) {
+            relativePath = "../pom.xml";
+        } else if (relativePath.isEmpty()) {
+            // <relativePath/> tells Maven the parent is only available from a repository
+            return null;
+        }
+        File parentFile = new File(pomFile.getParentFile(), relativePath);
+        if (parentFile.isDirectory()) {
+            parentFile = new File(parentFile, "pom.xml");
+        }
+        return parentFile.isFile() ? parentFile : null;
     }
 
     public POMInfo readPom(Reader originalPom) throws XMLStreamException {
+        return readPom(originalPom, Collections.<String, String>emptyMap());
+    }
+
+    /**
+     * @param inheritedProperties the properties defined by the parent POMs, used to expand the
+     *        values of the POM but not reported in the properties of the POMInfo returned
+     */
+    private POMInfo readPom(Reader originalPom, Map<String, String> inheritedProperties) throws XMLStreamException {
         XMLStreamReader parser = factory.createXMLStreamReader(new BufferedReader(originalPom));
         
         // Stack of the XML path currently parsed. Most deepest XML element is first in the list.
@@ -181,7 +263,8 @@ public class POMReader {
             thisPom.setVersion(parent.getVersion());
         }
 
-        Map<String, String> inferedProperties = new TreeMap<>(properties);
+        Map<String, String> inferedProperties = new TreeMap<>(inheritedProperties);
+        inferedProperties.putAll(properties);
         
         inferedProperties.put("pom.groupId", thisPom.getGroupId());
         inferedProperties.put("project.groupId", thisPom.getGroupId());
@@ -205,6 +288,9 @@ public class POMReader {
         }
 
         expandProperties(thisPom, inferedProperties);
+        if (parent != null) {
+            expandProperties(parent, inferedProperties);
+        }
 
         // the former code did not call expandProperties for EXTENSIONS
         for(List<Dependency> deplist : dependencies.values()) {


=====================================
src/test/java/org/debian/maven/repo/POMReaderTest.java
=====================================
@@ -379,6 +379,41 @@ public class POMReaderTest {
     /**
      * Ensures all modules are properly parsed, including those defined in a profile.
      */
+    @Test
+    public void testReadVersionsWithProperties() throws Exception {
+        POMReader instance = new POMReader();
+
+        POMInfo info = instance.readPom(TemporaryPomFolder.getFileInClasspath("versions-with-properties/pom.xml"));
+        assertEquals("1.2.3", info.getThisPom().getVersion());
+
+        info = instance.readPom(TemporaryPomFolder.getFileInClasspath("versions-with-properties/libs/pom.xml"));
+        assertEquals("1.2.3", info.getThisPom().getVersion());
+        assertEquals("1.2.3", info.getParent().getVersion());
+
+        info = instance.readPom(TemporaryPomFolder.getFileInClasspath("versions-with-properties/libs/core/pom.xml"));
+        assertEquals("1.2.3", info.getThisPom().getVersion());
+        assertEquals("1.2.3", info.getParent().getVersion());
+        assertEquals("example-libs", info.getParent().getArtifactId());
+        assertEquals("1.2.3", info.getDependencies().get(DEPENDENCIES).get(0).getVersion());
+        assertEquals("The property redefined by the closest parent wins", "3.19.0", info.getDependencies().get(DEPENDENCIES).get(1).getVersion());
+        assertFalse("The inherited properties aren't reported", info.getProperties().containsKey("revision"));
+
+        // The parent is a sibling module referenced by its relative path
+        info = instance.readPom(TemporaryPomFolder.getFileInClasspath("versions-with-properties/app/pom.xml"));
+        assertEquals("1.2.3", info.getThisPom().getVersion());
+        assertEquals("1.2.3", info.getParent().getVersion());
+        assertEquals("33.4.8-jre", info.getDependencies().get(DEPENDENCIES).get(0).getVersion());
+
+        // The property in the version of the parent is defined by the POM itself
+        info = instance.readPom(TemporaryPomFolder.getFileInClasspath("versions-with-properties/legacy/pom.xml"));
+        assertEquals("1.0", info.getThisPom().getVersion());
+        assertEquals("1.2.3", info.getParent().getVersion());
+
+        // The POM in the directory above isn't the parent declared, its properties aren't inherited
+        info = instance.readPom(TemporaryPomFolder.getFileInClasspath("versions-with-properties/tools/pom.xml"));
+        assertEquals("${revision}", info.getThisPom().getVersion());
+    }
+
     @Test
     public void testReadModules() throws Exception {
         POMReader reader = new POMReader();


=====================================
src/test/resources/versions-with-properties/app/pom.xml
=====================================
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- The parent is a sibling module -->
+  <parent>
+    <groupId>org.example</groupId>
+    <artifactId>example-bom</artifactId>
+    <version>${revision}</version>
+    <relativePath>../bom</relativePath>
+  </parent>
+
+  <artifactId>example-app</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>${guava.version}</version>
+    </dependency>
+  </dependencies>
+</project>


=====================================
src/test/resources/versions-with-properties/bom/pom.xml
=====================================
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.example</groupId>
+    <artifactId>example-parent</artifactId>
+    <version>${revision}</version>
+  </parent>
+
+  <artifactId>example-bom</artifactId>
+  <packaging>pom</packaging>
+
+  <properties>
+    <guava.version>33.4.8-jre</guava.version>
+  </properties>
+</project>


=====================================
src/test/resources/versions-with-properties/legacy/pom.xml
=====================================
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- The property in the version of the parent is defined by this POM -->
+  <parent>
+    <groupId>org.example</groupId>
+    <artifactId>example-parent</artifactId>
+    <version>${example.version}</version>
+  </parent>
+
+  <artifactId>example-legacy</artifactId>
+  <version>1.0</version>
+
+  <properties>
+    <example.version>1.2.3</example.version>
+  </properties>
+</project>


=====================================
src/test/resources/versions-with-properties/libs/core/pom.xml
=====================================
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.example</groupId>
+    <artifactId>example-libs</artifactId>
+    <version>${revision}</version>
+  </parent>
+
+  <artifactId>example-core</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.example</groupId>
+      <artifactId>example-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>${commons-lang.version}</version>
+    </dependency>
+  </dependencies>
+</project>


=====================================
src/test/resources/versions-with-properties/libs/pom.xml
=====================================
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.example</groupId>
+    <artifactId>example-parent</artifactId>
+    <version>${revision}</version>
+  </parent>
+
+  <artifactId>example-libs</artifactId>
+  <packaging>pom</packaging>
+
+  <properties>
+    <!-- Overrides the value defined by the parent -->
+    <commons-lang.version>3.19.0</commons-lang.version>
+  </properties>
+
+  <modules>
+    <module>core</module>
+  </modules>
+</project>


=====================================
src/test/resources/versions-with-properties/pom.xml
=====================================
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.example</groupId>
+  <artifactId>example-parent</artifactId>
+  <version>${revision}</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <revision>1.2.3</revision>
+    <commons-lang.version>3.18.0</commons-lang.version>
+  </properties>
+
+  <modules>
+    <module>libs</module>
+    <module>bom</module>
+    <module>app</module>
+    <module>tools</module>
+    <module>legacy</module>
+  </modules>
+</project>


=====================================
src/test/resources/versions-with-properties/tools/pom.xml
=====================================
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- The parent isn't the POM in the directory above -->
+  <parent>
+    <groupId>org.apache</groupId>
+    <artifactId>apache</artifactId>
+    <version>33</version>
+  </parent>
+
+  <groupId>org.example</groupId>
+  <artifactId>example-tools</artifactId>
+  <version>${revision}</version>
+</project>



View it on GitLab: https://salsa.debian.org/java-team/maven-repo-helper/-/compare/65cd84f4d626d91cde7730b5cf52cd37d4d4d85a...591191d382ddae502e5faa878eb9bf690a204659

-- 
View it on GitLab: https://salsa.debian.org/java-team/maven-repo-helper/-/compare/65cd84f4d626d91cde7730b5cf52cd37d4d4d85a...591191d382ddae502e5faa878eb9bf690a204659
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20261027/3f486140/attachment.htm>


More information about the pkg-java-commits mailing list