2012-09-14 50 views
1

我有一个Maven项目,它生成一个WAR文件并尝试从代码库中维护的.properties文件中的属性中获取工件版本。我也尝试使用自定义属性来形成WAR文件的最终名称。使用自定义属性构建的版本安装和部署maven工件

段:

<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/xsd/maven-4.0.0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 

    ... 

    <groupId>com.xyz.webapps</groupId> 
    <artifactId>webapps</artifactId> 
    <version>${info.version}-${application.env}</version> 
    <packaging>war</packaging> 
    <!-- Filling in the artifact version with properties read below --> 

    ... 

    <!-- Filling in the WAR name --> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <maven.war.final.name>${pom.artifactId}-${pom.currentVersion}.war</maven.war.final.name> 
    <maven.test.skip>true</maven.test.skip> 
    </properties> 

... 

<build> 
    <plugins> 

    ... 

    <!-- I read those properties files here --> 
    <plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>properties-maven-plugin</artifactId> 
    <version>1.0-alpha-2</version> 
    <executions> 
     <execution> 
     <phase>validate</phase> 
     <goals> 
      <goal>read-project-properties</goal> 
     </goals> 
     <configuration> 
      <files> 
      <file>${project.basedir}/webapps-main/src/main/resources/MessageResources.properties</file> 
      <file>${project.basedir}/build.properties</file> 
      </files> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

    ... 

</plugins> 

... 
</project> 

当我做了 “MVN清洁包” WAR文件的名称才能正确生成:

[INFO] Assembling webapp[webapps] in [/home/jubuntu/workspace/ui/new/webapps/target/webapps-2.8-qa] 
[INFO] Processing war project 
[INFO] Copying webapp resources[/home/jubuntu/workspace/ui/new/webapps/webapps-main/src/main/webapp] 
[INFO] Webapp assembled in [4690 msecs] 
[INFO] Building war: /home/jubuntu/workspace/ui/new/webapps/target/webapps-2.8-qa.war 

但是,当我做了一个 “MVN干净安装”(或“mvn clean deploy”),由于某些原因,属性不会扩展(程序包阶段仍会生成带有正确名称的WAR):

[INFO] Building war: /home/jubuntu/workspace/ui/new/webapps/target/webapps-2.8-qa.war 
[INFO] [install:install {execution: default-install}] 
[INFO] Installing /home/jubuntu/workspace/ui/new/webapps/target/webapps-2.8-qa.war to /home/jubuntu/.m2/repository/com/xyz/webapps/webapps/${info.version}-${application.env}/webapps-${info.version}-${application.env}.war 

我在这里有什么不对吗?我如何使这项工作安装和部署我的工件?我为我的版本使用maven版本2.2.1。谢谢。

回答

1

你不能这样做。 Maven不支持它。这是根本。

+0

感谢您的快速回复!我不知道这是Maven的一个基本功能,它不能被覆盖。看起来快照将不得不这样做。 –

相关问题