Wojciech Szymski
Wojciech Szymski

Reputation: 365

Maven: replace file after install

Is there any possibilities to replace some file after "mvn clean install" command in JAR, WAR and EAR package?

I would like to do something like:

  1. generate classes file using external Jar Tool
  2. builds EAR, WAR and JAR packages using maven "mvn clean install" command (using classes generated from 1st step)
  3. Compile jsp servlet class
  4. Generate descriptors and web.xml using external Jar Tool
  5. Replace file like descriptors, web.xml, and compiled JSP servlets.

How can I do this?

Upvotes: 1

Views: 1068

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328614

Move the build step 1 into a different project or an independent module which installs the result in the places where Maven will look (i.e. in the local repository). mvn file:install is your friend.

Or use Maven Antrun plugin and the generate-sources or compile phase.

That way, the special build in step 1 will become just another dependency.

Maven also has a JSP compiler which you can use in step 3 to produce another dependency.

Use the Maven Antrun plugin to produce the custom web.xml and other file descriptors and have an independent module collect everything in a WAR.

So you should split your build into several, independent modules. One just compiles the code. The next step compiles the JSPs (since they use the code from step 1). Next, compile a WAR from that (no Java code is compiled in this step). Lastly, another module that builds an EAR.

Upvotes: 1

Related Questions