maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Sand" <rs...@idfconnect.com>
Subject how to properly propagate plugin results into subsequent phases
Date Sat, 13 Jul 2013 15:35:33 GMT
Hi all,

I'm having trouble getting the output jar from this obfuscation plug-in I'm
writing to be processed properly by subsequent plugins (e.g.
maven-war-plugin and maven-install-plugin). Can someone with more savvy with
the Maven 3.0 API give some advice on where I'm going wrong?

The obfuscator takes the class files from ${project.build.outputDirectory}
(e.g. ./target/classes), plus optionally some other jars from the project
dependencies, and creates an obfuscated jar file such as
${project.build.directory}/${project.build.finalName}-obfuscated.jar.

What I want to do is add this new jar, e.g.
"myproject-1.0.0-obfuscated.jar", into subsequent phases such as
maven-war-plugin (to be included in the output artifact's WEB-INF/lib
folder) while excluding the input (e.g. ignore the ./target/classes and the
dependent jars which were included in the obfuscation).

To add the obfuscated jar into subsequent phases, I tried to include it by
using "mavenProjectHelper.attachArtifact" - but this gave me a very strange
behavior - when the install-plugin executed, it took the war file created by
maven-war-plugin and installed that over top of my last dependent jar! In
other words, it took myapp-1.0.0.war and myapp-1.0.0.pom and put them into
the repository as somedependency.jar and somedependency.pom. Very strange -
and although I'm sure I'm doing something wrong, that outcome feels like a
bug to me anyway. At least something that isn't idiot-proof! But this is
where I am least confident in my approach - can someone advise if I'm doing
this with the wrong technique?

To prevent the dependent jars which were obfuscated from being included in
subsequent phases, I'm finding each dependency from the project artifact
map, and then doing artifact.setScope(Artifact.SCOPE_PROVIDED) and
mavenProject.setArtifact(artifact) to put it back into the project. Any
comment on this technique?

Lastly, I'm not sure how to exclude the "primary" output from the compile
phase - e.g. if I compile ./target/classes, or if my plugin is running after
the packaging phase and I've got ./target/myproject-1.0.0.jar, how do I
exclude these after I successfully include
./target/myproject-1.0.0-obfuscated.jar?

Appreciate any help here. Thanks!

Richard Sand | CEO
IDF Connect, Inc. 
2207 Concord Ave, #359
Wilmington | Delaware 19803 | USA 
Office: +1 302 425 0516 | Fax: +1 856 866 1899
Mobile: +1 267 984 3651




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


Mime
View raw message