在多个模块上运行maven插件目标

时间:2015-07-02 07:47:09

标签: java maven

所以我的项目中有很多maven模块,我想在多个模块上运行一个maven插件的目标

这就是我的所作所为:

mvn -pl module1,module2,module3 wls:deploy

不幸的是,这就是我得到的:

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

所以问题是maven SKIPS在第一个模块之后的所有模块,我希望在所有模块上解雇目标。

这是我想要实现的目标:

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

我使用的插件是:

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

如何让maven在两个模块上运行目标?

1 个答案:

答案 0 :(得分:1)

使用maven子模块功能,例如来自互联网的天气和webapp模块

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

然后mvn -pl simple-parent wls:deploy