Tarlog
Tarlog

Reputation: 10154

Find and replace a jar file using Maven

Suppose you are working on a big project, which is run on some application server (let's say Tomcat, but it may be also Jboss, or Jetty, or something else). The project consists of a several wars, while each war contains a lot of jar. The whole thing is built using Maven and it takes a lot of time to build it all.

Now, suppose a developer makes a change in just one module that produces one small jar. To continue working and test the change, the developer needs to replace this jar in the relevant wars and restart server (sometimes it's sufficient to redeploy wars). It's much faster then rebuilding the whole application. I have seen a lot of developers (including myself) creating shell scripts for this task.

However, it could be much nicer, if it could be done automatically using maven. Let's say when running "mvn install" the plugin will also go to some predefined location (e.g. ${tomcat}/webapps) and search for all appearances of myjar.jar and replace them with a new version (We have multiple jars, remember?)

Does anyone know about such a plugin? Or may be about some other tool that can do the same task? Or some better idea how to do it?

Updated: Btw, If I don't find a solution, I'll probably implement it myself. So please let me know if you are interested. I'll need some beta testers :)

Updated: So I created the plugin myself. See http://code.google.com/p/replace-file-plugin/ Any feedback is appreciated.

Upvotes: 4

Views: 2524

Answers (4)

Tarlog
Tarlog

Reputation: 10154

Well, any features I asked for in this question, I have implemented myself. See http://code.google.com/p/replace-file-plugin/ I'll appreciate any feedback.

Upvotes: 2

Anton Kraievyi
Anton Kraievyi

Reputation: 4342

Let's narrow the scope to one and only war file, I think you'd scale this up to your scenario yourself with no trouble.

You may try this option: create a final assembly module which runs fast and combines all dependee modules into one war-file. Then, if you initially do mvn clean package install for the whole build, you'd have to mvn clean package install the changed dependee module and re-run the final assembly module to quickly get grab on the updated war. This is quite stateful build scheme (and thus error prone), but after some getting familiar with this approach to change propagation you'd probably think this is the most simple idea that might work, and work faster.

Upvotes: 0

Andy
Andy

Reputation: 8949

Check out JRebel. It rocks, reduces development/deployment time a lot. There is a 30 day free trial, so check it out for free. I purchased my own license, it took my company a few weeks to approve purchasing it, and I couldn't wait.

Seriosuly man, it rocks. Read about it, it can do what you want.

Upvotes: 2

deluan
deluan

Reputation: 1865

If you can write your script as a Ant build, you can use the Maven Antrun plugin to embed the Ant build in your build lifecycle.

Upvotes: 0

Related Questions