2009-07-13 20 views
0

我已經在pom.xml中定義了以下文件:無法獲得maven2的配置文件來工作

<profiles> 
    <profile> 
     <id>dev</id> 
     <build> 
     <plugins> 
      <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
       <phase>dev</phase> 
       <goals> 
        <goal>run</goal> 
       </goals> 
       <configuration> 
        <tasks> 
        <delete file="src/main/application/META-INF/data-sources.xml"/> 
        <copy file="src/main/resources/data-sources-dev.xml" tofile="src/main/application/META-INF/data-sources.xml"/> 
        </tasks> 
       </configuration> 
       </execution> 
      </executions> 
      </plugin> 
      <plugin> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <skip>true</skip> 
      </configuration> 
      </plugin> 
     </plugins> 
     </build> 
    </profile> 
    </profiles> 

的問題是,它似乎並沒有工作!

mvn help:effective-pom -P dev 

是否也回顯配置文件。

但是,如果我這樣做

mvn -X -Pdev install 

的刪除/複製部分不是在日誌中可見。

+0

你的意思是pom2.xml或pom.xml? – 2009-07-13 08:45:07

+0

糟糕,pom.xml。編輯。 – tputkonen 2009-07-13 09:14:41

回答

1

我剛剛複製粘貼到一個基本的POM配置,它工作得很好。你確定它沒有出現在配置和配置文件中?如果您將輸出重定向到文件並搜索「antrun」,我懷疑您會看到它在有效pom的構建部分中聲明。

您的antrun插件配置在執行之前需要綁定到包裝類型的有效階段。如果您希望內容在jar中可用(假設jar包裝),則需要在包裝階段之前。我建議流程資源

因此改變:

<phase>dev</phase> 

到:

<phase>process-resources</phase> 
+0

你是什麼意思出現在配置? antrun在-X生成的日誌中不可見。 – tputkonen 2009-07-13 09:20:39