Question

I have dev/XYZ.properties file, i am building a jar file using maven -P dev install. How can I place the property file in child.jar/META-INF/XYZ.properties file

Was it helpful?

Solution

You have to execute the maven-resources-plugin:copy-resources goal for your profile dev and bind it with the appropriate phase (process-resources seems the best phase to me). Here is how to define your profile 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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top