有两个配置文件来为 Web 应用程序构建一个依赖 jar(一个用于 tomcat,另一个用于 websphere)。在这里,我正在尝试一次运行这两个配置文件以一起构建这些 jar。
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 中提到了几个解决方案来实现这一点,我们之前也发表了类似的帖子,但在这种情况下对我们没有帮助。任何指针都会有所帮助。
配置文件配置看起来像
<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>
谢谢,桑