I need to know during which phase of the maven cycle the jsp are put on the target directory, and by which process.
I use the grunt-maven-plugin
to do a transformation on my .jsp
files (I generate the insert of the js scripts if you want to know).
Grunt duplicates the jsp file in a temp dir, do its job and put the updated jsp on the target/${project.build.name} directory. (if I only launch grunt, I can check it's work)
My issue is that the updated file is overwritten by the original jsp who is moved on this same repository.
if I only launch grunt(I do a mvn compile
, who launch the grunt task), I can check my grunt work fine. But if I do a mvn install
, the files are overwritten.
I think I can correct it by launching grunt after the original jsp are moved.
Question: Do you know during which phase of the maven cycle the jsp are put on the target directory?
My project is a webapp from the maven artifact webapp, by the way.
I need to know during which phase of the maven cycle the jsp are put on the target directory, and by which process.
During the package
phase by the Maven War Plugin and its war
goal.
Having packaging war
, a Maven build will by default invoke war:war
(war
of the Maven War Plugin) during the package
phase, according to default packaging bindings. Hence, no need to specify it explicitly in your POM file.
The Maven War Plugin will
${project.build.directory}/${project.build.finalName}
, as specified by its webappDirectory
configuration entry.war
file under ${project.build.directory}
by default, as specified by its outputDirectory
configuration entryMy issue is that the updated file is overwritten by the original jsp who is moved on this same repository.
In this case you are having a file conflict, same files (with different content) in the same target folder (target/${project.build.name}
as you mentioned is the same as the default War Plugin outputDirectory above).
You could redirect your modified .jsp
files under a different directory, say target/grunt
and then configure the Maven War Plugin to also take resources from this directory. These additional resources will be added after the default ones and as such override them (in case of conflicts).
For instance, you could configure your POM file with the following addition:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>target/grunt</directory>
</resource>
</webResources>
</configuration>
</plugin>
The global configuration will be also applied to the default Maven War Plugin executed as part of the aforementioned bindings.
In the snippet above, we are saying to the Maven War Plugin to also include resources from the target/grunt
folder. Any .jsp
file present in that folder would then be added to the built webapp (as folder and .war
file) and override the original .jsp
files (as you actually wanted).