2012-10-01 38 views
0

當我升級行家我有一個特性插件問題:升級Maven的2到Maven 3

    <groupId>org.codehaus.mojo</groupId> 
        <artifactId>properties-maven-plugin</artifactId> 

在我的POM我已經定義的屬性:

<?xml version="1.0" encoding="UTF-8"?> 
<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"> 
    <modelVersion>4.0.0</modelVersion> 
    <artifactId>...</artifactId> 
    <groupId>...</groupId> 
    <packaging>war</packaging> 
    <version>1.0.10-SNAPSHOT</version> 
    <name>...</name> 



<properties> 

    <!-- application --> 
    <appname>appname1</appname> 

</properties> 

<build> 
    ... // here I dont have properties plugin because I dont need them 
<plugin> 
       <artifactId>maven-war-plugin</artifactId> 
       <configuration> 
        <warName>${appname}</warName> // here is stil name in pom 
        <webResources> 
         <resource> 
          <filtering>true</filtering> 
          <directory>src/main/webapp</directory> 
         </resource> 
        </webResources> 
       </configuration> 
      </plugin> 
... 
</build> 

<profiles>  

    <profile> 
     <id>config</id> 
     <activation> 
      <property> 
       <name>config</name> 
      </property> 
     </activation> 
     <properties> 
      <config>${basedir}/../config/${config}/build.properties</config> 
     </properties> 
     <build> 
      <plugins>     
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>properties-maven-plugin</artifactId> 
        <version>1.0-alpha-2</version> 
        <executions> 
         <execution> 
          <phase>initialize</phase> 
          <goals> 
           <goal>read-project-properties</goal> 
          </goals> 
          <configuration> 
           <files> 
            <file>${config}</file> 
           </files> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin>      
      </plugins> 
     </build> 
    </profile> 

</profiles> 

<dependencies> 
... 
</dependencies> 

</project> 

那麼我的個人資料:

<profile> 
      <id>config</id> 
      <activation> 
       <property> 
        <name>config</name> 
       </property> 
      </activation> 
      <properties> 
       <konfig>${basedir}/../config/${config}/build.properties</konfig> 
      </properties> 
      <build> 
       <plugins>      
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>properties-maven-plugin</artifactId> 
         <version>1.0-alpha-2</version> 
         <executions> 
          <execution> 
           <phase>initialize</phase> 
           <goals> 
            <goal>read-project-properties</goal> 
           </goals> 
           <configuration> 
            <files> 
             <file>${konfig}</file> 
            </files> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin>      
       </plugins> 
      </build> 
     </profile> 

在那裏我可以指定屬性的另一個文件:

文件包含:

appname=appname2 

所以LOGIS是,當我運行mvn ......沒有配置文件屬性是從POM拍攝。如果使用配置文件,它應該使用config文件中的屬性。這與maven 2一起工作,但maven 3仍然從pom獲得屬性。有沒有辦法如何解決它?

這裏:http://mojo.codehaus.org/properties-maven-plugin/read-project-properties-mojo.html被寫:

屬性:

Requires a Maven 2.0 project to be executed. 

這意味着,這個插件是不是與Maven 3支持?

+0

您可以顯示完整的POM,因爲我懷疑這是基於屬性 - Maven的插件。 – khmarbaise

+0

我不能顯示整個POM,但我編輯它,並顯示只是重要的一部分。有趣的是,當我從POM中刪除屬性然後它的工作,所以只有重寫屬性的問題 – hudi

+0

我已經檢查,與完美的作品的Maven 3.0.3。你可以發佈pom文件嗎... – khmarbaise

回答

0

當從Maven 2的移動的Maven 3要小心,因爲Maven的2負載在啓動時所有的依賴和Maven 3個加載它們點播。因此,構建Maven 3中的工作將打破運行Maven 2的構建箱。經驗教訓。