You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Alan D. Cabrera" <li...@toolazydogs.com> on 2009/05/18 06:48:58 UTC

Programatically loading jars from the local maven repository

I need to programatically load jars from the local maven repository.   
While the format of the repository is pretty simple I would like to be  
relieved of the tedium of discovering where this local repository is  
and, as an added bonus, I would love to have jars automatically  
downloaded to my local repository if it is not there already.

Can someone point me to the code bits that will help me do this?


Regards,
Alan


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


Re: Programatically loading jars from the local maven repository

Posted by Oleg Gusakov <ol...@gmail.com>.

Jason van Zyl wrote:
>
> If you want Maven specific use the RepositorySystem in that branch 
> (will go to trunk in a few days), and use Mercury directly if you want 
> something Maven independent.
>
In case you decided to try out Mercury - look at IT 
https://svn.apache.org/repos/asf/maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/repository/tests/ComprehensiveRepositoryTest.java 
sets up 2 local repos, 2 remote repos and reads/writes to them. The idea 
is: you create a repository out of either URL of a local directory, then 
obtain and use either reader or writer via repo.getReader()/getWriter()

Or create a VirtualRepositoryReader() on top of a repository collection 
- it will search them all.

http://docs.codehaus.org/display/MAVEN/HowTo+use+Mercury+for+accessing+repositories

Mercury is also available as a set of Ant tasks. Poke me if you need 
more details ..

thanks,
Oleg

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


Re: Programatically loading jars from the local maven repository

Posted by Jason van Zyl <jv...@sonatype.com>.
If you want to use what is going to get expelled from the Maven 3.x  
core for all things to use then take a look here:

http://svn.apache.org/repos/asf/maven/components/branches/MNG-2766/maven-repository/src/main/java/org/apache/maven/repository/RepositorySystem.java

Right now in that branch it depends on maven-compat which contains the  
resolution code used in 2.x, but the RepositorySystem will have a  
Mercury implementation as well. But this interface is meant to serve  
as the single point of entry for all things Maven resolution related.  
Mercury is a general purpose resolution system and hasn't been  
dovetailed exactly with Maven. That will happen as part of a  
RepositorySystem implementation that Oleg has been working on in a  
branch.

By the end of the week there will be:

repository-system-api
repository-system-legacy

modules which will be self contained that you can use. If you're going  
to consume this feedback would be welcome. The goal here was to shore  
up much of the dangling public API and create one interface that Maven  
3.x uses internally as well as any plugins that require artifact  
resolution. The upshot is that 2.x plugins will be able to use this  
interface and from the API level nothing will change. I still don't  
know how much behavioral characteristics will change as a result of  
plugging in Mercury.

If you want Maven specific use the RepositorySystem in that branch  
(will go to trunk in a few days), and use Mercury directly if you want  
something Maven independent.

Happy to help you out if you want to try it.

On 18-May-09, at 3:46 AM, Alin Dreghiciu wrote:

> Alan,
> We are implementing at OPS4J Pax URL a simple osgi url handler (that  
> you
> could use also outside osgi) based on Mercury. I started  
> implementing it a
> while ago but then I run into problems with Mercury so was on hold  
> for a
> while. But I will be back on development soon. Once ready the only  
> thing you
> have to do is:
>
> new URL(maven:org.mygroup:myartifact) and so, you get the input  
> stream of
> your jar
>
> If the part where the jar is downloaded into your local repository  
> is not a
> "must" you can use the current "mvn" url handler:
> http://wiki.ops4j.org//x/CoA6
>
>
> On Mon, May 18, 2009 at 7:48 AM, Alan D. Cabrera  
> <li...@toolazydogs.com>wrote:
>
>> I need to programatically load jars from the local maven  
>> repository.  While
>> the format of the repository is pretty simple I would like to be  
>> relieved of
>> the tedium of discovering where this local repository is and, as an  
>> added
>> bonus, I would love to have jars automatically downloaded to my local
>> repository if it is not there already.
>>
>> Can someone point me to the code bits that will help me do this?
>>
>>
>> Regards,
>> Alan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
>
> -- 
> Alin Dreghiciu
> Software Developer - Looking for new projects!
> My profile: http://www.linkedin.com/in/alindreghiciu
> My blog: http://adreghiciu.blogspot.com
> http://www.ops4j.org - New Energy for OSS Communities - Open  
> Participation
> Software.
> http://www.qi4j.org - New Energy for Java - Domain Driven Development.

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
http://twitter.com/jvanzyl
http://twitter.com/SonatypeNexus
http://twitter.com/SonatypeM2E
----------------------------------------------------------

Three may keep a secret if two of them are dead.

  -- Benjamin Franklin


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


Re: Programatically loading jars from the local maven repository

Posted by Alin Dreghiciu <ad...@gmail.com>.
Alan,
We are implementing at OPS4J Pax URL a simple osgi url handler (that you
could use also outside osgi) based on Mercury. I started implementing it a
while ago but then I run into problems with Mercury so was on hold for a
while. But I will be back on development soon. Once ready the only thing you
have to do is:

new URL(maven:org.mygroup:myartifact) and so, you get the input stream of
your jar

If the part where the jar is downloaded into your local repository is not a
"must" you can use the current "mvn" url handler:
http://wiki.ops4j.org//x/CoA6


On Mon, May 18, 2009 at 7:48 AM, Alan D. Cabrera <li...@toolazydogs.com>wrote:

> I need to programatically load jars from the local maven repository.  While
> the format of the repository is pretty simple I would like to be relieved of
> the tedium of discovering where this local repository is and, as an added
> bonus, I would love to have jars automatically downloaded to my local
> repository if it is not there already.
>
> Can someone point me to the code bits that will help me do this?
>
>
> Regards,
> Alan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


-- 
Alin Dreghiciu
Software Developer - Looking for new projects!
My profile: http://www.linkedin.com/in/alindreghiciu
My blog: http://adreghiciu.blogspot.com
http://www.ops4j.org - New Energy for OSS Communities - Open Participation
Software.
http://www.qi4j.org - New Energy for Java - Domain Driven Development.