maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell Gold <r...@gold-family.us>
Subject Re: how to properly propagate plugin results into subsequent phases
Date Mon, 22 Jul 2013 11:23:51 GMT
Hi Richard,

I would probably use a multi-module project, here, with the war module depending on the others
it needs to include.

- Russ

On Jul 22, 2013, at 1:55 AM, Richard Sand <rsand@idfconnect.com> wrote:

> Hoping someone in the know will work with me to get this answered. Its an
> important use case for how plugins affect the project and further downstream
> activity. Please reach out to me if you can spare 30 minutes to chat with me
> about this subject. Thanks!
> 
> -----Original Message-----
> From: Richard Sand [mailto:rsand@idfconnect.com] 
> Sent: Thursday, July 18, 2013 2:02 AM
> To: 'Maven Users List'
> Subject: RE: how to properly propagate plugin results into subsequent phases
> 
> Hi all,
> 
> Can someone please help me with the proper technique when manipulating the
> dependent artifacts within a custom plugin.
> 
> To put it simply, my plug-in may take in multiple source, say
> /target/classes plus for example 3 dependent compile-time artifacts. It'll
> take these in - classes, plus 3 dependent libraries, and run them through
> the processor. It'll save the results as a jar file called
> ${projectname}-small.jar
> 
> Sometimes, we're now done. But more often than not, there are more stages to
> be processed. For example, maven-war-plugin needs to make a war package with
> the input artifacts. So, what I want to do is include the obfuscated jar as
> a library in the WEB-INF/lib of the war, but I want to skip the classes and
> other 3 dependent artifacts that went into the optimizer. What is the best
> way to do this, in keeping with maven architecture?
> 
> Appreciate any help!
> 
> -Richard
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Richard Sand [mailto:rsand@idfconnect.com]
> Sent: Saturday, July 13, 2013 11:36 AM
> To: 'Maven Users List'
> Subject: how to properly propagate plugin results into subsequent phases
> 
> 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
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

-----------------
Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
and listen to the Misfile radio play <http://www.gold-family.us/audio/misfile.html>!





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message