2014-09-25 21 views
0

我有裝載來自名爲的配置文件的某些屬性小ConfigurationSingleton類文件,此刻,configuration_singleton.xml原型如何使生成一個名爲喜歡的artifactId

private ConfigurationSingleton() throws IOException { 
    ... 
    configurationIS = ConfigurationSingleton.class. 
     getResourceAsStream("/configuration_singleton.xml"); 
    ... 

的文件在目錄:

/ 
++- src 
    +-- test 
     +-- resources 
      +-- configuration_singleton.xml 

現在我想用一個原型生成my-project-1.0.0.jar神器這是由my-project-1.0.0.xml文件中配置。像往常一樣,我已經使用Maven的性質${artifactId}${version}這裏:

private ConfigurationSingleton() throws IOException { 
    ... 
    configurationIS = ConfigurationSingleton.class. 
     getResourceAsStream("/${artifactId}-${version}.xml"); 
    ... 

但原型如何使生成一個名爲像${artifactId}-${version}.xml配置文件?

回答

0

正如archetype descriptor fileset報道:

如果文件或目錄名稱包含__property__模式,它會被替換相應的屬性值。

所以,你可以在原型項目的文件系統使用__artifactId____version__的屬性,如:

/ 
+-- src 
    +-- test 
     +-- resources 
      +-- __artifactId__-__version__.xml 

總結

  • 使用${property}內部文件
  • 使用__property__內部文件系統