You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Karl Heinz Marbaise <ka...@soebes.de> on 2011/04/20 10:26:39 UTC

Maven - Aether - Repositories from settings.xml

Hi,

i'm using Aether to get the available versions of an artifact so far so
good...but currently i have line in the code which i would like to solve in
a different way instead of hard coding it:


        Artifact artifact = new DefaultArtifact(
"com.soebes.subversion.sapm", "sapm", null, "[0,)");
        RemoteRepository repo = new RemoteRepository( "central", "default",
"http://repo1.maven.org/maven2/" );
        VersionRangeRequest rangeRequest = new VersionRangeRequest();
        rangeRequest.setArtifact( artifact );
        rangeRequest.addRepository( repo );
        VersionRangeResult rangeResult = system.resolveVersionRange(
session, rangeRequest );
        List versions = rangeResult.getVersions();

The line i wan't to do different is the following:

RemoteRepository repo = new RemoteRepository( "central", "default",
"http://repo1.maven.org/maven2/" );


Isn't there a better solution to the information about the repositories from
the current settings.xml file or from the system configuration settings.xml
file. 

Does exist an example how to load the settings.xml of the user and the
system configuration to create the above repository configuration?

Many thanks in advance
Kind regards
Karl Heinz Marbaise

-----
Kind regards
Karl Heinz Marbaise
----
http://www.soebes.de
http://www.skmwiki.de
http://supose.org/wiki/supose
--
View this message in context: http://maven.40175.n5.nabble.com/Maven-Aether-Repositories-from-settings-xml-tp4315216p4315216.html
Sent from the Maven - Users mailing list archive at Nabble.com.

Re: Maven - Aether - Repositories from settings.xml

Posted by Karl Heinz Marbaise <ka...@soebes.de>.
Hi Benjamin,


Benjamin Bentmann wrote:
> 
> Let's start with the clarification that this exception is logged and not 
> thrown up.
> 
Outch...sorry...that could be found by myself..But thanks for the
clarifiaction...


Benjamin Bentmann wrote:
> 
> VersionRangeResult.getExceptions().
> 
Thanks for that hint...


Benjamin Bentmann wrote:
> 
> You do realize that metadata is cached and only re-retrieved from the 
> remote side according to the update policy?
> Sorry oversight that...of course...you are right...how could i oversight
> that ;-(...

Kind regards
Karl Heinz Marbaise

-----
Kind regards
Karl Heinz Marbaise
----
http://www.soebes.de
http://www.skmwiki.de
http://supose.org/wiki/supose
--
View this message in context: http://maven.40175.n5.nabble.com/Maven-Aether-Repositories-from-settings-xml-tp4315216p4343258.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Maven - Aether - Repositories from settings.xml

Posted by Benjamin Bentmann <be...@udo.edu>.
Karl Heinz Marbaise wrote:

> I observed a little thing which i didn't understand...
> If i run the example the first time i got the following exception:

Let's start with the clarification that this exception is logged and not 
thrown up.

> Furthermore in the interface RepositorySystem the method
>
>   VersionRangeResult resolveVersionRange( RepositorySystemSession session,
> VersionRangeRequest request )
>          throws VersionRangeResolutionException;
>
> does not define this kind of Exception so i have no chance to catch such
> kind of exception...

VersionRangeResult.getExceptions().

> If i run the example the second time the exception does not appear a second
> time....and not on all further runnings...
> If i delete the local repository and start it again i got the above
> exception...

You do realize that metadata is cached and only re-retrieved from the 
remote side according to the update policy?


Benjamin

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


Re: Maven - Aether - Repositories from settings.xml

Posted by Karl Heinz Marbaise <ka...@soebes.de>.
Hi Benjamin,

first many thanks for your hints....

But now i working on a small test program (FindAvailableVersions from Aether
Demo) to check how Aether is working and how i have to use it...

I observed a little thing which i didn't understand...
If i run the example the first time i got the following exception:

Resolving metadata com.company.sales:artifact-common/maven-metadata.xml from
/home/ubuntu/ws-git/current-version/target/local-repo (enhanced)
Resolved metadata com.company.sales:artifact-common/maven-metadata.xml from
/home/ubuntu/ws-git/current-version/target/local-repo (enhanced)
Resolving metadata com.company.sales:artifact-common/maven-metadata.xml from
company-releases
(http://mavenrepo.localdomain:8081/nexus/content/groups/company-releases,
releases)
Resolving metadata com.company.sales:artifact-common/maven-metadata.xml from
central
(http://mavenrepo.localdomain:8081/nexus/content/groups/ext-releases,
releases)
Resolving metadata com.company.sales:artifact-common/maven-metadata.xml from
company-snapshots
(http://mavenrepo.localdomain:8081/nexus/content/groups/company-snapshots,
snapshots)
Resolving metadata com.company.sales:artifact-common/maven-metadata.xml from
company-plugins
(http://mavenrepo.localdomain:8081/nexus/content/groups/company-plugins,
releases)
Downloading:
http://mavenrepo.localdomain:8081/nexus/content/groups/company-releases/com.company.sales/artifact-common/maven-metadata.xml
Downloading:
http://mavenrepo.localdomain:8081/nexus/content/groups/ext-releases/com.company.sales/artifact-common/maven-metadata.xml
Downloading:
http://mavenrepo.localdomain:8081/nexus/content/groups/company-snapshots/com.company.sales/artifact-common/maven-metadata.xml
Downloading:
http://mavenrepo.localdomain:8081/nexus/content/groups/company-plugins/com.company.sales/artifact-common/maven-metadata.xml

org.apache.maven.wagon.ResourceDoesNotExistException: Unable to locate
resource in repository
	at
org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:139)
	at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
	at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
	at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
	at
org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:608)
	at
org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:64)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.FileNotFoundException:
http://mavenrepo.localdomain:8081/nexus/content/groups/ext-releases/com.company.sales/artifact-common/maven-metadata.xml
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at
sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491)
	at java.security.AccessController.doPrivileged(Native Method)
	at
sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485)
	at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)
	at
org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:122)
	... 8 more
Caused by: java.io.FileNotFoundException:
http://mavenrepo.localdomain:8081/nexus/content/groups/ext-releases/com.company.sales/artifact-common/maven-metadata.xml
	at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1434)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
	at
org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:115)
	... 8 more
2 KB   
2 KB   2 KB   
              
              
Downloaded:
http://mavenrepo.localdomain:8081/nexus/content/groups/company-releases/com.company.sales/artifact-common/maven-metadata.xml
(2 KB at 1.9 KB/sec)
Downloaded:
http://mavenrepo.localdomain:8081/nexus/content/groups/company-plugins/com.company.sales/artifact-common/maven-metadata.xml
(2 KB at 2.0 KB/sec)
345 B         
        
Downloaded:
http://mavenrepo.localdomain:8081/nexus/content/groups/company-snapshots/com.company.sales/artifact-common/maven-metadata.xml
(345 B at 0.3 KB/sec)
Resolved metadata com.company.sales:artifact-common/maven-metadata.xml from
company-releases
(http://mavenrepo.localdomain:8081/nexus/content/groups/company-releases,
releases)
Resolved metadata com.company.sales:artifact-common/maven-metadata.xml from
central
(http://mavenrepo.localdomain:8081/nexus/content/groups/ext-releases,
releases)
Resolved metadata com.company.sales:artifact-common/maven-metadata.xml from
company-snapshots
(http://mavenrepo.localdomain:8081/nexus/content/groups/company-snapshots,
snapshots)
Resolved metadata com.company.sales:artifact-common/maven-metadata.xml from
company-plugins
(http://mavenrepo.localdomain:8081/nexus/content/groups/company-plugins,
releases)
Available versions [y, 0.1.3-SNAPSHOT, 0.1.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8,
1.0.9, 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17,
1.0.18, 1.0.19, 1.0.20, 1.0.21, 1.0.22, 1.0.23, 1.0.24, 1.0.25, 1.0.26,
1.0.27]
Newest Version:1.0.27

Furthermore in the interface RepositorySystem the method


 VersionRangeResult resolveVersionRange( RepositorySystemSession session,
VersionRangeRequest request )
        throws VersionRangeResolutionException;

does not define this kind of Exception so i have no chance to catch such
kind of exception...
If i run the example the second time the exception does not appear a second
time....and not on all further runnings...
If i delete the local repository and start it again i got the above
exception...

So may be someone has a good hint about that...

Many thanks in advance

Kind regards

Karl Heinz Marbiase


-----
Kind regards
Karl Heinz Marbaise
----
http://www.soebes.de
http://www.skmwiki.de
http://supose.org/wiki/supose
--
View this message in context: http://maven.40175.n5.nabble.com/Maven-Aether-Repositories-from-settings-xml-tp4315216p4343057.html
Sent from the Maven - Users mailing list archive at Nabble.com.

Re: Maven - Aether - Repositories from settings.xml

Posted by Benjamin Bentmann <be...@udo.edu>.
Karl Heinz Marbaise wrote:

> Isn't there a better solution to the information about the repositories from
> the current settings.xml file or from the system configuration settings.xml
> file.

http://maven.apache.org/ref/3.0.3/maven-settings-builder/apidocs/org/apache/maven/settings/building/SettingsBuilder.html

and related components from the maven-settings-builder should do. 
Depending on how fancy you need to get, you might also want to use

http://maven.apache.org/ref/3.0.3/maven-model-builder/apidocs/org/apache/maven/model/profile/ProfileSelector.html


Benjamin

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