aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Plugin Development: resolving arbitrary artifacts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Plugin Development: resolving arbitrary artifacts" Watch "Plugin Development: resolving arbitrary artifacts" New topic
Author

Plugin Development: resolving arbitrary artifacts

Emilio Kazwell
Ranch Hand

Joined: Aug 28, 2009
Posts: 37
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.



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
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Have you tried using some of the existing deployment plugins for maven such as Jboss and cargo?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Emilio Kazwell
Ranch Hand

Joined: Aug 28, 2009
Posts: 37
Martijn Verburg wrote:Have you tried using some of the existing deployment plugins for maven such as Jboss and cargo?


Yep, What I'm trying to deploy is an Oracle Service Bus configuration jar. The above mentioned tools can deploy WARs, EARs, and JARs as applications and libraries I'm sure, but this artifact is very proprietary and specialized.

...

I'm really terribly surprised at the javadocs online for Maven2. There are javadocs generated from source, but virtually no human written class/member descriptions.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You're best bet is to ask your question on the maven developers list in that case (you might get lucky here, but the maven-dev list is specialised for those sorts of questions).

Best of luck!
Emilio Kazwell
Ranch Hand

Joined: Aug 28, 2009
Posts: 37
Ok. Thanks, Martijn.
Emilio Kazwell
Ranch Hand

Joined: Aug 28, 2009
Posts: 37
Just in case anyone has similar questions in the future this page is the result of asking around on the developer forums:

http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook

Good info above.
 
wood burning stoves
 
subject: Plugin Development: resolving arbitrary artifacts