Search code examples
maveninheritanceparent-pom

Maven Inheritance and Distribution Management


I have developers who use Maven parents external to my organisation. For this particular case the parent is the spring-boot-starter-parent

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

Their builds are working and they have been testing against these dependencies for a long time, I ideally do not want to change their inheritance.

The problem I have as a Release Engineer is that the artifacts produced need to be stored in an internal Maven Repository. We've historically done that by having a Maven Parent that defines the and nothing else, that all projects had as the root of their inheritance chain.

I could end up managing hundreds of POMS and I don't want to put in each one as if we have to move the internal Maven repository I will have to manage a ridiculous number of projects to reflect the change.

Is there any way I can set where I essentially don't have write access to parents? Can this be set in MAVEN_OPTS or as a properties file on the CI servers? I have tried using properties-maven-plugin to input all of our properties but distributionManagement won't accept a property as a variable.


Solution

  • Keeping your org parent pom (other than the parent element you specified earlier) would need you to bring Spring Boot dependencies as a bom:

    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-dependencies</artifactId>
          <version>1.4.1.RELEASE</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>
    

    But I think the less intrusive way might be to set the proper version to your modules using:

    mvn versions:set before building the artifacts and deploying to Nexus (or other Maven repo manager)