我知道这听起来可能是错误的做法,但我正在尝试拥有一个 Maven POM(模块),它在安装时将打包为 WAR,但另外,作为包含单个 WAR 的 EAR。
澄清一下:我希望将我项目中的每个现有 WAR 包装在它自己的EAR 中。
我的愿望背后的原因是因为我正在考虑重组我们打包发布的 WAR 的方式,以便每个都包含在 EAR 中(但仍然生成一个独立的 WAR 工件以便于开发)。我不热衷于创建一个依赖于 WAR 的新模块并将其打包到 EAR 中,因为我有大量的 WAR。
目前我正在尝试这个,对于我现有的 WAR 模块之一,但没有成功使用分类器:
<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">
<parent>
...
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>se-index-webapp</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
...
</configuration>
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<finalName>search-index.ear</finalName>
<classifier>ear</classifier>
<unpackTypes>war</unpackTypes>
<modules>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<uri>search-index.war</uri>
<bundleFileName>search-index.war</bundleFileName>
<contextRoot>/SearchIndex</contextRoot>
</webModule>
</modules>
</configuration>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
...
</dependencies>
</project>
我得到错误:
Artifact[war:myproject:se-index-webapp] is not a dependency of the project
我正在尝试做的事情可能吗?