2016-11-16 61 views
0

我需要從性能Maven中pom.xml文件使用maven的值pom.xml的,所以我用屬性 - Maven的插件來閱讀我的屬性文件如下讀取屬性文件到不工作

的pom.xml

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>properties-maven-plugin</artifactId> 
    <version>1.0-alpha-2</version> 
    <executions> 
     <execution> 
      <phase>validate</phase> 
      <goals> 
       <goal>read-project-properties</goal> 
      </goals> 
      <configuration> 
       <files> 
        <file>${basedir}/src/main/resources/qura.properties</file> 
       </files> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

qura.properties文件包含了這樣的事情..

config.file.path = resources/python/config/test.py 

我需要在pom.xml中

的資源要素使用config.file.path變量

的pom.xml

<resources> 
    <resource> 
     <directory>${basedir}/multilang/</directory> 
     <includes>    
      <include>${config.file.path}</include> 
     </includes> 
    </resource> 
<resources> 

但是$ {} config.file.path值不是從qura.properties文件佔用,我無法找到JAR文件test.py。

我在做什麼錯在這段代碼?

由於提前

回答

0

嘗試使用1.0.0版本,並在屬性文件中刪除圍繞等號空間。

如:

key=value 
+0

謝謝..但它甚至不去掉空格後爲我工作.. –

0

IMO,這不要緊,你是否把空格或不在身邊等號屬性文件中。您可能需要檢查${config.file.path}是否存在於由${basedir}/multilang指定的目錄中

以下代碼段適用於我。

<plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-resources-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <id>copy-resources</id> 
        <goals> 
         <goal>copy-resources</goal> 
        </goals> 
        <configuration> 
         <resources> 
          <resource> 
           <directory>src/main</directory> 
           <includes> 
            <include>${config.file.path}</include> 
           </includes> 
          </resource> 
         </resources> 
        </configuration> 
        <inherited></inherited> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>properties-maven-plugin</artifactId> 
      <version>1.0-alpha-2</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>read-project-properties</goal> 
        </goals> 
        <configuration> 
         <files> 
          <file>${basedir}/src/main/resources/qura.properties</file> 
         </files> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
+0

謝謝..但加入Maven的資源 - 插件包含在屬性文件中的資源和去掉空格沒有爲我工作。我確信存在$ {config.file.path}目錄。 –

+0

我的一般要求是我需要包含特定於特定於客戶端的資源的資源,比如說我想包含客戶端1的test1.py和客戶端2的test2.py,所以我嘗試了這個文件名屬性文件,並嘗試使用它在POM.xml ..但它不適用於我..是否有任何其他方式來包括我所需要的資源 –