maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Sand" <rs...@idfconnect.com>
Subject RE: artifact attached by plugin not appearing in subsequent plugins
Date Mon, 26 Aug 2013 20:53:38 GMT
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" <rsand@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" <rsand@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


Mime
View raw message