2013-03-15 46 views
0

我的問題很簡單:我希望maven在資源過濾期間找不到任何屬性時給我一些錯誤消息。
我在官方的maven文檔中找不到任何線索。
那麼我該怎麼做?如何在未找到資源過濾屬性時配置maven資源插件進行投訴?

+0

不幸的是,你不能。請參閱插件參數:http://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html – 2013-03-15 09:32:11

回答

1

我建議採取一個能用於這樣的事情maven-enforcer-plugin一個深沉的樣子:

<project> 
    [...] 
    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-enforcer-plugin</artifactId> 
     <version>1.2</version> 
     <executions> 
      <execution> 
      <id>enforce-property</id> 
      <goals> 
       <goal>enforce</goal> 
      </goals> 
      <configuration> 
       <rules> 
       <requireProperty> 
        <property>basedir</property> 
        <message>You must set a basedir property!</message> 
        <regex>.*\d.*</regex> 
        <regexMessage>The basedir property must contain at least one digit.</regexMessage> 
       </requireProperty> 
       <requireProperty> 
        <property>project.version</property> 
        <message>"Project version must be specified."</message> 
        <regex>.*(\d|-SNAPSHOT)$</regex> 
        <regexMessage>"Project version must end in a number or -SNAPSHOT."</regexMessage> 
       </requireProperty> 
       </rules> 
       <fail>true</fail> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
    [...] 
</project> 
+0

哇...這意味着我希望它所需的所有屬性必須配置在執行目標?這太麻煩了..我想要一種可以向我報告任何遺失財物的方式。 – 2013-03-16 06:28:08

+0

但是哪一個? – khmarbaise 2013-03-16 15:05:35