0

So I have many maven modules in my project and I'd like to run one maven plugin's goal on multiple modules

Here's what I do:

mvn -pl module1,module2,module3 wls:deploy

Unfortunately here's what I get:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] module1 ............................................... SUCCESS [7.422s]
[INFO] module2 ............................................... SKIPPED
[INFO] module3 ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.370s
[INFO] Finished at: Thu Jul 02 09:34:37 CEST 2015
[INFO] Final Memory: 23M/301M
[INFO] ------------------------------------------------------------------------

So the problem is that maven SKIPS all the modules after the first one, and I'd like the goal to be fired on all modules.

This is what I'd like to achieve:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] module1 ............................................... SUCCESS [7.422s]
[INFO] module2 ............................................... SUCCESS [12.674s]
[INFO] module3 ............................................... SUCCESS [4.563s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.370s
[INFO] Finished at: Thu Jul 02 09:34:37 CEST 2015
[INFO] Final Memory: 23M/301M
[INFO] ------------------------------------------------------------------------

The plugin I use is:

      <groupId>com.oracle.weblogic</groupId>
      <artifactId>wls-maven-plugin</artifactId>
      <version>12.1.1.0</version>

How to make maven run the goal on both modules?

klarki
  • 915
  • 4
  • 13

1 Answers1

0

Use maven submodule functionality, example from internet for weather and webapp modules

<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>

    <groupId>org.sonatype.mavenbook.multi</groupId>
    <artifactId>simple-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>Multi Chapter Simple Parent Project</name>

    <modules>
        <module>simple-weather</module>
        <module>simple-webapp</module>
    </modules>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

  <profiles>
     <profile>
       <id>ci</id>
          <modules>
             <module>simple-weather</module>
             <module>simple-webapp</module>
          </modules> 
      </profile>
  </profiles>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

Then mvn -pl simple-parent wls:deploy

Robert Wadowski
  • 1,407
  • 1
  • 11
  • 14
  • That's not going to solve my problems since the parent has many modules and I want to only execute the goal on module1 and module2. Moreover, when I execute the goal on the parent module, it simply fails straight away. – klarki Jul 02 '15 at 07:56
  • Yes it will solve it but you have to use profiles, see example – Robert Wadowski Jul 02 '15 at 07:57
  • You don't define any profiles at all in the example. – klarki Jul 02 '15 at 07:58
  • Give me time to add ;) ci simple-weather simple-webapp – Robert Wadowski Jul 02 '15 at 07:59
  • Actually that may work, and I haven't think of this before, so thank you, but I still wonder if there is another more elegant way (without using profiles) – klarki Jul 02 '15 at 09:19
  • On http://stackoverflow.com/questions/5539348/how-to-exclude-a-module-from-a-maven-reactor-build there is an alternative -pl !,! – Robert Wadowski Jul 02 '15 at 09:25
  • The problem is rather that even though I supply the modules to fire, it just fires the goal on the first module and SKIPS the other modules. – klarki Jul 02 '15 at 09:41
  • Well still I would choose option I suggest. It is good for long range, I don't want to always remember how to compile some module set. Always you have it written and described. If alternative is not working well ... so maybe stay with profiles. The best practice is to compile whatever you want with one simple command. – Robert Wadowski Jul 02 '15 at 10:03