2009-07-13 45 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