具有多个子模块WAR的Maven Tomcat插件

时间:2015-01-10 11:38:35

标签: maven cas maven-tomcat-plugin

我有父母pom:

<project>

<properties>
  <global.version>1.0-SNAPSHOT</global.version>
  <cas.version>4.0.0</cas.version>
</properties>

<modelVersion>4.0.0</modelVersion>
  <groupId>uk.co.g4me.cas</groupId>
  <artifactId>cas-maven-overlay</artifactId>
  <packaging>pom</packaging>
<version>${global.version}</version>

<build>

<plugins>

  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <port>8080</port>
      <httpsPort>8443</httpsPort>
      <keystoreFile>${user.home}/.keystore</keystoreFile>
      <keystorePass>changeit</keystorePass>
      <webapps> 
        <webapp> 
          <groupId>uk.co.g4me.cas</groupId> 
          <artifactId>cas-server</artifactId> 
          <version>${global.version}</version> 
          <type>war</type>    
          <asWebapp>true</asWebapp> 
        </webapp>
        <webapp> 
          <groupId>uk.co.g4me.cas</groupId> 
          <artifactId>cas-services</artifactId> 
          <version>${global.version}</version> 
          <type>war</type>    
          <asWebapp>true</asWebapp> 
        </webapp>
      </webapps>
    </configuration>
  </plugin>

</plugins>  

</build>

<repositories>
  <repository>
    <id>ja-sig</id>
    <url>http://oss.sonatype.org/content/repositories/releases/</url>
  </repository>
</repositories>

<modules>
  <module>cas-services</module>
  <module>cas-server</module>
</modules> 

</project>

两个子模块poms:

CAS服务:

<project>

  <parent>
    <groupId>uk.co.g4me.cas</groupId>
    <artifactId>cas-maven-overlay</artifactId>
    <version>${global.version}</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <artifactId>cas-services</artifactId>
  <packaging>war</packaging>

  <dependencies>

    <dependency>
      <groupId>org.jasig.cas</groupId>
      <artifactId>cas-management-webapp</artifactId>
      <version>${cas.version}</version>
      <type>war</type>
      <scope>compile</scope>
    </dependency>   

  </dependencies>

</project>

CAS-服务器:

<project>
  <parent>
    <groupId>uk.co.g4me.cas</groupId>
    <artifactId>cas-maven-overlay</artifactId>
    <version>${global.version}</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <artifactId>cas-server</artifactId>
  <packaging>war</packaging>

  <dependencies>

    <dependency>
      <groupId>org.jasig.cas</groupId>
      <artifactId>cas-server-webapp</artifactId>
      <version>${cas.version}</version>
      <type>war</type>
      <scope>compile</scope>
    </dependency>

  </dependencies>

</project>

按原样运行会导致构建失败:

Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run (default-cli) 
on project cas-services: Execution default-cli of goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run 
failed: addChild:  Child name '/cas-services' is not unique

这个错误是相当自我解释的,显然tomcat正在编译子模块并包括用于部署的类。

所以我在这里尝试做的事情有什么明显的错误吗?

我尝试过多种不同的配置但却无法让它们很好地配合使用。

如果我删除模块元素,一切正常。然而,这不太理想,因为最终会添加更多的模块,我想从父母那里清理和安装它们。

我也怀疑这可以通过设置个人资料来解决,但我想在解决这个问题之前我想先了解这个问题。

任何见解都表示赞赏。

0 个答案:

没有答案
相关问题