3

There's project with different modules and dependencies and all of them are needed to be mvn clean installed one by one in a particular sequence.And they have different parents and that can't be changed. Now how can I automate this process with maven reactor.So just by performing "mvn clean install" just once will perform the same operation on all the modules in the given sequence .

  • Is this a multi module build? – khmarbaise Apr 01 '19 at 09:37
  • well all I know is there are 20 modules which are expected to work only if they are clean installed in a given sequence. – AkashDeep Shukla Apr 01 '19 at 09:47
  • If you have a parent pom which contains `..` and all module (childs) define a parent to the previously mentioned parent you should be able to build them in one go from the parent location with `mvn clean package`. There should no need for `mvn clean install`..you have to define the dependencies between the modules. – khmarbaise Apr 01 '19 at 10:14
  • @khmarbaise that's the problem ... the children have org's repos as parent . there's no common parent pom. – AkashDeep Shukla Apr 01 '19 at 10:49
  • But that's now called an aggregator which should work. Just call `mvn clean package` from the root module ? – khmarbaise Apr 01 '19 at 12:14
  • @khmarbaise did what you said and got this error Rule 0: org.apache.maven.plugins.enforcer.ReactorModuleConvergence failed with message: The reactor contains different versions. The reactor is not valid – AkashDeep Shukla Apr 01 '19 at 12:26
  • That's something different which means you have enforcer in your build..which either means you have to line up your versions in all your pom's but based on what you said that will not work which means your parent inherits/uses enforcer rules which are not valid in this circumstances.. – khmarbaise Apr 01 '19 at 18:59
  • @khmarbaise so what other options do I have ? – AkashDeep Shukla Apr 02 '19 at 04:38
  • you have to either a different parent or change your pom depending on where the rules is configured. But this rules gives a hint that the versions in your multi module build should be same....furthermore having different parents in your multi module build makes usually no sense and the enforcer rules shows someone has thought about that?... – khmarbaise Apr 02 '19 at 04:39
  • but I am not supposed to alter anything in the existing poms. I can only create a new pom and use the existing ones. Anything that I can do ? and about versions, they all have different versions as they are being developed by separate teams.So Iam not sure about anything...any way that I can perform clean install without changing the parent of those poms ? – AkashDeep Shukla Apr 02 '19 at 06:55
  • can you help me with the error I'm receiving in the maven reactor ? is there any workaround ? Rule 0: org.apache.maven.plugins.enforcer.ReactorModuleConvergence failed with message: The reactor contains different versions. The reactor is not valid – AkashDeep Shukla Apr 02 '19 at 08:49
  • @khmarbaise ... – AkashDeep Shukla Apr 02 '19 at 09:18

2 Answers2

1

Maybe you can Work with Multiple Modules https://maven.apache.org/guides/mini/guide-multiple-modules.html

MayNull
  • 11
  • 1
-1

You can create a new parent of all other parents, this parent will be projects aggregator for all the other modules (the other parents), in that new parent you can order the modules as you want

<?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>build-all</groupId>
    <artifactId>build-all</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <modules>
        <module>../proj1/pom.xml </module>
        <module>../proj2/pom.xml </module>
        .
        .

    </modules>

</project>
Melad Basilius
  • 3,847
  • 10
  • 44
  • 81
  • those parents are repos of an org and I think that can't be done the way you proposed it to do. – AkashDeep Shukla Apr 01 '19 at 09:51
  • I had the same issue and fixed it using this idea – Melad Basilius Apr 01 '19 at 11:04
  • how can I create a parent pom of those repos which are not in my system at the begining ? I told you that the modules have some repos which are not the part of project, are the parent of those modules. And if I try the code in the screenshot, it gives Rule 0: org.apache.maven.plugins.enforcer.ReactorModuleConvergence failed with message: The reactor contains different versions. The reactor is not valid – AkashDeep Shukla Apr 01 '19 at 11:15