On 05/03/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Thanks Martin.
> I want a File object or a path to the project's target artifact.
> I have managed to calculate the target artifact myself using
> project.getArtifact() and project.getBuild().getOutputDirectory() but
> thought that there may be a simple and more robust API that I haven't
> noticed.
if the artifact has been built in this particular build invocation then:
project.getArtifact().getFile()
will give you its location - but note that if you run your plugin on its
own, outside of an actual "mvn package", then this will return null.
alternatively you can use the following scheme:
project.getBuild().getDirectory() + '/' + project.getBuild().getFinalName()
+ ...etc...
although finding the actual extension used for a given artifact type
is a bit tricky, and you might also need to add a classifier section.
part of this is because maven doesn't really mind where the artifact
is written to - because "mvn install" will run the packaging phase,
which means the relevant packaging plugin (jar, etc.) will have set
the artifact file - if you just run "mvn install:install" you'll see it
fail...
FYI, you can also use the "localRepository" component:
/**
* Local Repository.
*
* @parameter expression="${localRepository}"
* @required
* @readonly
*/
private ArtifactRepository localRepository;
to find the location of an artifact inside the current local repository:
localRepository.getBasedir() + '/' + localRepository.pathOf( artifact )
and there are other components to resolve an artifact in repositories.
I'm writing a plugin that assembles certain artifacts into one zip so
> they may be easily installed on another machine.
> I need this in order to have downloadables for certain open source
> projects, and thus enable users, without using maven repositories, to
> download a library artifact and its dependencies in a simple manner. The
> zip will also contain scripts to install the artifacts into the local
> repo.
hmm, well this sounds exactly like the maven-assembly-plugin:
http://maven.apache.org/plugins/maven-assembly-plugin
which lets you create distributions, etc. from maven projects
there's also the maven-dependency-plugin which can copy
collections of artifacts / project dependencies to a location.
HTH
-----Original Message-----
> From: Martin Gainty [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 05, 2008 3:04 PM
> To: Maven Users List
> Subject: Re: Maven plugin API - how do I find the File for the artifact
> of current project?
>
> Good Morning Daniel-
>
> org.apache.maven.model.Build has no accessors/mutators or methods which
> manipulate Artifact
>
> the getArtifact() method is present in 2.0.x version of
> org.apache.maven.project.MavenProject.java
> public Artifact getArtifact()
> {
> return artifact;
> }
> e.g.
> org.apache.maven.project.MavenProject project = new
> org.apache.maven.project.MavenProject();
> Artifact artifact=project.getArtifact();
>
> We could provide more assistance if you could tell us what you're
> attempting
> to accomplish
>
> Martin--
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Wednesday, March 05, 2008 7:15 AM
> Subject: Maven plugin API - how do I find the File for the artifact of
> current project?
>
>
>
> Hi.
> I looked for all kinds of APIs in org.apache.maven.project.MavenProject
> but did not find any API to give me the file/filename for the build's
> output artifact.
> The project.getArtifact() returns an Artifact object that describes the
> artifact. I can use it to calculate what is the artifact, but there must
> be a simpler way to get it.
> Also, the Build object returned by project.getBuild() has no such
> method.
>
> Thanks for your answers ...
>
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Cheers, Stuart