How to set custom context path of deployed applications with tomee-maven-plugin?

时间:2015-12-14 18:02:27

标签: maven plugins tomee contextpath

when deploying versioned wars for integration tests how can I manipulate the contexts of those wars whos names are out of my control.

For instance:

<groupId>org.apache.openejb.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>1.7.2</version>

<configuration>
    <tomeeVersion>1.7.2</tomeeVersion>
    <path>/integration-adapter</path>
    <tomeeClassifier>plus</tomeeClassifier>
    <tomeeHttpPort>25180</tomeeHttpPort> 
    <systemVariables>
                <org.slf4j.simpleLogger.defaultLogLevel>debug</org.slf4j.simpleLogger.defaultLogLevel>
                <org.apache.deltaspike.ProjectStage>IntegrationTest</org.apache.deltaspike.ProjectStage> 
    </systemVariables>
    <webapps> 
        <webapp>**com.mycom.backend:some-war:1.0.0-SNAPSHOT**</webapp> 
    </webapps>
</configuration>

The issue I have is, the included war files are deployed with the version in the context eg. http://127.0.0.1:8080/some-war-1.0.0-SNAPSHOT/

How do I rename this when deployed using the tomee plugin ?

eg. http://127.0.0.1:8080/some-war/

Just to reiterate, these wars are not the artifacts I am currently generating as part of my build.

Thanks

1 个答案:

答案 0 :(得分:2)

您可以通过指定自己的(自定义)上下文路径来解决此问题。这可以在<webapp>标记内通过在完全限定的...?name=some-webui文件名的字符串末尾附加war来实现。

生成的插件配置块将是:

<plugin>
    <groupId>org.apache.openejb.maven</groupId>
    <artifactId>tomee-maven-plugin</artifactId>
    <version>1.7.2</version>
    <configuration>
        <tomeeVersion>1.7.2</tomeeVersion>
        <path>/integration-adapter</path>
        <tomeeClassifier>plus</tomeeClassifier>
        <tomeeHttpPort>8080</tomeeHttpPort> 
        <systemVariables>
            <org.slf4j.simpleLogger.defaultLogLevel>debug</org.slf4j.simpleLogger.defaultLogLevel>
            <org.apache.deltaspike.ProjectStage>IntegrationTest</org.apache.deltaspike.ProjectStage> 
        </systemVariables>
        <debugPort>5005</debugPort>
        <args>-Dfoo=bar</args>
        <webapps>
            <webapp>com.mycom.ws:some-war:1.0.0-SNAPSHOT?name=some-webservices</webapp>    
            <webapp>com.mycom.webui:some-war:1.0.0-SNAPSHOT?name=some-webui</webapp>    
        </webapps>
    </configuration>
</plugin>

结果URL应为:

此外,您可以通过使用maven属性来外部化名称/版本信息:

  ...
  <webapp>com.mycom.ws:${webservice.artifact.name}:${webservice.artifact.version}?name=some-webservices</webapp>
  ...

具有以下属性部分:

<properties>
    <webservice.artifact.name>${project.artifactId}</webservice.artifact.name>
    <webservice.artifact.version>${project.version}</webservice.artifact.version>
</properties>