Reputation: 7899
I am building one war file using mvn clean install -Dlifecycle=dev
. so i have variable lifecycle
.
Now my requirement is , when i create build file for UAT/PROD
it must exclude one jsp(index.jsp)
from package .My jsp is in webApps directory parallel to resources.
Using profile
only for one page filtering is not good idea i think.
Appreciate any help .
Upvotes: 2
Views: 1045
Reputation: 11607
It starts with one JSP. Next is a customized CSS. Then different DB properties...
A profile is the way to go. Just create one, set its activation to the value of the variable, create another source folder with the JSP and add it to the resources in the profile.
So:
src/dev/webapp
in your project folder (so it is parallel to src/main/webapp
)pom.xml
that configures the war plugin
<profiles>
<profile>
<activation>
<property>
<name>lifecycle</name>
<value>dev</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<directory>src/dev/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
This copies the resources from src/dev/webapps
into the merged target folder when the variable lifecycle
is set to dev
.
Even if those are quite some lines of XML for copying a single file I think it is not a good idea to do it different (e.g. with a plugin that deletes files) when using Maven. While you can customize Maven builds so they aren't recognizable any more, the whole idea is to use the conventions so others can easily read the process.
Upvotes: 3