Hi,
I'm currently trying to write a plugin to deploy a project to an application
server. This project is of a type not currently buildable by Maven so my
plan of action is to manually build the artifact and deploy it to my
internal remote repository (deploy:deployfile) and then get Maven to resolve
this artifact to the local repository and deploy it from there. I already
have the code necessary to deploy the artifact, I'm just trying to hook it
into Maven, and I need to get maven to download the artifact to the local
repository and then give me it's path there.

   1. /**
   2.  * @goal extract
   3.  * @phase package
   4.  * @requiresDependencyResolution test
   5.  */
   6. public class DeployWierdProjectType extends AbstractMojo {
   7.
   8.     /**
   9.      * @parameter default-value="${project}"
   10.      * @required
   11.      * @readonly
   12.      */
   13.     private MavenProject project;
   14.
   15.     public void execute() throws MojoExecutionException {
   16.
   17.
           
System.out.println(project.getArtifact().getFile().getAbsolutePath());
   18.
   19.     }
   20. }

/** * @goal extract * @phase package * @requiresDependencyResolution test */
public class DeployWierdProjectType extends AbstractMojo { /** * @parameter
default-value="${project}" * @required * @readonly */ private MavenProject
project; public void execute() throws MojoExecutionException {
System.out.println(project.getArtifact().getFile().getAbsolutePath()); } }

I've been teaching myself the Maven api using a tutorial project. The code
above gives me different results depending on the phase I define, so this
probably not an accurate exercise as my mojo will not be bound to the
lifecycle. I think I'm missing a couple pieces to my puzzle right now:

1) The DefaultArtifactResolver class's resolve(Artifact, List,
ArtifactRepository) method takes an ArtifactRepository parameter which
specifies the local repository. I can't figure out where to find this as the
MavenProject doesn't seem to supply it. MavenProject.getRepositores()
returned only remote repositories for me when trying it. If I could figure
out the ArtifactRepositoryLayout class I might be able to generate a
DefaultArtifactRepository from scratch but for portability this information
should really come from the currently running installation of Maven's
"conf/settings.xml" file (or a profile if that's possible?).

2) Actually due to the lack of information in the javadoc I'm really just
guessing that the ArtifactResolver's resolve method will, in fact, download
the specified Artifact to the local repository and update the value returned
by the Artifact.getFile() method. I could be off base here.

Any input on how to accomplish these tasks in maven is greatly appreciated.

Thanks

-- 
Tristan JC Rouse

Reply via email to