mavenjenkinspom.xmlparent-pom

How can we build and refer bom in same pom


I have one jenkins job which build parent pom. Inside parent pom I have a module BOM also. The bom itself is being referred in same parent POM like below.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.org.fgn.abs</groupId>
            <artifactId>abs-bom</artifactId>
            <version>${project.version}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies> 
</dependencyManagement>

But it is unable to find the correct version of bom. It is obvious that it won't find the bom because it is not yet build. I am just looking any way to do the same without having separate job for building the bom.

Thanks In advance.


Solution

  • Yes, good question. One option is definitely that, you could have the BOM project build first using a separate job in Jenkins and that way when you build your main Parent project it finds that dependency. I do have some projects configured that way and it should work fine. The other option I think is you could have your BOM project as a module in another Parent project say B, and then include this Parent project in your main Parent project as a module. Honestly I haven't tried the second approach, but you could maybe this a shot.

    HTH