Maven Profiles Jar问题

时间:2013-03-25 11:24:13

标签: maven profiles

我有dev / XYZ.properties文件,我正在使用maven -P dev install构建一个jar文件。如何将属性文件放在child.jar / META-INF / XYZ.properties文件

1 个答案:

答案 0 :(得分:0)

您必须为您的个人资料maven-resources-plugin:copy-resources执行dev目标并将其与相应的阶段绑定(process-resources似乎是我的最佳阶段)。以下是如何定义您的个人资料dev

<profile>
  <id>dev</id>
  ...
  <build>
     <plugins>
        <plugin>
           <artifactId>maven-resources-plugin</artifactId>
           <version>2.6</version>
           <executions>
             <execution>
               <id>copy-resources</id>
               <phase>process-resources</phase>
               <goals>
                 <goal>copy-resources</goal>
               </goals>
               <configuration>
                  <outputDirectory>${basedir}/target/classes/META-INF</outputDirectory>
                  <resources>          
                    <resource>
                       <directory>${basedir}/dev</directory>
                       <includes>
                         <include>XYZ.properties</include>
                       </includes>
                    </resource>
                   </resources>              
               </configuration>            
            </execution>
         </executions>
     </plugin>
   </plugins>
</build>