2013-11-20 132 views
0

我想从属性文件读取属性,然后使用此值获取另一个属性文件的路径来读取它。Maven,使用属性文件读取另一个属性文件

我使用properties-maven-plugin,但它似乎无法做到这一点或我不正确地使用它。

我想这样的事情:

   <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>properties-maven-plugin</artifactId> 
        <version>1.0-alpha-2</version> 
        <executions> 
         <execution> 
          <phase>initialize</phase> 
          <goals> 
           <goal>read-project-properties</goal> 
          </goals> 
          <configuration> 
           <files> 
            <file>${*value from another property file*}/prop.properties</file> 
           </files> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 

回答

1

的Maven本身不允许pom.xml中中使用外部文件的属性 - 这就是为什么你已经使用properties-maven-plugin。 你把自己置于鸡蛋情况下,插件需要在自己之前运行。

可能有用的是,您将两个属性文件都放在文件列表中 - 只要运气好一点就可以解决。

我会做的下一个尝试是添加插件两次(或两次执行)加载第一个属性文件,然后让它在第二个工作。

+0

我使用了两次执行,它工作正常。感谢您的回答。 – XZen

+0

很高兴它工作:) – wemu