How to create patched artifact?
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. What's the maven way of doing this sort of thing? -Dave
Re: How to create patched artifact?
On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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
Re: How to create patched artifact?
Hum, I'm getting close but not quite there yet. Here is my configuration. plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-dependency-plugin/artifactId executions execution idunpack/id phasegenerate-sources/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritetrue/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasestrue/overWriteReleases overWriteSnapshotstrue/overWriteSnapshots /configuration /execution /executions /plugin For some reason after running the install goal the unpack seems to have taken precedence over the compile! Since the generate-sources phase is before compile shouldn't the compile have over written the unpack? I'm confused. -Dave On Tue, Aug 4, 2009 at 8:39 AM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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
Re: How to create patched artifact?
On Tue, Aug 4, 2009 at 1:01 PM, David Hofferdhoff...@gmail.com wrote: Hum, I'm getting close but not quite there yet. Here is my configuration. plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-dependency-plugin/artifactId executions execution idunpack/id phasegenerate-sources/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritetrue/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasestrue/overWriteReleases overWriteSnapshotstrue/overWriteSnapshots /configuration /execution /executions /plugin For some reason after running the install goal the unpack seems to have taken precedence over the compile! install isn't a goal in this case, it is a phase. When you run install, you are asking Maven to walk through the entire lifecycle (except the deploy phase). Instead of trying to test with the install phase, run mvn generate-sources then run mvn compile. Also use the -X flag to get more output. Take a look at the list of phases here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html Since the generate-sources phase is before compile shouldn't the compile have over written the unpack? I'm confused. Do you have source in src/main/java? What is your project's packaging? -Dave On Tue, Aug 4, 2009 at 8:39 AM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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 - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
Yeah, I meant install phase. My pom's packaging is jar, and I have the source in src/main/java. It seems to find the source because for new files I do find the compiled classes in the right places. However what I also find is that for classes in the dependent jar they seem to have overwrote the compiled ones. I think what is happening is that during the compile phase it simply skips the compile (or at least the writing of the class file to disk) if it already exists. How can I configure the compile to always overwrite? -Dave On Tue, Aug 4, 2009 at 12:10 PM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 1:01 PM, David Hofferdhoff...@gmail.com wrote: Hum, I'm getting close but not quite there yet. Here is my configuration. plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-dependency-plugin/artifactId executions execution idunpack/id phasegenerate-sources/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritetrue/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasestrue/overWriteReleases overWriteSnapshotstrue/overWriteSnapshots /configuration /execution /executions /plugin For some reason after running the install goal the unpack seems to have taken precedence over the compile! install isn't a goal in this case, it is a phase. When you run install, you are asking Maven to walk through the entire lifecycle (except the deploy phase). Instead of trying to test with the install phase, run mvn generate-sources then run mvn compile. Also use the -X flag to get more output. Take a look at the list of phases here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html Since the generate-sources phase is before compile shouldn't the compile have over written the unpack? I'm confused. Do you have source in src/main/java? What is your project's packaging? -Dave On Tue, Aug 4, 2009 at 8:39 AM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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
Re: How to create patched artifact?
Tim, 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. Is it really best practise to change groupId and artifactId? I would only change the version so that Maven has a chance to detect collisions. Similar to what Brian recommends for converting a SNAPSHOT version to a release version in this blog entry (see rule #5): http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ /Anders - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
On Tue, Aug 4, 2009 at 1:27 PM, Anders Hammarand...@hammar.net wrote: Tim, 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. Is it really best practise to change groupId and artifactId? I would only change the version so that Maven has a chance to detect collisions. Similar to what Brian recommends for converting a SNAPSHOT version to a release version in this blog entry (see rule #5): http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ If it is something that is public, yes, only change the version. I was assuming this was some gnarly internal binary that someone handed to him because that's what has happened to me in the past.Example: you work on a system that depends on some proprietary, source-less JAR binary. In that case, I'd wrap it with my own GAV and call it a day. But, you are right, if you are patching something like commons-lang or plexus-utils, you would totally preserve the GA and change the V. /Anders - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
On Tue, Aug 4, 2009 at 1:25 PM, David Hofferdhoff...@gmail.com wrote: Yeah, I meant install phase. My pom's packaging is jar, and I have the source in src/main/java. It seems to find the source because for new files I do find the compiled classes in the right places. However what I also find is that for classes in the dependent jar they seem to have overwrote the compiled ones. I think what is happening is that during the compile phase it simply skips the compile (or at least the writing of the class file to disk) if it already exists. How can I configure the compile to always overwrite? Move the copy goal that you declared to happen just after compilation. Look at the lifecycle list, I think you want process-classes -Dave On Tue, Aug 4, 2009 at 12:10 PM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 1:01 PM, David Hofferdhoff...@gmail.com wrote: Hum, I'm getting close but not quite there yet. Here is my configuration. plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-dependency-plugin/artifactId executions execution idunpack/id phasegenerate-sources/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritetrue/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasestrue/overWriteReleases overWriteSnapshotstrue/overWriteSnapshots /configuration /execution /executions /plugin For some reason after running the install goal the unpack seems to have taken precedence over the compile! install isn't a goal in this case, it is a phase. When you run install, you are asking Maven to walk through the entire lifecycle (except the deploy phase). Instead of trying to test with the install phase, run mvn generate-sources then run mvn compile. Also use the -X flag to get more output. Take a look at the list of phases here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html Since the generate-sources phase is before compile shouldn't the compile have over written the unpack? I'm confused. Do you have source in src/main/java? What is your project's packaging? -Dave On Tue, Aug 4, 2009 at 8:39 AM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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
Re: How to create patched artifact?
To resolve the overwrite issue I thought I would attach the maven-dependency-plugin to the process-classes phase so it happens after the compile. I then set its overWrite, overWriteReleases overWriteSnapshots tags to false so it would not overwrite the just compiled output. But it doesn't work, it still overwrites. So I'm back at square 1. -Dave On Tue, Aug 4, 2009 at 12:25 PM, David Hoffer dhoff...@gmail.com wrote: Yeah, I meant install phase. My pom's packaging is jar, and I have the source in src/main/java. It seems to find the source because for new files I do find the compiled classes in the right places. However what I also find is that for classes in the dependent jar they seem to have overwrote the compiled ones. I think what is happening is that during the compile phase it simply skips the compile (or at least the writing of the class file to disk) if it already exists. How can I configure the compile to always overwrite? -Dave On Tue, Aug 4, 2009 at 12:10 PM, Tim O'Brien tobr...@discursive.comwrote: On Tue, Aug 4, 2009 at 1:01 PM, David Hofferdhoff...@gmail.com wrote: Hum, I'm getting close but not quite there yet. Here is my configuration. plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-dependency-plugin/artifactId executions execution idunpack/id phasegenerate-sources/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritetrue/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasestrue/overWriteReleases overWriteSnapshotstrue/overWriteSnapshots /configuration /execution /executions /plugin For some reason after running the install goal the unpack seems to have taken precedence over the compile! install isn't a goal in this case, it is a phase. When you run install, you are asking Maven to walk through the entire lifecycle (except the deploy phase). Instead of trying to test with the install phase, run mvn generate-sources then run mvn compile. Also use the -X flag to get more output. Take a look at the list of phases here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html Since the generate-sources phase is before compile shouldn't the compile have over written the unpack? I'm confused. Do you have source in src/main/java? What is your project's packaging? -Dave On Tue, Aug 4, 2009 at 8:39 AM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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
Re: How to create patched artifact?
I think our emails collided. Just to be clear, here is my new configuration. It does not work because it overwrites what the compiler did. executions execution idunpack/id phaseprocess-classes/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritefalse/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasesfalse/overWriteReleases overWriteSnapshotsfalse/overWriteSnapshots /configuration /execution /executions -Dave On Tue, Aug 4, 2009 at 12:46 PM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 1:25 PM, David Hofferdhoff...@gmail.com wrote: Yeah, I meant install phase. My pom's packaging is jar, and I have the source in src/main/java. It seems to find the source because for new files I do find the compiled classes in the right places. However what I also find is that for classes in the dependent jar they seem to have overwrote the compiled ones. I think what is happening is that during the compile phase it simply skips the compile (or at least the writing of the class file to disk) if it already exists. How can I configure the compile to always overwrite? Move the copy goal that you declared to happen just after compilation. Look at the lifecycle list, I think you want process-classes -Dave On Tue, Aug 4, 2009 at 12:10 PM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 1:01 PM, David Hofferdhoff...@gmail.com wrote: Hum, I'm getting close but not quite there yet. Here is my configuration. plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-dependency-plugin/artifactId executions execution idunpack/id phasegenerate-sources/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritetrue/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasestrue/overWriteReleases overWriteSnapshotstrue/overWriteSnapshots /configuration /execution /executions /plugin For some reason after running the install goal the unpack seems to have taken precedence over the compile! install isn't a goal in this case, it is a phase. When you run install, you are asking Maven to walk through the entire lifecycle (except the deploy phase). Instead of trying to test with the install phase, run mvn generate-sources then run mvn compile. Also use the -X flag to get more output. Take a look at the list of phases here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html Since the generate-sources phase is before compile shouldn't the compile have over written the unpack? I'm confused. Do you have source in src/main/java? What is your project's packaging? -Dave On Tue, Aug 4, 2009 at 8:39 AM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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.
Re: How to create patched artifact?
Hi David, If you have all the source code, as you seem to suggest several times in this convoluted post, then why don't you just deploy a new -SNAPSHOT yourself to your local repository? You ARE using a repository manager, right?? http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ -jesse On Tue, Aug 4, 2009 at 10:25 AM, David Hofferdhoff...@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. What's the maven way of doing this sort of thing? -Dave -- There are 10 types of people in this world, those that can read binary and those that can not. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
Hum, Adding overWriteIfNewerfalse/overWriteIfNewer does not help either. The behavior I am seeing is that it always overwrites. -Dave On Tue, Aug 4, 2009 at 12:49 PM, David Hoffer dhoff...@gmail.com wrote: I think our emails collided. Just to be clear, here is my new configuration. It does not work because it overwrites what the compiler did. executions execution idunpack/id phaseprocess-classes/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritefalse/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasesfalse/overWriteReleases overWriteSnapshotsfalse/overWriteSnapshots /configuration /execution /executions -Dave On Tue, Aug 4, 2009 at 12:46 PM, Tim O'Brien tobr...@discursive.comwrote: On Tue, Aug 4, 2009 at 1:25 PM, David Hofferdhoff...@gmail.com wrote: Yeah, I meant install phase. My pom's packaging is jar, and I have the source in src/main/java. It seems to find the source because for new files I do find the compiled classes in the right places. However what I also find is that for classes in the dependent jar they seem to have overwrote the compiled ones. I think what is happening is that during the compile phase it simply skips the compile (or at least the writing of the class file to disk) if it already exists. How can I configure the compile to always overwrite? Move the copy goal that you declared to happen just after compilation. Look at the lifecycle list, I think you want process-classes -Dave On Tue, Aug 4, 2009 at 12:10 PM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 1:01 PM, David Hofferdhoff...@gmail.com wrote: Hum, I'm getting close but not quite there yet. Here is my configuration. plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-dependency-plugin/artifactId executions execution idunpack/id phasegenerate-sources/phase goals goalunpack/goal /goals configuration artifactItems artifactItem groupIdwt/groupId artifactIdwt/artifactId version4.0-SNAPSHOT/version typejar/type overWritetrue/overWrite outputDirectory${project.build.directory}/classes/outputDirectory /artifactItem /artifactItems overWriteReleasestrue/overWriteReleases overWriteSnapshotstrue/overWriteSnapshots /configuration /execution /executions /plugin For some reason after running the install goal the unpack seems to have taken precedence over the compile! install isn't a goal in this case, it is a phase. When you run install, you are asking Maven to walk through the entire lifecycle (except the deploy phase). Instead of trying to test with the install phase, run mvn generate-sources then run mvn compile. Also use the -X flag to get more output. Take a look at the list of phases here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html Since the generate-sources phase is before compile shouldn't the compile have over written the unpack? I'm confused. Do you have source in src/main/java? What is your project's packaging? -Dave On Tue, Aug 4, 2009 at 8:39 AM, Tim O'Brien tobr...@discursive.com wrote: On Tue, Aug 4, 2009 at 9:25 AM, David Hofferdhoff...@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.
Re: How to create patched artifact?
Perhaps I'm not clear what you are suggesting. I'm not trying to do a release, I'm trying to use a snapshot (that a different division at our company produces). However I need to make a few overrides to this snapshot. yes we do have a process to move our overrides into the snapshot...but that process takes some time. In the meantime I have to build with the snapshot as it exists. So what I am trying to do is simply unpack the snapshot, compile/replace classes with my overrides, and re-jar. I have chosen to rename the jar so there is no risk of confusing which jar is patched. yes we use a repository manager, all builds get deployed to it. -Dave On Tue, Aug 4, 2009 at 1:01 PM, jie...@gmail.com wrote: Hi David, If you have all the source code, as you seem to suggest several times in this convoluted post, then why don't you just deploy a new -SNAPSHOT yourself to your local repository? You ARE using a repository manager, right?? http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ -jesse On Tue, Aug 4, 2009 at 10:25 AM, David Hofferdhoff...@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. What's the maven way of doing this sort of thing? -Dave -- There are 10 types of people in this world, those that can read binary and those that can not. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
Use the excludes config property to exclude the specific files you don't want to overwrite. http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html The docs on that mojo leave much to be desired. On Tue, Aug 4, 2009 at 2:10 PM, David Hofferdhoff...@gmail.com wrote: Perhaps I'm not clear what you are suggesting. I'm not trying to do a release, I'm trying to use a snapshot (that a different division at our company produces). However I need to make a few overrides to this snapshot. yes we do have a process to move our overrides into the snapshot...but that process takes some time. In the meantime I have to build with the snapshot as it exists. So what I am trying to do is simply unpack the snapshot, compile/replace classes with my overrides, and re-jar. I have chosen to rename the jar so there is no risk of confusing which jar is patched. yes we use a repository manager, all builds get deployed to it. -Dave On Tue, Aug 4, 2009 at 1:01 PM, jie...@gmail.com wrote: Hi David, If you have all the source code, as you seem to suggest several times in this convoluted post, then why don't you just deploy a new -SNAPSHOT yourself to your local repository? You ARE using a repository manager, right?? http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ -jesse On Tue, Aug 4, 2009 at 10:25 AM, David Hofferdhoff...@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. What's the maven way of doing this sort of thing? -Dave -- There are 10 types of people in this world, those that can read binary and those that can not. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
On Tue, Aug 4, 2009 at 3:30 PM, Tim O'Brientobr...@discursive.com wrote: Use the excludes config property to exclude the specific files you don't want to overwrite. http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html The docs on that mojo leave much to be desired. Oh come on, the dependency plugin is very well documented. It's just got a lot of options so it's non-trivial. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
Late to the thread here, but why are you unpacking this patched jar? Why not just deploy it to your repo manager and update your poms to depend on it? On Tue, Aug 4, 2009 at 3:10 PM, David Hofferdhoff...@gmail.com wrote: Perhaps I'm not clear what you are suggesting. I'm not trying to do a release, I'm trying to use a snapshot (that a different division at our company produces). However I need to make a few overrides to this snapshot. yes we do have a process to move our overrides into the snapshot...but that process takes some time. In the meantime I have to build with the snapshot as it exists. So what I am trying to do is simply unpack the snapshot, compile/replace classes with my overrides, and re-jar. I have chosen to rename the jar so there is no risk of confusing which jar is patched. yes we use a repository manager, all builds get deployed to it. -Dave On Tue, Aug 4, 2009 at 1:01 PM, jie...@gmail.com wrote: Hi David, If you have all the source code, as you seem to suggest several times in this convoluted post, then why don't you just deploy a new -SNAPSHOT yourself to your local repository? You ARE using a repository manager, right?? http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ -jesse On Tue, Aug 4, 2009 at 10:25 AM, David Hofferdhoff...@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. What's the maven way of doing this sort of thing? -Dave -- There are 10 types of people in this world, those that can read binary and those that can not. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
FWIW, the dependency plugin is looking at a marker file stored in /target/dependencies to determine if a jar needs to be unpacked again. It compares the timestamp of the jar with the timestamp of the marker to determine newness. Once it decides to unpack a jar, it unpacks _all_ files in there, not just newer ones. On Tue, Aug 4, 2009 at 4:22 PM, Brian Foxbri...@infinity.nu wrote: Late to the thread here, but why are you unpacking this patched jar? Why not just deploy it to your repo manager and update your poms to depend on it? On Tue, Aug 4, 2009 at 3:10 PM, David Hofferdhoff...@gmail.com wrote: Perhaps I'm not clear what you are suggesting. I'm not trying to do a release, I'm trying to use a snapshot (that a different division at our company produces). However I need to make a few overrides to this snapshot. yes we do have a process to move our overrides into the snapshot...but that process takes some time. In the meantime I have to build with the snapshot as it exists. So what I am trying to do is simply unpack the snapshot, compile/replace classes with my overrides, and re-jar. I have chosen to rename the jar so there is no risk of confusing which jar is patched. yes we use a repository manager, all builds get deployed to it. -Dave On Tue, Aug 4, 2009 at 1:01 PM, jie...@gmail.com wrote: Hi David, If you have all the source code, as you seem to suggest several times in this convoluted post, then why don't you just deploy a new -SNAPSHOT yourself to your local repository? You ARE using a repository manager, right?? http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ -jesse On Tue, Aug 4, 2009 at 10:25 AM, David Hofferdhoff...@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. What's the maven way of doing this sort of thing? -Dave -- There are 10 types of people in this world, those that can read binary and those that can not. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
I love it how you are so close to the code, you think that this is sufficient documentation for a plugin goal configuration property on unpack: Property: overWriteIfNewer Documentation: Overwrite if newer :-) Like I said, that leave a lot to be desired. On Tue, Aug 4, 2009 at 3:19 PM, Brian Foxbri...@infinity.nu wrote: On Tue, Aug 4, 2009 at 3:30 PM, Tim O'Brientobr...@discursive.com wrote: Use the excludes config property to exclude the specific files you don't want to overwrite. http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html The docs on that mojo leave much to be desired. Oh come on, the dependency plugin is very well documented. It's just got a lot of options so it's non-trivial. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
That stuff is generated from the javadoc annotations. Take a look at the usage page: http://maven.apache.org/plugins/maven-dependency-plugin/usage.html#Overwrite%20Rules Overwrite Rules Artifacts are copied or unpacked using the following rules: * If the artifact doesn't exist in the destination, then copy/unpack it. Otherwise: * For copy/unpack mojo only: if artifactItem / overWrite or overWrite is true, then it will force an overwrite. * Releases check the overWriteReleases value (default = false). If true, then it will force an overwrite. * Snapshots check the overWriteSnapshots value (default = false). If true, then it will force an overwrite. * If none of the above is set to true, then it defaults to the overWriteIfNewer value (default = true). This value, if true, causes the plugin to only copy if the source is newer than the destination (or it doesn't exist in the destination). (for unpack, this checks the existence of the marker file, created in the markersDirectory path. To avoid unexpected behavior after mvn clean, this path should normally be contained within the /target hierarchy.) Examples: * Using the default settings (overWriteReleases = false, overWriteSnapshots = false, overWriteIfNewer = true), then a release or snapshot artifact will only over write the destination if the source is newer than the destination (or marker file if unpacking). * If overWriteReleases = true, then a release artifact (ie foo-1.0.jar) will always overwrite. * If overWriteSnapshots = true, then a snapshot artifact (ie foo-1.0-SNAPSHOT.jar) will always overwrite. * If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or markersDirectory if unpacking). So I again assert that for a plugin the documentation is good. On Tue, Aug 4, 2009 at 4:28 PM, Tim O'Brientobr...@discursive.com wrote: I love it how you are so close to the code, you think that this is sufficient documentation for a plugin goal configuration property on unpack: Property: overWriteIfNewer Documentation: Overwrite if newer :-) Like I said, that leave a lot to be desired. On Tue, Aug 4, 2009 at 3:19 PM, Brian Foxbri...@infinity.nu wrote: On Tue, Aug 4, 2009 at 3:30 PM, Tim O'Brientobr...@discursive.com wrote: Use the excludes config property to exclude the specific files you don't want to overwrite. http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html The docs on that mojo leave much to be desired. Oh come on, the dependency plugin is very well documented. It's just got a lot of options so it's non-trivial. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
On Tue, Aug 4, 2009 at 3:37 PM, Brian Foxbri...@infinity.nu wrote: That stuff is generated from the javadoc annotations. Take a look at the usage page: http://maven.apache.org/plugins/maven-dependency-plugin/usage.html#Overwrite%20Rules Overwrite Rules Artifacts are copied or unpacked using the following rules: * If the artifact doesn't exist in the destination, then copy/unpack it. Otherwise: * For copy/unpack mojo only: if artifactItem / overWrite or overWrite is true, then it will force an overwrite. * Releases check the overWriteReleases value (default = false). If true, then it will force an overwrite. * Snapshots check the overWriteSnapshots value (default = false). If true, then it will force an overwrite. * If none of the above is set to true, then it defaults to the overWriteIfNewer value (default = true). This value, if true, causes the plugin to only copy if the source is newer than the destination (or it doesn't exist in the destination). (for unpack, this checks the existence of the marker file, created in the markersDirectory path. To avoid unexpected behavior after mvn clean, this path should normally be contained within the /target hierarchy.) Examples: * Using the default settings (overWriteReleases = false, overWriteSnapshots = false, overWriteIfNewer = true), then a release or snapshot artifact will only over write the destination if the source is newer than the destination (or marker file if unpacking). * If overWriteReleases = true, then a release artifact (ie foo-1.0.jar) will always overwrite. * If overWriteSnapshots = true, then a snapshot artifact (ie foo-1.0-SNAPSHOT.jar) will always overwrite. * If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or markersDirectory if unpacking). So I again assert that for a plugin the documentation is good. Bleh, I still think it's awful, it reads like it was written by a cyborg. :-) If I'm going to unpack something, I'm going to expect that overwrite would allow me to control whether or not the process of unpacking was going to be destructive to existing files or not. That's the conundrum here, I see not other way than excludes to do this overlay without replacing files that already exist. The alternative would be to set staleMillis on the compiler plugin to a value that would always force a compile, but StaleSourceScanner doesn't support anything like staleMillis = -1. On Tue, Aug 4, 2009 at 4:28 PM, Tim O'Brientobr...@discursive.com wrote: I love it how you are so close to the code, you think that this is sufficient documentation for a plugin goal configuration property on unpack: Property: overWriteIfNewer Documentation: Overwrite if newer :-) Like I said, that leave a lot to be desired. On Tue, Aug 4, 2009 at 3:19 PM, Brian Foxbri...@infinity.nu wrote: On Tue, Aug 4, 2009 at 3:30 PM, Tim O'Brientobr...@discursive.com wrote: Use the excludes config property to exclude the specific files you don't want to overwrite. http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html The docs on that mojo leave much to be desired. Oh come on, the dependency plugin is very well documented. It's just got a lot of options so it's non-trivial. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
Bleh, I still think it's awful, it reads like it was written by a cyborg. :-) If I'm going to unpack something, I'm going to expect that overwrite would allow me to control whether or not the process of unpacking was going to be destructive to existing files or not. That's the conundrum here, I see not other way than excludes to do this overlay without replacing files that already exist. Possibly, but this use case simply wasn't included originally but if someone writes a patch, i will apply it right away. In fact when I originally wrote unpack it was to get war overlay support and in this case i definately wanted to overwrite everything from the war that was contained in what I unpacked. The war plugin was looking at each file and it actually broke my use case. To each their own ;-) The alternative would be to set staleMillis on the compiler plugin to a value that would always force a compile, but StaleSourceScanner doesn't support anything like staleMillis = -1. On Tue, Aug 4, 2009 at 4:28 PM, Tim O'Brientobr...@discursive.com wrote: I love it how you are so close to the code, you think that this is sufficient documentation for a plugin goal configuration property on unpack: Property: overWriteIfNewer Documentation: Overwrite if newer :-) Like I said, that leave a lot to be desired. On Tue, Aug 4, 2009 at 3:19 PM, Brian Foxbri...@infinity.nu wrote: On Tue, Aug 4, 2009 at 3:30 PM, Tim O'Brientobr...@discursive.com wrote: Use the excludes config property to exclude the specific files you don't want to overwrite. http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html The docs on that mojo leave much to be desired. Oh come on, the dependency plugin is very well documented. It's just got a lot of options so it's non-trivial. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to create patched artifact?
I'm not unpacking a patched jar, rather I'm unpacking the original jar...trying to create a patched jar if I could only get the unpack to work correctly. :) -Dave On Tue, Aug 4, 2009 at 2:22 PM, Brian Fox bri...@infinity.nu wrote: Late to the thread here, but why are you unpacking this patched jar? Why not just deploy it to your repo manager and update your poms to depend on it? On Tue, Aug 4, 2009 at 3:10 PM, David Hofferdhoff...@gmail.com wrote: Perhaps I'm not clear what you are suggesting. I'm not trying to do a release, I'm trying to use a snapshot (that a different division at our company produces). However I need to make a few overrides to this snapshot. yes we do have a process to move our overrides into the snapshot...but that process takes some time. In the meantime I have to build with the snapshot as it exists. So what I am trying to do is simply unpack the snapshot, compile/replace classes with my overrides, and re-jar. I have chosen to rename the jar so there is no risk of confusing which jar is patched. yes we use a repository manager, all builds get deployed to it. -Dave On Tue, Aug 4, 2009 at 1:01 PM, jie...@gmail.com wrote: Hi David, If you have all the source code, as you seem to suggest several times in this convoluted post, then why don't you just deploy a new -SNAPSHOT yourself to your local repository? You ARE using a repository manager, right?? http://www.sonatype.com/people/2009/01/best-practices-for-releasing-with-3rd-party-snapshot-dependencies/ -jesse On Tue, Aug 4, 2009 at 10:25 AM, David Hofferdhoff...@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. What's the maven way of doing this sort of thing? -Dave -- There are 10 types of people in this world, those that can read binary and those that can not. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org