Local and production configuration files in Maven Project -


i'm starting out maven , have question regarding selecting resources deployment. have local , production properties directory, , when deploy want have 1 of them selected , put in appropriate place. project structure this

- | -/src |  | -/main |  |  | -/java |  |  | -/resources |  |  | -/webapp |  |  |  | -/web-inf | -/config |  | -/local |  |  | -/properties |  |  |  | -config.properties |  | -/prod |  |  | -/properties |  |  |  | -config.properties | -/web-inf 

so when deploy should select appropriate properties folder , put /web-inf/. how can achieve that?

on side note, related, should config directory inside src/main/resources?

you can thing following (which have already):

. |-- pom.xml `-- src     |-- main     |   |-- java     |   |-- resources     |   |-- environment     |   |   |-- test     |   |   |   `-- database.properties     |   |   |-- qa     |   |   |   `-- database.properties     |   |   `-- production     |   |       `-- database.properties     |   `-- webapp 

apart above need every environment maven-assembly-descriptor following:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"   xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xsi:schemalocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">    <id>test</id>   <formats>     <format>war</format>   </formats>   <includebasedirectory>false</includebasedirectory>   <dependencysets>     <dependencyset>       <unpack>true</unpack>       <useprojectartifact>true</useprojectartifact>     </dependencyset>   </dependencysets>   <filesets>     <fileset>       <outputdirectory>web-inf</outputdirectory>       <directory>${basedir}/src/main/environment/test/</directory>       <includes>         <include>**</include>       </includes>     </fileset>   </filesets> </assembly> 

you need change folders according locations , need execution of maven-assembly-plugin produce appropriate artifacts this:

 <plugin>     <groupid>org.apache.maven.plugins</groupid>     <artifactid>maven-assembly-plugin</artifactid>     <executions>       <execution>         <id>test</id>         <phase>package</phase>         <goals>           <goal>single</goal>         </goals>         <configuration>           <descriptors>             <descriptor>${project.basedir}/src/main/assembly/test.xml</descriptor>           </descriptors>         </configuration>       </execution>       <execution>         <id>qa</id>         <phase>package</phase>         <goals>           <goal>single</goal>         </goals>         <configuration>           <descriptors>             <descriptor>${project.basedir}/src/main/assembly/qa.xml</descriptor>           </descriptors>         </configuration>       </execution>       <execution>         <id>production</id>         <phase>package</phase>         <goals>           <goal>single</goal>         </goals>         <configuration>           <descriptors>             <descriptor>${project.basedir}/src/main/assembly/production.xml</descriptor>           </descriptors>         </configuration>       </execution>     </executions>   </plugin> 

the result having artifact like

  1. xyz-1.0-snapshot-test.war
  2. xyz-1.0-snapshot-qa.war
  3. xyz-1.0-snapshot-production.war

which created single call of maven mvn clean package. that's it. should aware of approach going deployment direction not job of maven.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -