0

I have Maven multi module project where i have hardcoded the pom version in main pom and all of the child pom's as well. But am trying to use the maven-ci-friendly-version to my project.

So i have replaced all of my <version>1.1.0</version> with <version>${revision}</version> in main pom and all of the child pom as well. And in main pom alone i have defined the property value like below

<properties>
   <revision>1.1.0</revision>
</properties>

But when i run the mvn clean install from main pom i can see property inheritance is happening properly, but it is failin in one of the submodule with below error.

Error:

 artifact com.sample:pom:${revision} from/to jcenter (https://bintray.com/bintray/jcenter): Transfer failed for https://bintray.com/bintray/jcenter/com/sample/$%257Brevision%257D/sample-$%257Brevision%257D.pom 410 Gone -> [Help 1]

when i go to com.sample location in .m2 i can see two folders got created. one with actual pom version folder 1 --> 1.1.0 and another with property name folder2 --> ${revision}.

Here build is looking for core pom.xml in folder2 which is ${revision}.

Build is going fine in other modules but only this folder2 is getting created when build reaches that particular module alone.

Then i have opened the pom.xml of that particular module where i can see some of the properties were defined.

This issue is due to the properties defined in that particular submodule ?

We are struck in this for quite long time, appreciate anyone's help.

Edit 1:

I have noticed that when it fails it is due to transitive dependencies at child pom files.

Eg: At child pom level build is failing at the dependencies mentioned at the child pom where the mentioned dependency is dependent on other dependencies.

So it couldn't be able to inherit the ${revision} property value at trasitive dependency.

Edit :2

parent pom

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.foo.bar</groupId>
        <artifactId>primo-config</artifactId>
        <version>1.0</version>
    </parent>
    <groupId>com.sample</groupId>
    <artifactId>core</artifactId>
    <version>${revision}</version>
    <packaging>pom</packaging>
    <name>Ondot</name>
    <profiles>
        <profile>
            <id>profile</id>
            <modules>
                <module>sample</module>
                <module>profile2</module>
            </modules>
        </profile>
    <scm>
        <connection>
            scm:git:<git url>
        </connection>
        <developerConnection>
            scm:git:<git url>
        </developerConnection>
    </scm>
    <properties>
        <revision>1.1.0</revision>
        
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.8</version>
            </dependency>

         
            <dependency>
                <groupId>org.jsoup</groupId>
                <artifactId>jsoup</artifactId>
                <version>1.14.2</version>
            </dependency>

            <dependency>
                <groupId>com.fasterxml.jackson.datatype</groupId>
                <artifactId>jackson-datatype-jsr310</artifactId>
                <version>2.6.5</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <repositories>
    
        <repository>
            <id>maven-nuxeo</id>
            <name>Maven Nuxeo Repository</name>
            <url>https://maven.nuxeo.org/nexus/content/groups/public/</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </repository>


    </repositories>
    <build>
        <pluginManagement>
            <plugins>
        <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>flatten-maven-plugin</artifactId>
      <version>1.1.0</version>
      <configuration>
        <updatePomFile>true</updatePomFile>
        <flattenMode>resolveCiFriendliesOnly</flattenMode>
      </configuration>
      <executions>
        <execution>
          <id>flatten</id>
          <phase>process-resources</phase>
          <goals>
            <goal>flatten</goal>
          </goals>
        </execution>
        <execution>
          <id>flatten.clean</id>
          <phase>clean</phase>
          <goals>
            <goal>clean</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
        <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>3.0.0-M3</version>
  <executions>
    <execution>
      <id>enforce-property-inheritance</id>
      <goals>
        <goal>enforce</goal>
      </goals>
      <configuration>
        <rules>
          <requireProperty>
            <property>revision</property>
          </requireProperty>
        </rules>
      </configuration>
    </execution>
  </executions>
</plugin>

                
        </plugins>
    </build>
</project>

problamatic submoduel pom.xml

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.sample</groupId>
    <artifactId>sample</artifactId>
    <version>${revision}</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <artifactId>sampleCore</artifactId>
  <packaging>jar</packaging>
  <name>Ondot :: Connector Config :: sample:: Core</name>
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>own-dependency-jar</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>

Here this own-dependency-jar will get generated from other module but which is transitive dependency on sample pom(which is parent of sampleCore).

While defining "own-dependency-jar" dependency we have mentioned the version as ${project.version}, so it is trying to resolve transitive dependency. It is looking for sample-1.1.0.pom. but since we have mentioned as project.version it is directly taking version as ${revision} instead of the value of ${revision}.

8
  • You have missed to configure flatten-maven-plugin see the details of the documentation. Commented Jun 20, 2023 at 8:59
  • CAn you create an example project to reproducie that... Commented Jun 20, 2023 at 9:00
  • i did configured flatten-maven-plugin at main pom level, moreover i have a doubt is this even achievable? Commented Jun 20, 2023 at 9:05
  • Please check Edit1 as well. Commented Jun 20, 2023 at 9:46
  • Please make an full working example... Commented Jun 20, 2023 at 13:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.