从命令行运行多个maven配置文件

时间:2016-03-30 17:15:10

标签: java maven maven-profiles maven-jar-plugin

有两个配置文件为Web应用程序构建一个依赖jar(一个用于tomcat,另一个用于websphere)。在这里我正在尝试的是一次性运行这两个配置文件来构建这些罐子。

mvn help:active-profiles -o -Dmaven.test.skip=true clean install -PTOMCAT,WEBSPHERE

由于这些执行,我们期待 acme-tomcat-0.0.1-SNAPSHOT.jar acme-web-0.0.1-SNAPSHOT.jar 但是除此之外,还创建了一个默认jar acme-0.0.1-SNAPSHOT.jar 。这似乎是因为默认执行。

我们如何避免此默认执行以避免生成默认 acme-0.0.1-SNAPSHOT.jar 。我们在SO中引用couple of solutions来到达此处,我们也made a similar post earlier但在这种情况下我们无法帮助我们。 任何指针都会有所帮助。

配置文件配置类似于

<profiles>
    <profile>
        <id>TOMCAT</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>tom-jar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <finalName>${project.artifactId}-tomcat-${project.version}</finalName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build> 
        <dependencies>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-core</artifactId>
                <version>5.7.0</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
                <version>1.0.1</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.javaee</groupId>
                <artifactId>jboss-jms-api</artifactId>
                <version>1.1.0.GA</version>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>WEBSPHERE</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>web-jar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <finalName>${project.artifactId}-web-${project.version}</finalName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build> 
        <dependencies>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-core</artifactId>
                <version>5.4.3</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
                <version>1.0</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.javaee</groupId>
                <artifactId>jboss-jms-api</artifactId>
                <version>1.1.0.GA</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>

谢谢, 圣

1 个答案:

答案 0 :(得分:0)

使用Volodymyr Kozubal中的指针,将我的TOMCAT配置文件的执行ID更改为:

<execution>
   <id>default-jar</id>
   .........
 </execution>

覆盖默认执行。

谢谢大家

相关问题