On Tue, Aug 4, 2009 at 9:25 AM, David Hoffer<dhoff...@gmail.com> wrote:
> What is the maven way of creating a patched jar?
>
> I have a case where I need to apply some overrides to a binary jar which is
> one of my dependencies.  I have the source code for the overrides.  So I
> could create a child module with the source and the one dependency that
> needs the overrides applied.  What maven plugin would I use to extract the
> class files from the dependency, combine with the new generated classes from
> source, and then re-jar?  The final artifact would have a new name, i.e.
> _patched, so as to not get confused with the original.  How can I then stop
> the transitive dependency on the original jar?  I would want the dependency
> to be on the new patched version only.
>

1. Create a project with a new groupId, artifactId, and version.

2.  Publish this third-party binary to a repository manager - you can
use one of the various repository managers that allow you to manually
upload an artifact.   (Me?  I'd recommend Nexus).

3. Use the dependency plugin to unpack the artifact to your project's
target/classes.   Bind the unpack goal to generate-sources or
generate-resources so that the download and unpack.

Unpack Mojo: 
http://maven.apache.org/plugins/maven-dependency-plugin/examples/unpacking-artifacts.html
Intro to Lifecycle:
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

4. Package, publish your new patched artifact to a repository manager
(under a new groupId, artifactId, version).

The key here is that you create a project that patches the original
artifact and then publishes it under a different GAV coordinate.   I
would not recommend patching the JAR and then writing it back to the
repository manager under the same GAV coordinate: 1. You are going to
have a GAV collision, and 2. It makes it difficult to update to a new
version of this binary dependency.

> What's the maven way of doing this sort of thing?
>

Good luck.

> -Dave
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to