You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Richard Sand <rs...@idfconnect.com> on 2013/08/20 00:19:04 UTC

artifact attached by plugin not appearing in subsequent plugins

Hi all - I've been stuck for a while trying to get an artifact injected by a
plugin to apply to subsequent plugins/goals in a project.

I have a project which generates a web application. My use case here is the
obfuscator plugin which I wrote, which creates a jar file called
"<projectname>-small.jar". The plugin creates jar file using
MavenProjectHelper.attachArtifact(). The plugin executes during the
packaging phase, before the maven-war-plugin. The jar file is created
successfully, and the call to attachArtifact() returns with no errors, but
the maven-war-plugin does not "see" the jar file and therefore doesn't
include it in the results. When I turn on debugging I can see
maven-war-plugin copying the other project artifacts into
target/<projectname>/WEB-INF/lib.

Have I missed a step? I know I can explicitly configure maven-war-plugin to
grab the new artifact, but I thought the point of "attachArtifact" was to
inject the new artifact into the flow. 

Appreciate any insight into what I'm doing wrong...

Thanks!

-Richard




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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Thank you Mirko, I got a similar reply on Jira. I'll do as you suggested.

Best regards,

Richard


-----Original Message-----
From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com] 
Sent: Tuesday, August 20, 2013 6:20 AM
To: Maven Users List
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Richard,

AFAIK attachArtifact just tells Maven to install an additional binary to it's local cache resp. to deploy it to the distribution repository.

What you want, as far as I understand, is to create an artifact which will be picked up later on and included in a war? You should probably create a separate module project, which creates the jar and just include this jar as runtime dependency in your war project.

Regards Mirko
--
Sent from my mobile
On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:

> I concluded that this was a missing feature of maven-war-plugin, where 
> it simply wasn't looking to see if there were attached resources.
>
> I supplied a simple patch to the handleArtifacts() method to have that 
> method also handle attached artifacts,  You can see the report here.
> https://jira.codehaus.org/browse/MWAR-304
>
> -Richard
>
> -----Original Message-----
> From: Richard Sand [mailto:rsand@idfconnect.com]
> Sent: Monday, August 19, 2013 6:19 PM
> To: 'Maven Users List'
> Subject: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Hi all - I've been stuck for a while trying to get an artifact 
> injected by a plugin to apply to subsequent plugins/goals in a 
> project.
>
> I have a project which generates a web application. My use case here 
> is the obfuscator plugin which I wrote, which creates a jar file 
> called "<projectname>-small.jar". The plugin creates jar file using 
> MavenProjectHelper.attachArtifact(). The plugin executes during the 
> packaging phase, before the maven-war-plugin. The jar file is created 
> successfully, and the call to attachArtifact() returns with no errors, 
> but the maven-war-plugin does not "see" the jar file and therefore 
> doesn't include it in the results. When I turn on debugging I can see 
> maven-war-plugin copying the other project artifacts into 
> target/<projectname>/WEB-INF/lib.
>
> Have I missed a step? I know I can explicitly configure 
> maven-war-plugin to grab the new artifact, but I thought the point of 
> "attachArtifact" was to inject the new artifact into the flow.
>
> Appreciate any insight into what I'm doing wrong...
>
> 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
>
>



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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Sorry just correcting myself, I was referring to the maven shade plugin not mojo shade plugin.

-Richard

-----Original Message-----
From: Richard Sand [mailto:rsand@idfconnect.com] 
Sent: Monday, August 26, 2013 4:54 PM
To: 'Maven Users List'; 'Maven Developers List'
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Hi all,

Mirko thanks for your reply. I think the plugin API should have *some* simple mechanism for transferring a "generated" artifact from one plugin to the next.

In my example, the project creates a standard named artifact i.e. "${project.build.finalName}.war", and the obfuscation plugin also a new (generated) jar artifact with classifier "small", i.e. ${project.build.finalName}-small.jar, specifically with the classes it has processed.

To get the war file to include this new generated artifact, I have to place it directly into the WEB-INF/lib folder, whereas by default it would go into ${project.build.directory}. Obviously this isn't burdensome. But my question was whether it would make sense to have the war plugin consider attached artifacts. I actually created issue MWAR-304 with a simple patch to do this, but the developer agreed with your point that attaching an artifact should only be used for placing said artifact into a repository, not as a mechanism for propagating the artifact to other plugins (https://jira.codehaus.org/browse/MWAR-304).

However this general use case (propagating a generated artifact between plugins) continues to vex me. Example - I tried using the mojo shade plugin to generate a jar to include in a web application.  Same type of use case - I want the shade plugin to use the artifact generated by a previous plugin. The shade plugin only accepts an artifact as an input, I cannot give it a path to a filename to include as I did above with the war plugin. So either way I need to modify the shade plugin - either to accept filesystem paths to include or a Boolean to tell it to check for dynamically attached plugins. Since Maven 3.0 includes MavenProject.getAttachedArtifacts(), it seems silly not to use it. If a plugin is going to accept artifacts as input, why shouldn't an attached artifact be considered? It seems like the natural and transparent mechanism to propagate generated, attached artifacts between plugins. Just choose your classifier and go. 

Granted, the shade plugin should also have a parameter to include filesystem paths.

Best regards,

Richard

-----Original Message-----
From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
Sent: Tuesday, August 20, 2013 11:40 AM
To: Maven Users List; Maven Developers List
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Hello Richard,

x-posted to dev, as the war-plugin is a core-plugin:
- IMO attaching would be the "wrong" term as it has another meaning.
- This is more of a "generated" jar (as generated sources,  classes etc.)
- IMO packages should go in Maven modules of their own.

Regards Mirko
--
Sent from my mobile
On Aug 20, 2013 5:13 PM, "Richard Sand" <rs...@idfconnect.com> wrote:

> Is there any merit to the idea of having a configuration option in 
> maven-war-plugin to include attached artifacts in the webapp in the 
> same way it includes dependent artifacts?
>
> -Richard
>
> -----Original Message-----
> From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
> Sent: Tuesday, August 20, 2013 6:20 AM
> To: Maven Users List
> Subject: RE: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Richard,
>
> AFAIK attachArtifact just tells Maven to install an additional binary 
> to it's local cache resp. to deploy it to the distribution repository.
>
> What you want, as far as I understand, is to create an artifact which 
> will be picked up later on and included in a war? You should probably 
> create a separate module project, which creates the jar and just 
> include this jar as runtime dependency in your war project.
>
> Regards Mirko
> --
> Sent from my mobile
> On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:
>
> > I concluded that this was a missing feature of maven-war-plugin, 
> > where it simply wasn't looking to see if there were attached resources.
> >
> > I supplied a simple patch to the handleArtifacts() method to have 
> > that method also handle attached artifacts,  You can see the report here.
> > https://jira.codehaus.org/browse/MWAR-304
> >
> > -Richard
> >
> > -----Original Message-----
> > From: Richard Sand [mailto:rsand@idfconnect.com]
> > Sent: Monday, August 19, 2013 6:19 PM
> > To: 'Maven Users List'
> > Subject: artifact attached by plugin not appearing in subsequent 
> > plugins
> >
> > Hi all - I've been stuck for a while trying to get an artifact 
> > injected by a plugin to apply to subsequent plugins/goals in a 
> > project.
> >
> > I have a project which generates a web application. My use case here 
> > is the obfuscator plugin which I wrote, which creates a jar file 
> > called "<projectname>-small.jar". The plugin creates jar file using 
> > MavenProjectHelper.attachArtifact(). The plugin executes during the 
> > packaging phase, before the maven-war-plugin. The jar file is 
> > created successfully, and the call to attachArtifact() returns with 
> > no errors, but the maven-war-plugin does not "see" the jar file and 
> > therefore doesn't include it in the results. When I turn on 
> > debugging I can see maven-war-plugin copying the other project 
> > artifacts into target/<projectname>/WEB-INF/lib.
> >
> > Have I missed a step? I know I can explicitly configure 
> > maven-war-plugin to grab the new artifact, but I thought the point 
> > of "attachArtifact" was to inject the new artifact into the flow.
> >
> > Appreciate any insight into what I'm doing wrong...
> >
> > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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




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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Notice that the maven-assembly-plugin behaves exactly as I'd hoped - it has
a Boolean "useProjectAttachments" for dependencySets and
"attachmentClassifier" to look for an attached alternative to the main
project artifact. Those are exactly the two features I added to
maven-shade-plugin and maven-war-plugin. 

-----Original Message-----
From: Richard Sand [mailto:rsand@idfconnect.com] 
Sent: Wednesday, August 28, 2013 5:05 PM
To: 'Maven Developers List'
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

I always appreciate a good starwars reference. Actually there are 12 maven
modules overall in this particular project, so I don't think I fear multiple
modules. Could we have split the actual Jersey application classes into a
separate project outside of the war project - yes, agreed. 

What I do object to is creating another module with no purpose other except
to hold a single build plugin. That way leads to the dreaded Maven Tribbles,
and nobody wants to see that...!

I'm just not following where this aversion to using multiple plugins
together is coming from. I really just don't get it. Can you address that?
I'll concede to you that I can allow the poms to be prosper - but I'd like
to approach the conversation from the angle of "why *wouldn't* we want the
output artifact of one plugin to be the input artifact to another"? So all
kidding aside, if this is contrary to the Tao of Maven I'd really appreciate
understanding why. Thanks!

-Richard

-----Original Message-----
From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com]
Sent: Wednesday, August 28, 2013 4:20 PM
To: Maven Developers List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

But you shouldn't be having java code in module 3 (as it is a war module) so
that should be split in two to follow best practice... It sounds like you
have multiple-module-phobia... That way is the way of fear. Fear leads to
anger... Anger leads to the dark side. Embrace the many modules on the light
side of the maven-force

On Wednesday, 28 August 2013, Richard Sand wrote:

> I thought about it, but its very complicated to obfuscate in stages 
> because some of the classes to be obfuscated in projects 3 and 4 rely 
> on the obfuscated entrypoints in project 2.
>
> Basically obfuscation has to be the last thing done before final 
> testing and assembly.
>
> -----Original Message-----
> From: Stephen Connolly
> [mailto:stephen.alan.connolly@gmail.com<javascript:;>
> ]
> Sent: Wednesday, August 28, 2013 3:12 PM
> To: Maven Developers List
> Subject: Re: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Sounds like you should be obfuscating *in* module 2 and then adding 
> the dependency with classifier to module 3 and 4 (or do two 
> obfuscations in module 2 if you need different flavours)
>
> On Wednesday, 28 August 2013, Richard Sand wrote:
>
> > Hi all,
> >
> > Wayne, thanks for the feedback. I understand where you're coming from.
> > I've written out here a concrete example of what I want to do with 
> > these plugins, and with maven in general wrt passing generated 
> > artifacts between plugins. Hopefully others will weigh in on whether 
> > this approach is good and maven-esque.
> >
> > I have 4 maven projects:
> >
> > 1) a global parent pom
> > 2) a common API project which creates a jar
> > 3) a web application project (a Jersey JAX-RS service fwiw) which 
> > creates a war and depends on #2
> > 4) a java client for #3 (based on JerseyClient), which also depends 
> > on
> > #2
> >
> > 1st example: In project 3, I use my obfuscation plugin on the common 
> > API and the generated classes. That resulting jar file needs to go 
> > into the WEB-INF/lib folder of the war file. My proposed change to 
> > the maven war plugin would make it automatically look for a 
> > generated jar artifact attached to the project from a previous 
> > plug-in and package it appropriately. The current alternative, which 
> > admittedly is no big deal, is to simply have the output artifact 
> > created by my plugin go directly into WEB-INF/lib. But adding a 
> > boolean config variable to maven-war-plugin to tell it to look for 
> > attached jars and include them seems logical as well as trivial to 
> > me, but this could just be because of my relative newness to all 
> > things Maven
> >
> > 2nd example: in project 4, I again use my obfuscation plugin on the 
> > common API and generated classes, and then want to take that 
> > artifact and, along with the rest of the dependencies, use the 
> > maven-shade-plugin to build an "uberjar". More problematic than 
> > example 1 above because the shade plugin only looks at artifacts and 
> > has no hook to include anything directly from the filesystem. So 
> > what I did was modify the shade 2.1 source to include a new 
> > configuration
> parameter. For simplicy's sake I simply called it "
> > alternativeInputClassifier". When present, it instructs shade to 
> > look for an attached artifact with the artifact name of the project, 
> > of type jar, and with the specified classifier, in lieu of 
> > processing only the main project as input. It was a very minor 
> > change and I'm happy to provide the diff for it. The result is that 
> > my pom.xml for project 4 looks like below and works beautifully. One 
> > pom with two
> profiles:
> >
> >         <dependencies>
> >                 ....
> >                 <dependency>
> >                         <groupId>com.idfconnect.myproject</groupId>
> >                         <artifactId>common-tools</artifactId>
> >                 </dependency>
> >         </dependencies>
> >         <profiles>
> >                 <profile>
> >                         <!-- REGULAR (unobfuscated) PROFILE -->
> >                         <id>regular</id>
> >                         <activation>
> >                                 <activeByDefault>true</activeByDefault>
> >                         </activation>
> >                         <build>
> >                                 <plugins>
> >                                         <!-- BEGIN SHADE -->
> >                                         <plugin>
> >
> > From: Wayne Fay [mailto:waynefay@gmail.com 
> > <javascript:;><javascript:;>]
> > Sent: Tuesday, August 27, 2013 5:04 PM
> > To: Maven Users List
> > Subject: Re: artifact attached by plugin not appearing in subsequent 
> > plugins
> >
> > > Hi Wayne - that seems a very inefficient approach, having 5 or 6 
> > > separate modules to manage to achieve a single assembly. The point 
> > > is that maven does have phases, goals, lifecycles - why not use 
> > > them? The MavenProject object already provides the
> >
> > Not saying this is ideal for all scenarios. Just saying it is one 
> > solution that works out of the box and it leaves the door open for 
> > customization you may need along the way. People here oftentimes say 
> > they
> "just want to do X"
> > and so we provide some advice. Then they come back a week later and 
> > say well actually they need variants of X for different clients, 
> > environments, architectures, etc so they share how they've been 
> > going down the path of profiles which most of us here believe is the 
> > wrong way to do things. I'm just trying to ensure you know TMTOWTDI 
> > (perl-ism). :)
> >
> > > ...I think dividing the construction of a single atomic component 
> > > into multiple modules because the plugins cannot be chained 
> > > together is more
> > unappealing.
> >
> > I don't disagree. As I said, this is based on my assumption (perhaps
> > wrong) that you have left a great many details out of your original 
> > query, and the next few emails will describe a monstrous beast you 
> > have created with profiles and binding plugins to various lifecycles 
> > etc in an effort to do "all the work" in a single project/module.
> > ;-)
> >
> > > BTW I haven't touched Ant in at least 6 years, so I doubt I'm an 
> > > "Ant-oriented person".  :-)
> >
> > Didn't mean you were necessarily Ant-oriented. I know you've 
> > released some Maven plugins lately. Thanks for your work in the 
> > Maven ecosystem! :)
> >
> > Wayne
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: 
> > users-unsubscribe@maven.apache.org<javascript:;>
> > <javascript:;> For additional commands, e-mail:
> > users-help@maven.apache.org <javascript:;><javascript:;>
> >
> >
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org 
> > <javascript:;> <javascript:;> For additional commands, e-mail:
> > dev-help@maven.apache.org <javascript:;> <javascript:;>
> >
> >
>
> --
> Sent from my phone
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org 
> <javascript:;> For additional commands, e-mail:
> dev-help@maven.apache.org <javascript:;>
>
>

--
Sent from my phone



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




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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
I always appreciate a good starwars reference. Actually there are 12 maven
modules overall in this particular project, so I don't think I fear multiple
modules. Could we have split the actual Jersey application classes into a
separate project outside of the war project - yes, agreed. 

What I do object to is creating another module with no purpose other except
to hold a single build plugin. That way leads to the dreaded Maven Tribbles,
and nobody wants to see that...!

I'm just not following where this aversion to using multiple plugins
together is coming from. I really just don't get it. Can you address that?
I'll concede to you that I can allow the poms to be prosper - but I'd like
to approach the conversation from the angle of "why *wouldn't* we want the
output artifact of one plugin to be the input artifact to another"? So all
kidding aside, if this is contrary to the Tao of Maven I'd really appreciate
understanding why. Thanks!

-Richard

-----Original Message-----
From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com] 
Sent: Wednesday, August 28, 2013 4:20 PM
To: Maven Developers List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

But you shouldn't be having java code in module 3 (as it is a war module) so
that should be split in two to follow best practice... It sounds like you
have multiple-module-phobia... That way is the way of fear. Fear leads to
anger... Anger leads to the dark side. Embrace the many modules on the light
side of the maven-force

On Wednesday, 28 August 2013, Richard Sand wrote:

> I thought about it, but its very complicated to obfuscate in stages 
> because some of the classes to be obfuscated in projects 3 and 4 rely 
> on the obfuscated entrypoints in project 2.
>
> Basically obfuscation has to be the last thing done before final 
> testing and assembly.
>
> -----Original Message-----
> From: Stephen Connolly 
> [mailto:stephen.alan.connolly@gmail.com<javascript:;>
> ]
> Sent: Wednesday, August 28, 2013 3:12 PM
> To: Maven Developers List
> Subject: Re: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Sounds like you should be obfuscating *in* module 2 and then adding 
> the dependency with classifier to module 3 and 4 (or do two 
> obfuscations in module 2 if you need different flavours)
>
> On Wednesday, 28 August 2013, Richard Sand wrote:
>
> > Hi all,
> >
> > Wayne, thanks for the feedback. I understand where you're coming from.
> > I've written out here a concrete example of what I want to do with 
> > these plugins, and with maven in general wrt passing generated 
> > artifacts between plugins. Hopefully others will weigh in on whether 
> > this approach is good and maven-esque.
> >
> > I have 4 maven projects:
> >
> > 1) a global parent pom
> > 2) a common API project which creates a jar
> > 3) a web application project (a Jersey JAX-RS service fwiw) which 
> > creates a war and depends on #2
> > 4) a java client for #3 (based on JerseyClient), which also depends 
> > on
> > #2
> >
> > 1st example: In project 3, I use my obfuscation plugin on the common 
> > API and the generated classes. That resulting jar file needs to go 
> > into the WEB-INF/lib folder of the war file. My proposed change to 
> > the maven war plugin would make it automatically look for a 
> > generated jar artifact attached to the project from a previous 
> > plug-in and package it appropriately. The current alternative, which 
> > admittedly is no big deal, is to simply have the output artifact 
> > created by my plugin go directly into WEB-INF/lib. But adding a 
> > boolean config variable to maven-war-plugin to tell it to look for 
> > attached jars and include them seems logical as well as trivial to 
> > me, but this could just be because of my relative newness to all 
> > things Maven
> >
> > 2nd example: in project 4, I again use my obfuscation plugin on the 
> > common API and generated classes, and then want to take that 
> > artifact and, along with the rest of the dependencies, use the 
> > maven-shade-plugin to build an "uberjar". More problematic than 
> > example 1 above because the shade plugin only looks at artifacts and 
> > has no hook to include anything directly from the filesystem. So 
> > what I did was modify the shade 2.1 source to include a new 
> > configuration
> parameter. For simplicy's sake I simply called it "
> > alternativeInputClassifier". When present, it instructs shade to 
> > look for an attached artifact with the artifact name of the project, 
> > of type jar, and with the specified classifier, in lieu of 
> > processing only the main project as input. It was a very minor 
> > change and I'm happy to provide the diff for it. The result is that 
> > my pom.xml for project 4 looks like below and works beautifully. One 
> > pom with two
> profiles:
> >
> >         <dependencies>
> >                 ....
> >                 <dependency>
> >                         <groupId>com.idfconnect.myproject</groupId>
> >                         <artifactId>common-tools</artifactId>
> >                 </dependency>
> >         </dependencies>
> >         <profiles>
> >                 <profile>
> >                         <!-- REGULAR (unobfuscated) PROFILE -->
> >                         <id>regular</id>
> >                         <activation>
> >                                 <activeByDefault>true</activeByDefault>
> >                         </activation>
> >                         <build>
> >                                 <plugins>
> >                                         <!-- BEGIN SHADE -->
> >                                         <plugin>
> >
> > From: Wayne Fay [mailto:waynefay@gmail.com 
> > <javascript:;><javascript:;>]
> > Sent: Tuesday, August 27, 2013 5:04 PM
> > To: Maven Users List
> > Subject: Re: artifact attached by plugin not appearing in subsequent 
> > plugins
> >
> > > Hi Wayne - that seems a very inefficient approach, having 5 or 6 
> > > separate modules to manage to achieve a single assembly. The point 
> > > is that maven does have phases, goals, lifecycles - why not use 
> > > them? The MavenProject object already provides the
> >
> > Not saying this is ideal for all scenarios. Just saying it is one 
> > solution that works out of the box and it leaves the door open for 
> > customization you may need along the way. People here oftentimes say 
> > they
> "just want to do X"
> > and so we provide some advice. Then they come back a week later and 
> > say well actually they need variants of X for different clients, 
> > environments, architectures, etc so they share how they've been 
> > going down the path of profiles which most of us here believe is the 
> > wrong way to do things. I'm just trying to ensure you know TMTOWTDI 
> > (perl-ism). :)
> >
> > > ...I think dividing the construction of a single atomic component 
> > > into multiple modules because the plugins cannot be chained 
> > > together is more
> > unappealing.
> >
> > I don't disagree. As I said, this is based on my assumption (perhaps
> > wrong) that you have left a great many details out of your original 
> > query, and the next few emails will describe a monstrous beast you 
> > have created with profiles and binding plugins to various lifecycles 
> > etc in an effort to do "all the work" in a single project/module. 
> > ;-)
> >
> > > BTW I haven't touched Ant in at least 6 years, so I doubt I'm an 
> > > "Ant-oriented person".  :-)
> >
> > Didn't mean you were necessarily Ant-oriented. I know you've 
> > released some Maven plugins lately. Thanks for your work in the 
> > Maven ecosystem! :)
> >
> > Wayne
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: 
> > users-unsubscribe@maven.apache.org<javascript:;>
> > <javascript:;> For additional commands, e-mail:
> > users-help@maven.apache.org <javascript:;><javascript:;>
> >
> >
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org 
> > <javascript:;> <javascript:;> For additional commands, e-mail:
> > dev-help@maven.apache.org <javascript:;> <javascript:;>
> >
> >
>
> --
> Sent from my phone
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org 
> <javascript:;> For additional commands, e-mail: 
> dev-help@maven.apache.org <javascript:;>
>
>

--
Sent from my phone



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


Re: artifact attached by plugin not appearing in subsequent plugins

Posted by Stephen Connolly <st...@gmail.com>.
But you shouldn't be having java code in module 3 (as it is a war module)
so that should be split in two to follow best practice... It sounds like
you have multiple-module-phobia... That way is the way of fear. Fear leads
to anger... Anger leads to the dark side. Embrace the many modules on the
light side of the maven-force

On Wednesday, 28 August 2013, Richard Sand wrote:

> I thought about it, but its very complicated to obfuscate in stages because
> some of the classes to be obfuscated in projects 3 and 4 rely on the
> obfuscated entrypoints in project 2.
>
> Basically obfuscation has to be the last thing done before final testing
> and
> assembly.
>
> -----Original Message-----
> From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com<javascript:;>
> ]
> Sent: Wednesday, August 28, 2013 3:12 PM
> To: Maven Developers List
> Subject: Re: artifact attached by plugin not appearing in subsequent
> plugins
>
> Sounds like you should be obfuscating *in* module 2 and then adding the
> dependency with classifier to module 3 and 4 (or do two obfuscations in
> module 2 if you need different flavours)
>
> On Wednesday, 28 August 2013, Richard Sand wrote:
>
> > Hi all,
> >
> > Wayne, thanks for the feedback. I understand where you're coming from.
> > I've written out here a concrete example of what I want to do with
> > these plugins, and with maven in general wrt passing generated
> > artifacts between plugins. Hopefully others will weigh in on whether
> > this approach is good and maven-esque.
> >
> > I have 4 maven projects:
> >
> > 1) a global parent pom
> > 2) a common API project which creates a jar
> > 3) a web application project (a Jersey JAX-RS service fwiw) which
> > creates a war and depends on #2
> > 4) a java client for #3 (based on JerseyClient), which also depends on
> > #2
> >
> > 1st example: In project 3, I use my obfuscation plugin on the common
> > API and the generated classes. That resulting jar file needs to go
> > into the WEB-INF/lib folder of the war file. My proposed change to the
> > maven war plugin would make it automatically look for a generated jar
> > artifact attached to the project from a previous plug-in and package
> > it appropriately. The current alternative, which admittedly is no big
> > deal, is to simply have the output artifact created by my plugin go
> > directly into WEB-INF/lib. But adding a boolean config variable to
> > maven-war-plugin to tell it to look for attached jars and include them
> > seems logical as well as trivial to me, but this could just be because
> > of my relative newness to all things Maven
> >
> > 2nd example: in project 4, I again use my obfuscation plugin on the
> > common API and generated classes, and then want to take that artifact
> > and, along with the rest of the dependencies, use the
> > maven-shade-plugin to build an "uberjar". More problematic than
> > example 1 above because the shade plugin only looks at artifacts and
> > has no hook to include anything directly from the filesystem. So what
> > I did was modify the shade 2.1 source to include a new configuration
> parameter. For simplicy's sake I simply called it "
> > alternativeInputClassifier". When present, it instructs shade to look
> > for an attached artifact with the artifact name of the project, of
> > type jar, and with the specified classifier, in lieu of processing
> > only the main project as input. It was a very minor change and I'm
> > happy to provide the diff for it. The result is that my pom.xml for
> > project 4 looks like below and works beautifully. One pom with two
> profiles:
> >
> >         <dependencies>
> >                 ....
> >                 <dependency>
> >                         <groupId>com.idfconnect.myproject</groupId>
> >                         <artifactId>common-tools</artifactId>
> >                 </dependency>
> >         </dependencies>
> >         <profiles>
> >                 <profile>
> >                         <!-- REGULAR (unobfuscated) PROFILE -->
> >                         <id>regular</id>
> >                         <activation>
> >                                 <activeByDefault>true</activeByDefault>
> >                         </activation>
> >                         <build>
> >                                 <plugins>
> >                                         <!-- BEGIN SHADE -->
> >                                         <plugin>
> >
> > From: Wayne Fay [mailto:waynefay@gmail.com <javascript:;><javascript:;>]
> > Sent: Tuesday, August 27, 2013 5:04 PM
> > To: Maven Users List
> > Subject: Re: artifact attached by plugin not appearing in subsequent
> > plugins
> >
> > > Hi Wayne - that seems a very inefficient approach, having 5 or 6
> > > separate modules to manage to achieve a single assembly. The point
> > > is that maven does have phases, goals, lifecycles - why not use
> > > them? The MavenProject object already provides the
> >
> > Not saying this is ideal for all scenarios. Just saying it is one
> > solution that works out of the box and it leaves the door open for
> > customization you may need along the way. People here oftentimes say they
> "just want to do X"
> > and so we provide some advice. Then they come back a week later and
> > say well actually they need variants of X for different clients,
> > environments, architectures, etc so they share how they've been going
> > down the path of profiles which most of us here believe is the wrong
> > way to do things. I'm just trying to ensure you know TMTOWTDI
> > (perl-ism). :)
> >
> > > ...I think dividing the construction of a single atomic component
> > > into multiple modules because the plugins cannot be chained together
> > > is more
> > unappealing.
> >
> > I don't disagree. As I said, this is based on my assumption (perhaps
> > wrong) that you have left a great many details out of your original
> > query, and the next few emails will describe a monstrous beast you
> > have created with profiles and binding plugins to various lifecycles
> > etc in an effort to do "all the work" in a single project/module. ;-)
> >
> > > BTW I haven't touched Ant in at least 6 years, so I doubt I'm an
> > > "Ant-oriented person".  :-)
> >
> > Didn't mean you were necessarily Ant-oriented. I know you've released
> > some Maven plugins lately. Thanks for your work in the Maven
> > ecosystem! :)
> >
> > Wayne
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org<javascript:;>
> > <javascript:;> For additional commands, e-mail:
> > users-help@maven.apache.org <javascript:;><javascript:;>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org <javascript:;>
> > <javascript:;> For additional commands, e-mail:
> > dev-help@maven.apache.org <javascript:;> <javascript:;>
> >
> >
>
> --
> Sent from my phone
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: dev-help@maven.apache.org <javascript:;>
>
>

-- 
Sent from my phone

RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
I thought about it, but its very complicated to obfuscate in stages because
some of the classes to be obfuscated in projects 3 and 4 rely on the
obfuscated entrypoints in project 2. 

Basically obfuscation has to be the last thing done before final testing and
assembly.

-----Original Message-----
From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com] 
Sent: Wednesday, August 28, 2013 3:12 PM
To: Maven Developers List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

Sounds like you should be obfuscating *in* module 2 and then adding the
dependency with classifier to module 3 and 4 (or do two obfuscations in
module 2 if you need different flavours)

On Wednesday, 28 August 2013, Richard Sand wrote:

> Hi all,
>
> Wayne, thanks for the feedback. I understand where you're coming from.
> I've written out here a concrete example of what I want to do with 
> these plugins, and with maven in general wrt passing generated 
> artifacts between plugins. Hopefully others will weigh in on whether 
> this approach is good and maven-esque.
>
> I have 4 maven projects:
>
> 1) a global parent pom
> 2) a common API project which creates a jar
> 3) a web application project (a Jersey JAX-RS service fwiw) which 
> creates a war and depends on #2
> 4) a java client for #3 (based on JerseyClient), which also depends on 
> #2
>
> 1st example: In project 3, I use my obfuscation plugin on the common 
> API and the generated classes. That resulting jar file needs to go 
> into the WEB-INF/lib folder of the war file. My proposed change to the 
> maven war plugin would make it automatically look for a generated jar 
> artifact attached to the project from a previous plug-in and package 
> it appropriately. The current alternative, which admittedly is no big 
> deal, is to simply have the output artifact created by my plugin go 
> directly into WEB-INF/lib. But adding a boolean config variable to 
> maven-war-plugin to tell it to look for attached jars and include them 
> seems logical as well as trivial to me, but this could just be because 
> of my relative newness to all things Maven
>
> 2nd example: in project 4, I again use my obfuscation plugin on the 
> common API and generated classes, and then want to take that artifact 
> and, along with the rest of the dependencies, use the 
> maven-shade-plugin to build an "uberjar". More problematic than 
> example 1 above because the shade plugin only looks at artifacts and 
> has no hook to include anything directly from the filesystem. So what 
> I did was modify the shade 2.1 source to include a new configuration
parameter. For simplicy's sake I simply called it "
> alternativeInputClassifier". When present, it instructs shade to look 
> for an attached artifact with the artifact name of the project, of 
> type jar, and with the specified classifier, in lieu of processing 
> only the main project as input. It was a very minor change and I'm 
> happy to provide the diff for it. The result is that my pom.xml for 
> project 4 looks like below and works beautifully. One pom with two
profiles:
>
>         <dependencies>
>                 ....
>                 <dependency>
>                         <groupId>com.idfconnect.myproject</groupId>
>                         <artifactId>common-tools</artifactId>
>                 </dependency>
>         </dependencies>
>         <profiles>
>                 <profile>
>                         <!-- REGULAR (unobfuscated) PROFILE -->
>                         <id>regular</id>
>                         <activation>
>                                 <activeByDefault>true</activeByDefault>
>                         </activation>
>                         <build>
>                                 <plugins>
>                                         <!-- BEGIN SHADE -->
>                                         <plugin>
>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-shade-plugin</artifactId>
>
> <version>2.1-idfc1</version>
>                                                 <executions>
>                                                         <execution>
>
> <phase>package</phase>
>                                                                 
> <goals>
>
> <goal>shade</goal>
>                                                                 
> </goals>
>
> <configuration>
>
> <minimizeJar>true</minimizeJar>
>
> <shadedArtifactAttached>true</shadedArtifactAttached>
>
> <shadedClassifierName>full</shadedClassifierName>
>
> </configuration>
>                                                         </execution>
>                                                 </executions>
>                                         </plugin>
>                                         <!-- END SHADE -->
>                                 </plugins>
>                         </build>
>                 </profile>
>
>                 <!-- OBFUSCATION PROFILE -->
>                 <profile>
>                         <id>obfuscate</id>
>                         <build>
>                                 <plugins>
>                                         <!-- BEGIN OBFUSCATE -->
>                                         <plugin>
>
> <groupId>com.idfconnect.devtools</groupId>
>
> <artifactId>idfc-proguard-maven-plugin</artifactId>
>                                                 <version>1.0.0</version>
>                                                 <executions>
>                                                         <execution>
>
> <phase>package</phase>
>                                                                 
> <goals>
>
> <goal>obfuscate</goal>
>                                                                 </goals>
>                                                         </execution>
>                                                 </executions>
>                                                 <configuration>
>
> <shrink>false</shrink>
>                                                         
> <inputArtifacts>
>
> <inputArtifact>com.idfconnect.myproject:common-tools</inputArtifact>
>                                                         </inputArtifacts>
>                                                         
> <libraryJarPaths>
>
> <libraryJarPath>${java.home}/lib/jsse.jar</libraryJarPath>
>                                                         </libraryJarPaths>
>                                                 </configuration>
>                                                 <dependencies>
>                                                         <dependency>
>
> <groupId>net.sf.proguard</groupId>
>
> <artifactId>proguard-base</artifactId>
>
> <version>4.9</version>
>                                                         </dependency>
>                                                 </dependencies>
>                                         </plugin>
>                                         <!-- END OBFUSCATE -->
>
>                                         <!-- BEGIN SHADE -->
>                                         <plugin>
>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-shade-plugin</artifactId>
>
> <version>2.1-idfc1</version>
>                                                 <executions>
>                                                         <execution>
>
> <phase>package</phase>
>                                                                 
> <goals>
>
> <goal>shade</goal>
>                                                                 
> </goals>
>
> <configuration>
>
> <alternativeInputClassifier>small</alternativeInputClassifier>
>
> <artifactSet>
>
>       <excludes>
>
> -Richard
>
> -----Original Message-----
> From: Wayne Fay [mailto:waynefay@gmail.com <javascript:;>]
> Sent: Tuesday, August 27, 2013 5:04 PM
> To: Maven Users List
> Subject: Re: artifact attached by plugin not appearing in subsequent 
> plugins
>
> > Hi Wayne - that seems a very inefficient approach, having 5 or 6 
> > separate modules to manage to achieve a single assembly. The point 
> > is that maven does have phases, goals, lifecycles - why not use 
> > them? The MavenProject object already provides the
>
> Not saying this is ideal for all scenarios. Just saying it is one 
> solution that works out of the box and it leaves the door open for 
> customization you may need along the way. People here oftentimes say they
"just want to do X"
> and so we provide some advice. Then they come back a week later and 
> say well actually they need variants of X for different clients, 
> environments, architectures, etc so they share how they've been going 
> down the path of profiles which most of us here believe is the wrong 
> way to do things. I'm just trying to ensure you know TMTOWTDI 
> (perl-ism). :)
>
> > ...I think dividing the construction of a single atomic component 
> > into multiple modules because the plugins cannot be chained together 
> > is more
> unappealing.
>
> I don't disagree. As I said, this is based on my assumption (perhaps
> wrong) that you have left a great many details out of your original 
> query, and the next few emails will describe a monstrous beast you 
> have created with profiles and binding plugins to various lifecycles 
> etc in an effort to do "all the work" in a single project/module. ;-)
>
> > BTW I haven't touched Ant in at least 6 years, so I doubt I'm an 
> > "Ant-oriented person".  :-)
>
> Didn't mean you were necessarily Ant-oriented. I know you've released 
> some Maven plugins lately. Thanks for your work in the Maven 
> ecosystem! :)
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org 
> <javascript:;> For additional commands, e-mail: 
> users-help@maven.apache.org<javascript:;>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org 
> <javascript:;> For additional commands, e-mail: 
> dev-help@maven.apache.org <javascript:;>
>
>

--
Sent from my phone



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


Re: artifact attached by plugin not appearing in subsequent plugins

Posted by Stephen Connolly <st...@gmail.com>.
Sounds like you should be obfuscating *in* module 2 and then adding the
dependency with classifier to module 3 and 4 (or do two obfuscations in
module 2 if you need different flavours)

On Wednesday, 28 August 2013, Richard Sand wrote:

> Hi all,
>
> Wayne, thanks for the feedback. I understand where you're coming from.
> I've written out here a concrete example of what I want to do with these
> plugins, and with maven in general wrt passing generated artifacts between
> plugins. Hopefully others will weigh in on whether this approach is good
> and maven-esque.
>
> I have 4 maven projects:
>
> 1) a global parent pom
> 2) a common API project which creates a jar
> 3) a web application project (a Jersey JAX-RS service fwiw) which creates
> a war and depends on #2
> 4) a java client for #3 (based on JerseyClient), which also depends on #2
>
> 1st example: In project 3, I use my obfuscation plugin on the common API
> and the generated classes. That resulting jar file needs to go into the
> WEB-INF/lib folder of the war file. My proposed change to the maven war
> plugin would make it automatically look for a generated jar artifact
> attached to the project from a previous plug-in and package it
> appropriately. The current alternative, which admittedly is no big deal, is
> to simply have the output artifact created by my plugin go directly into
> WEB-INF/lib. But adding a boolean config variable to maven-war-plugin to
> tell it to look for attached jars and include them seems logical as well as
> trivial to me, but this could just be because of my relative newness to all
> things Maven
>
> 2nd example: in project 4, I again use my obfuscation plugin on the common
> API and generated classes, and then want to take that artifact and, along
> with the rest of the dependencies, use the maven-shade-plugin to build an
> "uberjar". More problematic than example 1 above because the shade plugin
> only looks at artifacts and has no hook to include anything directly from
> the filesystem. So what I did was modify the shade 2.1 source to include a
> new configuration parameter. For simplicy's sake I simply called it "
> alternativeInputClassifier". When present, it instructs shade to look for
> an attached artifact with the artifact name of the project, of type jar,
> and with the specified classifier, in lieu of processing only the main
> project as input. It was a very minor change and I'm happy to provide the
> diff for it. The result is that my pom.xml for project 4 looks like below
> and works beautifully. One pom with two profiles:
>
>         <dependencies>
>                 ....
>                 <dependency>
>                         <groupId>com.idfconnect.myproject</groupId>
>                         <artifactId>common-tools</artifactId>
>                 </dependency>
>         </dependencies>
>         <profiles>
>                 <profile>
>                         <!-- REGULAR (unobfuscated) PROFILE -->
>                         <id>regular</id>
>                         <activation>
>                                 <activeByDefault>true</activeByDefault>
>                         </activation>
>                         <build>
>                                 <plugins>
>                                         <!-- BEGIN SHADE -->
>                                         <plugin>
>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-shade-plugin</artifactId>
>
> <version>2.1-idfc1</version>
>                                                 <executions>
>                                                         <execution>
>
> <phase>package</phase>
>                                                                 <goals>
>
> <goal>shade</goal>
>                                                                 </goals>
>
> <configuration>
>
> <minimizeJar>true</minimizeJar>
>
> <shadedArtifactAttached>true</shadedArtifactAttached>
>
> <shadedClassifierName>full</shadedClassifierName>
>
> </configuration>
>                                                         </execution>
>                                                 </executions>
>                                         </plugin>
>                                         <!-- END SHADE -->
>                                 </plugins>
>                         </build>
>                 </profile>
>
>                 <!-- OBFUSCATION PROFILE -->
>                 <profile>
>                         <id>obfuscate</id>
>                         <build>
>                                 <plugins>
>                                         <!-- BEGIN OBFUSCATE -->
>                                         <plugin>
>
> <groupId>com.idfconnect.devtools</groupId>
>
> <artifactId>idfc-proguard-maven-plugin</artifactId>
>                                                 <version>1.0.0</version>
>                                                 <executions>
>                                                         <execution>
>
> <phase>package</phase>
>                                                                 <goals>
>
> <goal>obfuscate</goal>
>                                                                 </goals>
>                                                         </execution>
>                                                 </executions>
>                                                 <configuration>
>
> <shrink>false</shrink>
>                                                         <inputArtifacts>
>
> <inputArtifact>com.idfconnect.myproject:common-tools</inputArtifact>
>                                                         </inputArtifacts>
>                                                         <libraryJarPaths>
>
> <libraryJarPath>${java.home}/lib/jsse.jar</libraryJarPath>
>                                                         </libraryJarPaths>
>                                                 </configuration>
>                                                 <dependencies>
>                                                         <dependency>
>
> <groupId>net.sf.proguard</groupId>
>
> <artifactId>proguard-base</artifactId>
>
> <version>4.9</version>
>                                                         </dependency>
>                                                 </dependencies>
>                                         </plugin>
>                                         <!-- END OBFUSCATE -->
>
>                                         <!-- BEGIN SHADE -->
>                                         <plugin>
>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-shade-plugin</artifactId>
>
> <version>2.1-idfc1</version>
>                                                 <executions>
>                                                         <execution>
>
> <phase>package</phase>
>                                                                 <goals>
>
> <goal>shade</goal>
>                                                                 </goals>
>
> <configuration>
>
> <alternativeInputClassifier>small</alternativeInputClassifier>
>
> <artifactSet>
>
>       <excludes>
>
> -Richard
>
> -----Original Message-----
> From: Wayne Fay [mailto:waynefay@gmail.com <javascript:;>]
> Sent: Tuesday, August 27, 2013 5:04 PM
> To: Maven Users List
> Subject: Re: artifact attached by plugin not appearing in subsequent
> plugins
>
> > Hi Wayne - that seems a very inefficient approach, having 5 or 6
> > separate modules to manage to achieve a single assembly. The point is
> > that maven does have phases, goals, lifecycles - why not use them? The
> > MavenProject object already provides the
>
> Not saying this is ideal for all scenarios. Just saying it is one solution
> that works out of the box and it leaves the door open for customization you
> may need along the way. People here oftentimes say they "just want to do X"
> and so we provide some advice. Then they come back a week later and say
> well actually they need variants of X for different clients, environments,
> architectures, etc so they share how they've been going down the path of
> profiles which most of us here believe is the wrong way to do things. I'm
> just trying to ensure you know TMTOWTDI (perl-ism). :)
>
> > ...I think dividing the construction of a single atomic component into
> > multiple modules because the plugins cannot be chained together is more
> unappealing.
>
> I don't disagree. As I said, this is based on my assumption (perhaps
> wrong) that you have left a great many details out of your original query,
> and the next few emails will describe a monstrous beast you have created
> with profiles and binding plugins to various lifecycles etc in an effort to
> do "all the work" in a single project/module. ;-)
>
> > BTW I haven't touched Ant in at least 6 years, so I doubt I'm an
> > "Ant-oriented person".  :-)
>
> Didn't mean you were necessarily Ant-oriented. I know you've released some
> Maven plugins lately. Thanks for your work in the Maven ecosystem! :)
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: users-help@maven.apache.org<javascript:;>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: dev-help@maven.apache.org <javascript:;>
>
>

-- 
Sent from my phone

RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Hi all,

Wayne, thanks for the feedback. I understand where you're coming from. I've written out here a concrete example of what I want to do with these plugins, and with maven in general wrt passing generated artifacts between plugins. Hopefully others will weigh in on whether this approach is good and maven-esque.

I have 4 maven projects:

1) a global parent pom
2) a common API project which creates a jar
3) a web application project (a Jersey JAX-RS service fwiw) which creates a war and depends on #2
4) a java client for #3 (based on JerseyClient), which also depends on #2

1st example: In project 3, I use my obfuscation plugin on the common API and the generated classes. That resulting jar file needs to go into the WEB-INF/lib folder of the war file. My proposed change to the maven war plugin would make it automatically look for a generated jar artifact attached to the project from a previous plug-in and package it appropriately. The current alternative, which admittedly is no big deal, is to simply have the output artifact created by my plugin go directly into WEB-INF/lib. But adding a boolean config variable to maven-war-plugin to tell it to look for attached jars and include them seems logical as well as trivial to me, but this could just be because of my relative newness to all things Maven

2nd example: in project 4, I again use my obfuscation plugin on the common API and generated classes, and then want to take that artifact and, along with the rest of the dependencies, use the maven-shade-plugin to build an "uberjar". More problematic than example 1 above because the shade plugin only looks at artifacts and has no hook to include anything directly from the filesystem. So what I did was modify the shade 2.1 source to include a new configuration parameter. For simplicy's sake I simply called it " alternativeInputClassifier". When present, it instructs shade to look for an attached artifact with the artifact name of the project, of type jar, and with the specified classifier, in lieu of processing only the main project as input. It was a very minor change and I'm happy to provide the diff for it. The result is that my pom.xml for project 4 looks like below and works beautifully. One pom with two profiles:

	<dependencies>
		....
		<dependency>
			<groupId>com.idfconnect.myproject</groupId>
			<artifactId>common-tools</artifactId>
		</dependency>
	</dependencies>
	<profiles>
		<profile>
			<!-- REGULAR (unobfuscated) PROFILE -->
			<id>regular</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<build>
				<plugins>
					<!-- BEGIN SHADE -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-shade-plugin</artifactId>
						<version>2.1-idfc1</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>shade</goal>
								</goals>
								<configuration>
									<minimizeJar>true</minimizeJar>
									<shadedArtifactAttached>true</shadedArtifactAttached>
									<shadedClassifierName>full</shadedClassifierName>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- END SHADE -->
				</plugins>
			</build>
		</profile>

		<!-- OBFUSCATION PROFILE -->
		<profile>
			<id>obfuscate</id>
			<build>
				<plugins>
					<!-- BEGIN OBFUSCATE -->
					<plugin>
						<groupId>com.idfconnect.devtools</groupId>
						<artifactId>idfc-proguard-maven-plugin</artifactId>
						<version>1.0.0</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>obfuscate</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<shrink>false</shrink>
							<inputArtifacts>
								<inputArtifact>com.idfconnect.myproject:common-tools</inputArtifact>
							</inputArtifacts>
							<libraryJarPaths>
								<libraryJarPath>${java.home}/lib/jsse.jar</libraryJarPath>
							</libraryJarPaths>
						</configuration>
						<dependencies>
							<dependency>
								<groupId>net.sf.proguard</groupId>
								<artifactId>proguard-base</artifactId>
								<version>4.9</version>
							</dependency>
						</dependencies>
					</plugin>
					<!-- END OBFUSCATE -->

					<!-- BEGIN SHADE -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-shade-plugin</artifactId>
						<version>2.1-idfc1</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>shade</goal>
								</goals>
								<configuration>
									<alternativeInputClassifier>small</alternativeInputClassifier>
									<artifactSet>
										<excludes>
											<exclude>com.idfconnect.myproject:common-tools</exclude>
										</excludes>
									</artifactSet>
									<minimizeJar>true</minimizeJar>
									<shadedArtifactAttached>true</shadedArtifactAttached>
									<shadedClassifierName>full</shadedClassifierName>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- END SHADE -->

				</plugins>
			</build>
		</profile>
	</profiles>

So I'm getting a decent amount of mileage out of the notion of using attachArtifact as a method of passing generated artifacts from one plugin to the next. 

So... now that I've modified maven-war-plugin and maven-shade-plugin to look at attached artifacts, would anyone like me to submit the patches on JIRA? I actually modified the shade plugin so you can run shade as a standalone goal, e.g. explicitly specify the input artifact in the plugin configuration and mvn shade away....

Also I'd like to suggest in any event that, for a future version of maven, it add a "transient artifact" space to maven sessions to allow this communication between plugins without actually writing the artifact to the local repository.

Looking forward to hearing your feedback. Thanks!

-Richard

-----Original Message-----
From: Wayne Fay [mailto:waynefay@gmail.com] 
Sent: Tuesday, August 27, 2013 5:04 PM
To: Maven Users List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

> Hi Wayne - that seems a very inefficient approach, having 5 or 6 
> separate modules to manage to achieve a single assembly. The point is 
> that maven does have phases, goals, lifecycles - why not use them? The 
> MavenProject object already provides the

Not saying this is ideal for all scenarios. Just saying it is one solution that works out of the box and it leaves the door open for customization you may need along the way. People here oftentimes say they "just want to do X" and so we provide some advice. Then they come back a week later and say well actually they need variants of X for different clients, environments, architectures, etc so they share how they've been going down the path of profiles which most of us here believe is the wrong way to do things. I'm just trying to ensure you know TMTOWTDI (perl-ism). :)

> ...I think dividing the construction of a single atomic component into 
> multiple modules because the plugins cannot be chained together is more unappealing.

I don't disagree. As I said, this is based on my assumption (perhaps
wrong) that you have left a great many details out of your original query, and the next few emails will describe a monstrous beast you have created with profiles and binding plugins to various lifecycles etc in an effort to do "all the work" in a single project/module. ;-)

> BTW I haven't touched Ant in at least 6 years, so I doubt I'm an 
> "Ant-oriented person".  :-)

Didn't mean you were necessarily Ant-oriented. I know you've released some Maven plugins lately. Thanks for your work in the Maven ecosystem! :)

Wayne

---------------------------------------------------------------------
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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Hi all,

Wayne, thanks for the feedback. I understand where you're coming from. I've written out here a concrete example of what I want to do with these plugins, and with maven in general wrt passing generated artifacts between plugins. Hopefully others will weigh in on whether this approach is good and maven-esque.

I have 4 maven projects:

1) a global parent pom
2) a common API project which creates a jar
3) a web application project (a Jersey JAX-RS service fwiw) which creates a war and depends on #2
4) a java client for #3 (based on JerseyClient), which also depends on #2

1st example: In project 3, I use my obfuscation plugin on the common API and the generated classes. That resulting jar file needs to go into the WEB-INF/lib folder of the war file. My proposed change to the maven war plugin would make it automatically look for a generated jar artifact attached to the project from a previous plug-in and package it appropriately. The current alternative, which admittedly is no big deal, is to simply have the output artifact created by my plugin go directly into WEB-INF/lib. But adding a boolean config variable to maven-war-plugin to tell it to look for attached jars and include them seems logical as well as trivial to me, but this could just be because of my relative newness to all things Maven

2nd example: in project 4, I again use my obfuscation plugin on the common API and generated classes, and then want to take that artifact and, along with the rest of the dependencies, use the maven-shade-plugin to build an "uberjar". More problematic than example 1 above because the shade plugin only looks at artifacts and has no hook to include anything directly from the filesystem. So what I did was modify the shade 2.1 source to include a new configuration parameter. For simplicy's sake I simply called it " alternativeInputClassifier". When present, it instructs shade to look for an attached artifact with the artifact name of the project, of type jar, and with the specified classifier, in lieu of processing only the main project as input. It was a very minor change and I'm happy to provide the diff for it. The result is that my pom.xml for project 4 looks like below and works beautifully. One pom with two profiles:

	<dependencies>
		....
		<dependency>
			<groupId>com.idfconnect.myproject</groupId>
			<artifactId>common-tools</artifactId>
		</dependency>
	</dependencies>
	<profiles>
		<profile>
			<!-- REGULAR (unobfuscated) PROFILE -->
			<id>regular</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<build>
				<plugins>
					<!-- BEGIN SHADE -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-shade-plugin</artifactId>
						<version>2.1-idfc1</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>shade</goal>
								</goals>
								<configuration>
									<minimizeJar>true</minimizeJar>
									<shadedArtifactAttached>true</shadedArtifactAttached>
									<shadedClassifierName>full</shadedClassifierName>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- END SHADE -->
				</plugins>
			</build>
		</profile>

		<!-- OBFUSCATION PROFILE -->
		<profile>
			<id>obfuscate</id>
			<build>
				<plugins>
					<!-- BEGIN OBFUSCATE -->
					<plugin>
						<groupId>com.idfconnect.devtools</groupId>
						<artifactId>idfc-proguard-maven-plugin</artifactId>
						<version>1.0.0</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>obfuscate</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<shrink>false</shrink>
							<inputArtifacts>
								<inputArtifact>com.idfconnect.myproject:common-tools</inputArtifact>
							</inputArtifacts>
							<libraryJarPaths>
								<libraryJarPath>${java.home}/lib/jsse.jar</libraryJarPath>
							</libraryJarPaths>
						</configuration>
						<dependencies>
							<dependency>
								<groupId>net.sf.proguard</groupId>
								<artifactId>proguard-base</artifactId>
								<version>4.9</version>
							</dependency>
						</dependencies>
					</plugin>
					<!-- END OBFUSCATE -->

					<!-- BEGIN SHADE -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-shade-plugin</artifactId>
						<version>2.1-idfc1</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>shade</goal>
								</goals>
								<configuration>
									<alternativeInputClassifier>small</alternativeInputClassifier>
									<artifactSet>
										<excludes>
											<exclude>com.idfconnect.myproject:common-tools</exclude>
										</excludes>
									</artifactSet>
									<minimizeJar>true</minimizeJar>
									<shadedArtifactAttached>true</shadedArtifactAttached>
									<shadedClassifierName>full</shadedClassifierName>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- END SHADE -->

				</plugins>
			</build>
		</profile>
	</profiles>

So I'm getting a decent amount of mileage out of the notion of using attachArtifact as a method of passing generated artifacts from one plugin to the next. 

So... now that I've modified maven-war-plugin and maven-shade-plugin to look at attached artifacts, would anyone like me to submit the patches on JIRA? I actually modified the shade plugin so you can run shade as a standalone goal, e.g. explicitly specify the input artifact in the plugin configuration and mvn shade away....

Also I'd like to suggest in any event that, for a future version of maven, it add a "transient artifact" space to maven sessions to allow this communication between plugins without actually writing the artifact to the local repository.

Looking forward to hearing your feedback. Thanks!

-Richard

-----Original Message-----
From: Wayne Fay [mailto:waynefay@gmail.com] 
Sent: Tuesday, August 27, 2013 5:04 PM
To: Maven Users List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

> Hi Wayne - that seems a very inefficient approach, having 5 or 6 
> separate modules to manage to achieve a single assembly. The point is 
> that maven does have phases, goals, lifecycles - why not use them? The 
> MavenProject object already provides the

Not saying this is ideal for all scenarios. Just saying it is one solution that works out of the box and it leaves the door open for customization you may need along the way. People here oftentimes say they "just want to do X" and so we provide some advice. Then they come back a week later and say well actually they need variants of X for different clients, environments, architectures, etc so they share how they've been going down the path of profiles which most of us here believe is the wrong way to do things. I'm just trying to ensure you know TMTOWTDI (perl-ism). :)

> ...I think dividing the construction of a single atomic component into 
> multiple modules because the plugins cannot be chained together is more unappealing.

I don't disagree. As I said, this is based on my assumption (perhaps
wrong) that you have left a great many details out of your original query, and the next few emails will describe a monstrous beast you have created with profiles and binding plugins to various lifecycles etc in an effort to do "all the work" in a single project/module. ;-)

> BTW I haven't touched Ant in at least 6 years, so I doubt I'm an 
> "Ant-oriented person".  :-)

Didn't mean you were necessarily Ant-oriented. I know you've released some Maven plugins lately. Thanks for your work in the Maven ecosystem! :)

Wayne

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




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


Re: artifact attached by plugin not appearing in subsequent plugins

Posted by Wayne Fay <wa...@gmail.com>.
> Hi Wayne - that seems a very inefficient approach, having 5 or 6 separate modules to
> manage to achieve a single assembly. The point is that maven does have phases,
> goals, lifecycles - why not use them? The MavenProject object already provides the

Not saying this is ideal for all scenarios. Just saying it is one
solution that works out of the box and it leaves the door open for
customization you may need along the way. People here oftentimes say
they "just want to do X" and so we provide some advice. Then they come
back a week later and say well actually they need variants of X for
different clients, environments, architectures, etc so they share how
they've been going down the path of profiles which most of us here
believe is the wrong way to do things. I'm just trying to ensure you
know TMTOWTDI (perl-ism). :)

> ...I think dividing the construction of a single atomic component into multiple modules
> because the plugins cannot be chained together is more unappealing.

I don't disagree. As I said, this is based on my assumption (perhaps
wrong) that you have left a great many details out of your original
query, and the next few emails will describe a monstrous beast you
have created with profiles and binding plugins to various lifecycles
etc in an effort to do "all the work" in a single project/module. ;-)

> BTW I haven't touched Ant in at least 6 years, so I doubt I'm an "Ant-oriented person".  :-)

Didn't mean you were necessarily Ant-oriented. I know you've released
some Maven plugins lately. Thanks for your work in the Maven
ecosystem! :)

Wayne

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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Hi Wayne - that seems a very inefficient approach, having 5 or 6 separate modules to manage to achieve a single assembly. The point is that maven does have phases, goals, lifecycles - why not use them? The MavenProject object already provides the mechanism for one plugin to see the attachments from a previous plugin, so again it’s a why-not question.

The way you present the choice of having a single maven module certainly makes it sound distasteful, but I think dividing the construction of a single atomic component into multiple modules because the plugins cannot be chained together is more unappealing. Especially when the maven architecture and API makes it so easy to do.

BTW I haven't touched Ant in at least 6 years, so I doubt I'm an "Ant-oriented person".  :-)

-Richard

-----Original Message-----
From: Wayne Fay [mailto:waynefay@gmail.com] 
Sent: Monday, August 26, 2013 5:59 PM
To: Maven Users List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

> Mirko thanks for your reply. I think the plugin API should have *some* 
> simple mechanism for transferring a "generated" artifact from one plugin to the next.

One way people on this list implement this is by viewing their various Maven modules as being a series of transformations which are applied to successive artifacts.

lib, common, etc
depended on by war
depended on by obfuscator
depended on by shader
depended on by assembly
eventually produces an obfuscated, shaded war file in a tar.gz along with the latest compatible version of Tomcat in an OS-specific package ready for simple deployment.

An Ant-oriented person might put all this in a single Maven module and force the various plugins to bind to different phases and customize or hard-code the configuration to force this pipeline just to achieve all of this in a single module build. A Maven-oriented person probably would not.

Wayne

---------------------------------------------------------------------
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


Re: artifact attached by plugin not appearing in subsequent plugins

Posted by Wayne Fay <wa...@gmail.com>.
> Mirko thanks for your reply. I think the plugin API should have *some* simple
> mechanism for transferring a "generated" artifact from one plugin to the next.

One way people on this list implement this is by viewing their various
Maven modules as being a series of transformations which are applied
to successive artifacts.

lib, common, etc
depended on by war
depended on by obfuscator
depended on by shader
depended on by assembly
eventually produces an obfuscated, shaded war file in a tar.gz along
with the latest compatible version of Tomcat in an OS-specific package
ready for simple deployment.

An Ant-oriented person might put all this in a single Maven module and
force the various plugins to bind to different phases and customize or
hard-code the configuration to force this pipeline just to achieve all
of this in a single module build. A Maven-oriented person probably
would not.

Wayne

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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Sorry just correcting myself, I was referring to the maven shade plugin not mojo shade plugin.

-Richard

-----Original Message-----
From: Richard Sand [mailto:rsand@idfconnect.com] 
Sent: Monday, August 26, 2013 4:54 PM
To: 'Maven Users List'; 'Maven Developers List'
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Hi all,

Mirko thanks for your reply. I think the plugin API should have *some* simple mechanism for transferring a "generated" artifact from one plugin to the next.

In my example, the project creates a standard named artifact i.e. "${project.build.finalName}.war", and the obfuscation plugin also a new (generated) jar artifact with classifier "small", i.e. ${project.build.finalName}-small.jar, specifically with the classes it has processed.

To get the war file to include this new generated artifact, I have to place it directly into the WEB-INF/lib folder, whereas by default it would go into ${project.build.directory}. Obviously this isn't burdensome. But my question was whether it would make sense to have the war plugin consider attached artifacts. I actually created issue MWAR-304 with a simple patch to do this, but the developer agreed with your point that attaching an artifact should only be used for placing said artifact into a repository, not as a mechanism for propagating the artifact to other plugins (https://jira.codehaus.org/browse/MWAR-304).

However this general use case (propagating a generated artifact between plugins) continues to vex me. Example - I tried using the mojo shade plugin to generate a jar to include in a web application.  Same type of use case - I want the shade plugin to use the artifact generated by a previous plugin. The shade plugin only accepts an artifact as an input, I cannot give it a path to a filename to include as I did above with the war plugin. So either way I need to modify the shade plugin - either to accept filesystem paths to include or a Boolean to tell it to check for dynamically attached plugins. Since Maven 3.0 includes MavenProject.getAttachedArtifacts(), it seems silly not to use it. If a plugin is going to accept artifacts as input, why shouldn't an attached artifact be considered? It seems like the natural and transparent mechanism to propagate generated, attached artifacts between plugins. Just choose your classifier and go. 

Granted, the shade plugin should also have a parameter to include filesystem paths.

Best regards,

Richard

-----Original Message-----
From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
Sent: Tuesday, August 20, 2013 11:40 AM
To: Maven Users List; Maven Developers List
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Hello Richard,

x-posted to dev, as the war-plugin is a core-plugin:
- IMO attaching would be the "wrong" term as it has another meaning.
- This is more of a "generated" jar (as generated sources,  classes etc.)
- IMO packages should go in Maven modules of their own.

Regards Mirko
--
Sent from my mobile
On Aug 20, 2013 5:13 PM, "Richard Sand" <rs...@idfconnect.com> wrote:

> Is there any merit to the idea of having a configuration option in 
> maven-war-plugin to include attached artifacts in the webapp in the 
> same way it includes dependent artifacts?
>
> -Richard
>
> -----Original Message-----
> From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
> Sent: Tuesday, August 20, 2013 6:20 AM
> To: Maven Users List
> Subject: RE: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Richard,
>
> AFAIK attachArtifact just tells Maven to install an additional binary 
> to it's local cache resp. to deploy it to the distribution repository.
>
> What you want, as far as I understand, is to create an artifact which 
> will be picked up later on and included in a war? You should probably 
> create a separate module project, which creates the jar and just 
> include this jar as runtime dependency in your war project.
>
> Regards Mirko
> --
> Sent from my mobile
> On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:
>
> > I concluded that this was a missing feature of maven-war-plugin, 
> > where it simply wasn't looking to see if there were attached resources.
> >
> > I supplied a simple patch to the handleArtifacts() method to have 
> > that method also handle attached artifacts,  You can see the report here.
> > https://jira.codehaus.org/browse/MWAR-304
> >
> > -Richard
> >
> > -----Original Message-----
> > From: Richard Sand [mailto:rsand@idfconnect.com]
> > Sent: Monday, August 19, 2013 6:19 PM
> > To: 'Maven Users List'
> > Subject: artifact attached by plugin not appearing in subsequent 
> > plugins
> >
> > Hi all - I've been stuck for a while trying to get an artifact 
> > injected by a plugin to apply to subsequent plugins/goals in a 
> > project.
> >
> > I have a project which generates a web application. My use case here 
> > is the obfuscator plugin which I wrote, which creates a jar file 
> > called "<projectname>-small.jar". The plugin creates jar file using 
> > MavenProjectHelper.attachArtifact(). The plugin executes during the 
> > packaging phase, before the maven-war-plugin. The jar file is 
> > created successfully, and the call to attachArtifact() returns with 
> > no errors, but the maven-war-plugin does not "see" the jar file and 
> > therefore doesn't include it in the results. When I turn on 
> > debugging I can see maven-war-plugin copying the other project 
> > artifacts into target/<projectname>/WEB-INF/lib.
> >
> > Have I missed a step? I know I can explicitly configure 
> > maven-war-plugin to grab the new artifact, but I thought the point 
> > of "attachArtifact" was to inject the new artifact into the flow.
> >
> > Appreciate any insight into what I'm doing wrong...
> >
> > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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




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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Hi all,

Mirko thanks for your reply. I think the plugin API should have *some* simple mechanism for transferring a "generated" artifact from one plugin to the next.

In my example, the project creates a standard named artifact i.e. "${project.build.finalName}.war", and the obfuscation plugin also a new (generated) jar artifact with classifier "small", i.e. ${project.build.finalName}-small.jar, specifically with the classes it has processed.

To get the war file to include this new generated artifact, I have to place it directly into the WEB-INF/lib folder, whereas by default it would go into ${project.build.directory}. Obviously this isn't burdensome. But my question was whether it would make sense to have the war plugin consider attached artifacts. I actually created issue MWAR-304 with a simple patch to do this, but the developer agreed with your point that attaching an artifact should only be used for placing said artifact into a repository, not as a mechanism for propagating the artifact to other plugins (https://jira.codehaus.org/browse/MWAR-304).

However this general use case (propagating a generated artifact between plugins) continues to vex me. Example - I tried using the mojo shade plugin to generate a jar to include in a web application.  Same type of use case - I want the shade plugin to use the artifact generated by a previous plugin. The shade plugin only accepts an artifact as an input, I cannot give it a path to a filename to include as I did above with the war plugin. So either way I need to modify the shade plugin - either to accept filesystem paths to include or a Boolean to tell it to check for dynamically attached plugins. Since Maven 3.0 includes MavenProject.getAttachedArtifacts(), it seems silly not to use it. If a plugin is going to accept artifacts as input, why shouldn't an attached artifact be considered? It seems like the natural and transparent mechanism to propagate generated, attached artifacts between plugins. Just choose your classifier and go. 

Granted, the shade plugin should also have a parameter to include filesystem paths.

Best regards,

Richard

-----Original Message-----
From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com] 
Sent: Tuesday, August 20, 2013 11:40 AM
To: Maven Users List; Maven Developers List
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Hello Richard,

x-posted to dev, as the war-plugin is a core-plugin:
- IMO attaching would be the "wrong" term as it has another meaning.
- This is more of a "generated" jar (as generated sources,  classes etc.)
- IMO packages should go in Maven modules of their own.

Regards Mirko
--
Sent from my mobile
On Aug 20, 2013 5:13 PM, "Richard Sand" <rs...@idfconnect.com> wrote:

> Is there any merit to the idea of having a configuration option in 
> maven-war-plugin to include attached artifacts in the webapp in the 
> same way it includes dependent artifacts?
>
> -Richard
>
> -----Original Message-----
> From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
> Sent: Tuesday, August 20, 2013 6:20 AM
> To: Maven Users List
> Subject: RE: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Richard,
>
> AFAIK attachArtifact just tells Maven to install an additional binary 
> to it's local cache resp. to deploy it to the distribution repository.
>
> What you want, as far as I understand, is to create an artifact which 
> will be picked up later on and included in a war? You should probably 
> create a separate module project, which creates the jar and just 
> include this jar as runtime dependency in your war project.
>
> Regards Mirko
> --
> Sent from my mobile
> On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:
>
> > I concluded that this was a missing feature of maven-war-plugin, 
> > where it simply wasn't looking to see if there were attached resources.
> >
> > I supplied a simple patch to the handleArtifacts() method to have 
> > that method also handle attached artifacts,  You can see the report here.
> > https://jira.codehaus.org/browse/MWAR-304
> >
> > -Richard
> >
> > -----Original Message-----
> > From: Richard Sand [mailto:rsand@idfconnect.com]
> > Sent: Monday, August 19, 2013 6:19 PM
> > To: 'Maven Users List'
> > Subject: artifact attached by plugin not appearing in subsequent 
> > plugins
> >
> > Hi all - I've been stuck for a while trying to get an artifact 
> > injected by a plugin to apply to subsequent plugins/goals in a 
> > project.
> >
> > I have a project which generates a web application. My use case here 
> > is the obfuscator plugin which I wrote, which creates a jar file 
> > called "<projectname>-small.jar". The plugin creates jar file using 
> > MavenProjectHelper.attachArtifact(). The plugin executes during the 
> > packaging phase, before the maven-war-plugin. The jar file is 
> > created successfully, and the call to attachArtifact() returns with 
> > no errors, but the maven-war-plugin does not "see" the jar file and 
> > therefore doesn't include it in the results. When I turn on 
> > debugging I can see maven-war-plugin copying the other project 
> > artifacts into target/<projectname>/WEB-INF/lib.
> >
> > Have I missed a step? I know I can explicitly configure 
> > maven-war-plugin to grab the new artifact, but I thought the point 
> > of "attachArtifact" was to inject the new artifact into the flow.
> >
> > Appreciate any insight into what I'm doing wrong...
> >
> > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Hi all,

Mirko thanks for your reply. I think the plugin API should have *some* simple mechanism for transferring a "generated" artifact from one plugin to the next.

In my example, the project creates a standard named artifact i.e. "${project.build.finalName}.war", and the obfuscation plugin also a new (generated) jar artifact with classifier "small", i.e. ${project.build.finalName}-small.jar, specifically with the classes it has processed.

To get the war file to include this new generated artifact, I have to place it directly into the WEB-INF/lib folder, whereas by default it would go into ${project.build.directory}. Obviously this isn't burdensome. But my question was whether it would make sense to have the war plugin consider attached artifacts. I actually created issue MWAR-304 with a simple patch to do this, but the developer agreed with your point that attaching an artifact should only be used for placing said artifact into a repository, not as a mechanism for propagating the artifact to other plugins (https://jira.codehaus.org/browse/MWAR-304).

However this general use case (propagating a generated artifact between plugins) continues to vex me. Example - I tried using the mojo shade plugin to generate a jar to include in a web application.  Same type of use case - I want the shade plugin to use the artifact generated by a previous plugin. The shade plugin only accepts an artifact as an input, I cannot give it a path to a filename to include as I did above with the war plugin. So either way I need to modify the shade plugin - either to accept filesystem paths to include or a Boolean to tell it to check for dynamically attached plugins. Since Maven 3.0 includes MavenProject.getAttachedArtifacts(), it seems silly not to use it. If a plugin is going to accept artifacts as input, why shouldn't an attached artifact be considered? It seems like the natural and transparent mechanism to propagate generated, attached artifacts between plugins. Just choose your classifier and go. 

Granted, the shade plugin should also have a parameter to include filesystem paths.

Best regards,

Richard

-----Original Message-----
From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com] 
Sent: Tuesday, August 20, 2013 11:40 AM
To: Maven Users List; Maven Developers List
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Hello Richard,

x-posted to dev, as the war-plugin is a core-plugin:
- IMO attaching would be the "wrong" term as it has another meaning.
- This is more of a "generated" jar (as generated sources,  classes etc.)
- IMO packages should go in Maven modules of their own.

Regards Mirko
--
Sent from my mobile
On Aug 20, 2013 5:13 PM, "Richard Sand" <rs...@idfconnect.com> wrote:

> Is there any merit to the idea of having a configuration option in 
> maven-war-plugin to include attached artifacts in the webapp in the 
> same way it includes dependent artifacts?
>
> -Richard
>
> -----Original Message-----
> From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
> Sent: Tuesday, August 20, 2013 6:20 AM
> To: Maven Users List
> Subject: RE: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Richard,
>
> AFAIK attachArtifact just tells Maven to install an additional binary 
> to it's local cache resp. to deploy it to the distribution repository.
>
> What you want, as far as I understand, is to create an artifact which 
> will be picked up later on and included in a war? You should probably 
> create a separate module project, which creates the jar and just 
> include this jar as runtime dependency in your war project.
>
> Regards Mirko
> --
> Sent from my mobile
> On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:
>
> > I concluded that this was a missing feature of maven-war-plugin, 
> > where it simply wasn't looking to see if there were attached resources.
> >
> > I supplied a simple patch to the handleArtifacts() method to have 
> > that method also handle attached artifacts,  You can see the report here.
> > https://jira.codehaus.org/browse/MWAR-304
> >
> > -Richard
> >
> > -----Original Message-----
> > From: Richard Sand [mailto:rsand@idfconnect.com]
> > Sent: Monday, August 19, 2013 6:19 PM
> > To: 'Maven Users List'
> > Subject: artifact attached by plugin not appearing in subsequent 
> > plugins
> >
> > Hi all - I've been stuck for a while trying to get an artifact 
> > injected by a plugin to apply to subsequent plugins/goals in a 
> > project.
> >
> > I have a project which generates a web application. My use case here 
> > is the obfuscator plugin which I wrote, which creates a jar file 
> > called "<projectname>-small.jar". The plugin creates jar file using 
> > MavenProjectHelper.attachArtifact(). The plugin executes during the 
> > packaging phase, before the maven-war-plugin. The jar file is 
> > created successfully, and the call to attachArtifact() returns with 
> > no errors, but the maven-war-plugin does not "see" the jar file and 
> > therefore doesn't include it in the results. When I turn on 
> > debugging I can see maven-war-plugin copying the other project 
> > artifacts into target/<projectname>/WEB-INF/lib.
> >
> > Have I missed a step? I know I can explicitly configure 
> > maven-war-plugin to grab the new artifact, but I thought the point 
> > of "attachArtifact" was to inject the new artifact into the flow.
> >
> > Appreciate any insight into what I'm doing wrong...
> >
> > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>



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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hello Richard,

x-posted to dev, as the war-plugin is a core-plugin:
- IMO attaching would be the "wrong" term as it has another meaning.
- This is more of a "generated" jar (as generated sources,  classes etc.)
- IMO packages should go in Maven modules of their own.

Regards Mirko
-- 
Sent from my mobile
On Aug 20, 2013 5:13 PM, "Richard Sand" <rs...@idfconnect.com> wrote:

> Is there any merit to the idea of having a configuration option in
> maven-war-plugin to include attached artifacts in the webapp in the same
> way it includes dependent artifacts?
>
> -Richard
>
> -----Original Message-----
> From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
> Sent: Tuesday, August 20, 2013 6:20 AM
> To: Maven Users List
> Subject: RE: artifact attached by plugin not appearing in subsequent
> plugins
>
> Richard,
>
> AFAIK attachArtifact just tells Maven to install an additional binary to
> it's local cache resp. to deploy it to the distribution repository.
>
> What you want, as far as I understand, is to create an artifact which will
> be picked up later on and included in a war? You should probably create a
> separate module project, which creates the jar and just include this jar as
> runtime dependency in your war project.
>
> Regards Mirko
> --
> Sent from my mobile
> On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:
>
> > I concluded that this was a missing feature of maven-war-plugin, where
> > it simply wasn't looking to see if there were attached resources.
> >
> > I supplied a simple patch to the handleArtifacts() method to have that
> > method also handle attached artifacts,  You can see the report here.
> > https://jira.codehaus.org/browse/MWAR-304
> >
> > -Richard
> >
> > -----Original Message-----
> > From: Richard Sand [mailto:rsand@idfconnect.com]
> > Sent: Monday, August 19, 2013 6:19 PM
> > To: 'Maven Users List'
> > Subject: artifact attached by plugin not appearing in subsequent
> > plugins
> >
> > Hi all - I've been stuck for a while trying to get an artifact
> > injected by a plugin to apply to subsequent plugins/goals in a
> > project.
> >
> > I have a project which generates a web application. My use case here
> > is the obfuscator plugin which I wrote, which creates a jar file
> > called "<projectname>-small.jar". The plugin creates jar file using
> > MavenProjectHelper.attachArtifact(). The plugin executes during the
> > packaging phase, before the maven-war-plugin. The jar file is created
> > successfully, and the call to attachArtifact() returns with no errors,
> > but the maven-war-plugin does not "see" the jar file and therefore
> > doesn't include it in the results. When I turn on debugging I can see
> > maven-war-plugin copying the other project artifacts into
> > target/<projectname>/WEB-INF/lib.
> >
> > Have I missed a step? I know I can explicitly configure
> > maven-war-plugin to grab the new artifact, but I thought the point of
> > "attachArtifact" was to inject the new artifact into the flow.
> >
> > Appreciate any insight into what I'm doing wrong...
> >
> > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hello Richard,

x-posted to dev, as the war-plugin is a core-plugin:
- IMO attaching would be the "wrong" term as it has another meaning.
- This is more of a "generated" jar (as generated sources,  classes etc.)
- IMO packages should go in Maven modules of their own.

Regards Mirko
-- 
Sent from my mobile
On Aug 20, 2013 5:13 PM, "Richard Sand" <rs...@idfconnect.com> wrote:

> Is there any merit to the idea of having a configuration option in
> maven-war-plugin to include attached artifacts in the webapp in the same
> way it includes dependent artifacts?
>
> -Richard
>
> -----Original Message-----
> From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com]
> Sent: Tuesday, August 20, 2013 6:20 AM
> To: Maven Users List
> Subject: RE: artifact attached by plugin not appearing in subsequent
> plugins
>
> Richard,
>
> AFAIK attachArtifact just tells Maven to install an additional binary to
> it's local cache resp. to deploy it to the distribution repository.
>
> What you want, as far as I understand, is to create an artifact which will
> be picked up later on and included in a war? You should probably create a
> separate module project, which creates the jar and just include this jar as
> runtime dependency in your war project.
>
> Regards Mirko
> --
> Sent from my mobile
> On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:
>
> > I concluded that this was a missing feature of maven-war-plugin, where
> > it simply wasn't looking to see if there were attached resources.
> >
> > I supplied a simple patch to the handleArtifacts() method to have that
> > method also handle attached artifacts,  You can see the report here.
> > https://jira.codehaus.org/browse/MWAR-304
> >
> > -Richard
> >
> > -----Original Message-----
> > From: Richard Sand [mailto:rsand@idfconnect.com]
> > Sent: Monday, August 19, 2013 6:19 PM
> > To: 'Maven Users List'
> > Subject: artifact attached by plugin not appearing in subsequent
> > plugins
> >
> > Hi all - I've been stuck for a while trying to get an artifact
> > injected by a plugin to apply to subsequent plugins/goals in a
> > project.
> >
> > I have a project which generates a web application. My use case here
> > is the obfuscator plugin which I wrote, which creates a jar file
> > called "<projectname>-small.jar". The plugin creates jar file using
> > MavenProjectHelper.attachArtifact(). The plugin executes during the
> > packaging phase, before the maven-war-plugin. The jar file is created
> > successfully, and the call to attachArtifact() returns with no errors,
> > but the maven-war-plugin does not "see" the jar file and therefore
> > doesn't include it in the results. When I turn on debugging I can see
> > maven-war-plugin copying the other project artifacts into
> > target/<projectname>/WEB-INF/lib.
> >
> > Have I missed a step? I know I can explicitly configure
> > maven-war-plugin to grab the new artifact, but I thought the point of
> > "attachArtifact" was to inject the new artifact into the flow.
> >
> > Appreciate any insight into what I'm doing wrong...
> >
> > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
I've tried it to the extent possible, yes. I attach with a classifier
"small" to indicate the obfuscated (and shrunken) jar. The maven war plugin
will look at the MavenProject.getArtifacts() to pull in the scoped
dependencies, but it doesn't look at MavenProject.getAttachedArtifacts().
There just isn't any hook there to get the plugin to process the attached
artifact - best I can do is write it directly into WEB-INF/lib and let the
packager pick it up.

So my proposal was to add a Boolean to the war plugin to tell it to include
any attached jar artifacts. I could optionally add a classifier name, e.g.
add only an attached artifact matching the artifactid of the project and
with this classifier. Or a list of any arbitrary artifact ID strings which
match attached artifacts... for my specific use case simply the Boolean will
do. 

And similarly I want to make the same change in the maven shade plugin. The
shade plugin is very focused on the primary artifact of the project, so for
that I was thinking to just adding the Boolean and classifier - as Stephen
points out, the attached artifact with classifier should have the same
transitive dependencies anyway.

The larger question is how to move generated artifacts from one plugin to
another. The pushback I've gotten on these proposed changes to the plugins
is that attachment isn't supposed to be used for that purpose - attachment
is solely for putting artifacts into the repository, and not for passing
newly generated artifacts between plugins.

New feature perhaps? Idea being the notion of transient artifacts which only
persist for the life of a maven session? Then other plugins in the same
execution which potentially could use these transient artifacts could either
automatically look for them or be configured to do so, like I suggested
above for the war and shade plugins. The only difference between the
transient and attached artifacts is that the transient wouldn't get
persisted to a repository. And if you want to attach it, a plugin like the
mojo buildhelper could have a goal to attach any (or specific) transient
artifacts.

If I'm talking crazy, please forgive me, school started today for my 2nd
grader and I haven't had my coffee yet. :-)

Thanks!

-Richard

-----Original Message-----
From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com] 
Sent: Tuesday, August 27, 2013 3:32 AM
To: Maven Users List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

On Tuesday, 27 August 2013, Barrie Treloar wrote:

> On 21 August 2013 00:42, Richard Sand <rsand@idfconnect.com 
> <javascript:;>>
> wrote:
> > Is there any merit to the idea of having a configuration option in
> maven-war-plugin to include attached artifacts in the webapp in the 
> same way it includes dependent artifacts?
>
> The MavenProjectHelper.attachArtifact requires a type or classifier in 
> order to be used.
>
> The default artifact and the attached artifact are different 
> dependencies, and so you need to specify them twice for them to be 
> included in the webapp.
> One for the default artifact and one for the attached artifact (which 
> has the type or classifier specified so that you can tell the 
> difference).
>
> I dont use the war plugin, but I specifying the dependency on the 
> attached artifact should mean that it appears in your war.


And better still, since the obfuscated artifact *should* have the same
transitive dependencies, it would be the one case where two artifacts from
the same module would be ok.

OTOH if obfuscation adds shade-like dependency reduction *then* it needs to
get a separate GAV


>
> Have you tried this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org 
> <javascript:;> For additional commands, e-mail: 
> users-help@maven.apache.org<javascript:;>
>
>

--
Sent from my phone



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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
I've tried it to the extent possible, yes. I attach with a classifier
"small" to indicate the obfuscated (and shrunken) jar. The maven war plugin
will look at the MavenProject.getArtifacts() to pull in the scoped
dependencies, but it doesn't look at MavenProject.getAttachedArtifacts().
There just isn't any hook there to get the plugin to process the attached
artifact - best I can do is write it directly into WEB-INF/lib and let the
packager pick it up.

So my proposal was to add a Boolean to the war plugin to tell it to include
any attached jar artifacts. I could optionally add a classifier name, e.g.
add only an attached artifact matching the artifactid of the project and
with this classifier. Or a list of any arbitrary artifact ID strings which
match attached artifacts... for my specific use case simply the Boolean will
do. 

And similarly I want to make the same change in the maven shade plugin. The
shade plugin is very focused on the primary artifact of the project, so for
that I was thinking to just adding the Boolean and classifier - as Stephen
points out, the attached artifact with classifier should have the same
transitive dependencies anyway.

The larger question is how to move generated artifacts from one plugin to
another. The pushback I've gotten on these proposed changes to the plugins
is that attachment isn't supposed to be used for that purpose - attachment
is solely for putting artifacts into the repository, and not for passing
newly generated artifacts between plugins.

New feature perhaps? Idea being the notion of transient artifacts which only
persist for the life of a maven session? Then other plugins in the same
execution which potentially could use these transient artifacts could either
automatically look for them or be configured to do so, like I suggested
above for the war and shade plugins. The only difference between the
transient and attached artifacts is that the transient wouldn't get
persisted to a repository. And if you want to attach it, a plugin like the
mojo buildhelper could have a goal to attach any (or specific) transient
artifacts.

If I'm talking crazy, please forgive me, school started today for my 2nd
grader and I haven't had my coffee yet. :-)

Thanks!

-Richard

-----Original Message-----
From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com] 
Sent: Tuesday, August 27, 2013 3:32 AM
To: Maven Users List
Subject: Re: artifact attached by plugin not appearing in subsequent plugins

On Tuesday, 27 August 2013, Barrie Treloar wrote:

> On 21 August 2013 00:42, Richard Sand <rsand@idfconnect.com 
> <javascript:;>>
> wrote:
> > Is there any merit to the idea of having a configuration option in
> maven-war-plugin to include attached artifacts in the webapp in the 
> same way it includes dependent artifacts?
>
> The MavenProjectHelper.attachArtifact requires a type or classifier in 
> order to be used.
>
> The default artifact and the attached artifact are different 
> dependencies, and so you need to specify them twice for them to be 
> included in the webapp.
> One for the default artifact and one for the attached artifact (which 
> has the type or classifier specified so that you can tell the 
> difference).
>
> I dont use the war plugin, but I specifying the dependency on the 
> attached artifact should mean that it appears in your war.


And better still, since the obfuscated artifact *should* have the same
transitive dependencies, it would be the one case where two artifacts from
the same module would be ok.

OTOH if obfuscation adds shade-like dependency reduction *then* it needs to
get a separate GAV


>
> Have you tried this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org 
> <javascript:;> For additional commands, e-mail: 
> users-help@maven.apache.org<javascript:;>
>
>

--
Sent from my phone



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


Re: artifact attached by plugin not appearing in subsequent plugins

Posted by Stephen Connolly <st...@gmail.com>.
On Tuesday, 27 August 2013, Barrie Treloar wrote:

> On 21 August 2013 00:42, Richard Sand <rsand@idfconnect.com <javascript:;>>
> wrote:
> > Is there any merit to the idea of having a configuration option in
> maven-war-plugin to include attached artifacts in the webapp in the same
> way it includes dependent artifacts?
>
> The MavenProjectHelper.attachArtifact requires a type or classifier in
> order to be used.
>
> The default artifact and the attached artifact are different
> dependencies, and so you need to specify them twice for them to be
> included in the webapp.
> One for the default artifact and one for the attached artifact (which
> has the type or classifier specified so that you can tell the
> difference).
>
> I dont use the war plugin, but I specifying the dependency on the
> attached artifact should mean that it appears in your war.


And better still, since the obfuscated artifact *should* have the same
transitive dependencies, it would be the one case where two artifacts from
the same module would be ok.

OTOH if obfuscation adds shade-like dependency reduction *then* it needs to
get a separate GAV


>
> Have you tried this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: users-help@maven.apache.org<javascript:;>
>
>

-- 
Sent from my phone

Re: artifact attached by plugin not appearing in subsequent plugins

Posted by Barrie Treloar <ba...@gmail.com>.
On 21 August 2013 00:42, Richard Sand <rs...@idfconnect.com> wrote:
> Is there any merit to the idea of having a configuration option in maven-war-plugin to include attached artifacts in the webapp in the same way it includes dependent artifacts?

The MavenProjectHelper.attachArtifact requires a type or classifier in
order to be used.

The default artifact and the attached artifact are different
dependencies, and so you need to specify them twice for them to be
included in the webapp.
One for the default artifact and one for the attached artifact (which
has the type or classifier specified so that you can tell the
difference).

I dont use the war plugin, but I specifying the dependency on the
attached artifact should mean that it appears in your war.

Have you tried this?

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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
Is there any merit to the idea of having a configuration option in maven-war-plugin to include attached artifacts in the webapp in the same way it includes dependent artifacts?

-Richard

-----Original Message-----
From: Mirko Friedenhagen [mailto:mfriedenhagen@gmail.com] 
Sent: Tuesday, August 20, 2013 6:20 AM
To: Maven Users List
Subject: RE: artifact attached by plugin not appearing in subsequent plugins

Richard,

AFAIK attachArtifact just tells Maven to install an additional binary to it's local cache resp. to deploy it to the distribution repository.

What you want, as far as I understand, is to create an artifact which will be picked up later on and included in a war? You should probably create a separate module project, which creates the jar and just include this jar as runtime dependency in your war project.

Regards Mirko
--
Sent from my mobile
On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:

> I concluded that this was a missing feature of maven-war-plugin, where 
> it simply wasn't looking to see if there were attached resources.
>
> I supplied a simple patch to the handleArtifacts() method to have that 
> method also handle attached artifacts,  You can see the report here.
> https://jira.codehaus.org/browse/MWAR-304
>
> -Richard
>
> -----Original Message-----
> From: Richard Sand [mailto:rsand@idfconnect.com]
> Sent: Monday, August 19, 2013 6:19 PM
> To: 'Maven Users List'
> Subject: artifact attached by plugin not appearing in subsequent 
> plugins
>
> Hi all - I've been stuck for a while trying to get an artifact 
> injected by a plugin to apply to subsequent plugins/goals in a 
> project.
>
> I have a project which generates a web application. My use case here 
> is the obfuscator plugin which I wrote, which creates a jar file 
> called "<projectname>-small.jar". The plugin creates jar file using 
> MavenProjectHelper.attachArtifact(). The plugin executes during the 
> packaging phase, before the maven-war-plugin. The jar file is created 
> successfully, and the call to attachArtifact() returns with no errors, 
> but the maven-war-plugin does not "see" the jar file and therefore 
> doesn't include it in the results. When I turn on debugging I can see 
> maven-war-plugin copying the other project artifacts into 
> target/<projectname>/WEB-INF/lib.
>
> Have I missed a step? I know I can explicitly configure 
> maven-war-plugin to grab the new artifact, but I thought the point of 
> "attachArtifact" was to inject the new artifact into the flow.
>
> Appreciate any insight into what I'm doing wrong...
>
> 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
>
>



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


RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Richard,

AFAIK attachArtifact just tells Maven to install an additional binary to
it's local cache resp. to deploy it to the distribution repository.

What you want, as far as I understand, is to create an artifact which will
be picked up later on and included in a war? You should probably create a
separate module project, which creates the jar and just include this jar as
runtime dependency in your war project.

Regards Mirko
-- 
Sent from my mobile
On Aug 20, 2013 7:42 AM, "Richard Sand" <rs...@idfconnect.com> wrote:

> I concluded that this was a missing feature of maven-war-plugin, where it
> simply wasn't looking to see if there were attached resources.
>
> I supplied a simple patch to the handleArtifacts() method to have that
> method also handle attached artifacts,  You can see the report here.
> https://jira.codehaus.org/browse/MWAR-304
>
> -Richard
>
> -----Original Message-----
> From: Richard Sand [mailto:rsand@idfconnect.com]
> Sent: Monday, August 19, 2013 6:19 PM
> To: 'Maven Users List'
> Subject: artifact attached by plugin not appearing in subsequent plugins
>
> Hi all - I've been stuck for a while trying to get an artifact injected by
> a
> plugin to apply to subsequent plugins/goals in a project.
>
> I have a project which generates a web application. My use case here is the
> obfuscator plugin which I wrote, which creates a jar file called
> "<projectname>-small.jar". The plugin creates jar file using
> MavenProjectHelper.attachArtifact(). The plugin executes during the
> packaging phase, before the maven-war-plugin. The jar file is created
> successfully, and the call to attachArtifact() returns with no errors, but
> the maven-war-plugin does not "see" the jar file and therefore doesn't
> include it in the results. When I turn on debugging I can see
> maven-war-plugin copying the other project artifacts into
> target/<projectname>/WEB-INF/lib.
>
> Have I missed a step? I know I can explicitly configure maven-war-plugin to
> grab the new artifact, but I thought the point of "attachArtifact" was to
> inject the new artifact into the flow.
>
> Appreciate any insight into what I'm doing wrong...
>
> 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
>
>

RE: artifact attached by plugin not appearing in subsequent plugins

Posted by Richard Sand <rs...@idfconnect.com>.
I concluded that this was a missing feature of maven-war-plugin, where it
simply wasn't looking to see if there were attached resources.

I supplied a simple patch to the handleArtifacts() method to have that
method also handle attached artifacts,  You can see the report here.
https://jira.codehaus.org/browse/MWAR-304

-Richard

-----Original Message-----
From: Richard Sand [mailto:rsand@idfconnect.com] 
Sent: Monday, August 19, 2013 6:19 PM
To: 'Maven Users List'
Subject: artifact attached by plugin not appearing in subsequent plugins

Hi all - I've been stuck for a while trying to get an artifact injected by a
plugin to apply to subsequent plugins/goals in a project.

I have a project which generates a web application. My use case here is the
obfuscator plugin which I wrote, which creates a jar file called
"<projectname>-small.jar". The plugin creates jar file using
MavenProjectHelper.attachArtifact(). The plugin executes during the
packaging phase, before the maven-war-plugin. The jar file is created
successfully, and the call to attachArtifact() returns with no errors, but
the maven-war-plugin does not "see" the jar file and therefore doesn't
include it in the results. When I turn on debugging I can see
maven-war-plugin copying the other project artifacts into
target/<projectname>/WEB-INF/lib.

Have I missed a step? I know I can explicitly configure maven-war-plugin to
grab the new artifact, but I thought the point of "attachArtifact" was to
inject the new artifact into the flow. 

Appreciate any insight into what I'm doing wrong...

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