1.) How to accept multiple persistence, datasource too belongings files depending on the profile or surroundings variable (xxx-dev, xxx-integr, xxx-prod)?
2.) How to execute a maven copy/rename/move inwards a pom?
3.) How to execute an emmet if within a maven pom?
It's best to response this inquiry inwards this uncomplicated chunk of code :-)
<plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>install</phase> <configuration> <target> <echo>Execute emmet tasks</echo> <taskdef resource="net/sf/antcontrib/antcontrib.properties"> </taskdef> <if> <isset property="local.tomcat.home" /> <then> <copy file="${project.basedir}/src/main/resources/ipiel-${env}.properties" tofile="${local.tomcat.home}\conf\ipiel.properties" /> </then> </if> <copy file="${project.basedir}/src/main/resources/META-INF/persistence-${env}.xml" tofile="${project.build.directory}/${project.artifactId}-${project.version}/META-INF/persistence.xml" /> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>ant-contrib</groupId> <artifactId>ant-contrib</artifactId> <version>20020829</version> </dependency> </dependencies> </plugin>
Some notes:
1.) We demand to define a dependency to ant-contrib to endure able to role the emmet if tag.
2.) The re-create belongings file volition execute if property local.tomcat.home is set.
Note, using -P production volition solely activate that profile simply volition non supervene upon whatsoever variable inwards the actual belongings file. To endure able to larn the actual file nosotros demand to specify -Denv=prod. Also nosotros demand to bind it to the exam stage too non the install phase.
0 komentar:
Please comment if there are any that need to be asked.