Permalink
Browse files

Merge branch 'master' of dyblast.fr:kerneos-store

  • Loading branch information...
2 parents ef856f6 + 6a6e666 commit 2200015b89cd6909294d5a408ef0472d7e99a6d1 @riverapj riverapj committed Sep 14, 2011
View
29 ...tory/maven/src/main/java/org/ow2/kerneosstore/repository/maven/impl/ArtifactResolver.java
@@ -28,6 +28,7 @@
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.repository.LocalRepository;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
@@ -43,19 +44,29 @@
public class ArtifactResolver {
private static Pattern artifactPattern = Pattern.compile("([^:]+):([^:]+)(?::([^:]+))?");
- private RemoteRepository repository;
+ private RemoteRepository repository = null;
private RepositorySystem system;
private RepositorySystemSession session;
public ArtifactResolver(String repository) {
// Init repository system
- system = Booter.newRepositorySystem();
- session = Booter.newRepositorySystemSession(system);
+ this.system = Booter.newRepositorySystem();
- if (repository != null)
- this.repository = new RemoteRepository("default", "default", repository);
- else
+ if (repository != null) {
+ if (repository.toLowerCase().startsWith("file://")) {
+ this.session = Booter.newRepositorySystemSession(this.system, repository.substring(7));
+ } else {
+ this.session = Booter.newRepositorySystemSession(this.system);
+ this.repository = new RemoteRepository("default", "default", repository);
+ }
+ } else {
+ this.session = Booter.newRepositorySystemSession(this.system);
this.repository = Booter.newCentralRepository();
+ }
+ }
+
+ public RepositorySystemSession getSession() {
+ return session;
}
public RemoteRepository getRepository() {
@@ -84,7 +95,8 @@ public Artifact getArtifact(String repositoryKey) throws ArtifactResolutionExcep
rangeRequest.setArtifact(artifact);
// Add repository
- rangeRequest.addRepository(repository);
+ if (repository != null)
+ rangeRequest.addRepository(repository);
// Resolve
VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
@@ -97,7 +109,8 @@ public Artifact getArtifact(String repositoryKey) throws ArtifactResolutionExcep
artfactRequest.setArtifact(artifact);
// Add repository
- artfactRequest.addRepository(repository);
+ if (repository != null)
+ artfactRequest.addRepository(repository);
// Resolve
ArtifactResult descriptorResult = system.resolveArtifact(session, artfactRequest);
View
20 repository/maven/src/main/java/org/ow2/kerneosstore/repository/maven/impl/Booter.java
@@ -18,27 +18,27 @@
/**
* A helper to boot the repository system and a repository system session.
*/
-public class Booter
-{
+public class Booter {
- public static RepositorySystem newRepositorySystem()
- {
+ public static RepositorySystem newRepositorySystem() {
return ManualRepositorySystemFactory.newRepositorySystem();
}
- public static RepositorySystemSession newRepositorySystemSession( RepositorySystem system )
- {
+ public static RepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
+ return newRepositorySystemSession(system, "target/local-repo");
+ }
+
+ public static RepositorySystemSession newRepositorySystemSession(RepositorySystem system, String repo) {
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
- LocalRepository localRepo = new LocalRepository( "target/local-repo" );
+ LocalRepository localRepo = new LocalRepository(repo);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
return session;
}
- public static RemoteRepository newCentralRepository()
- {
- return new RemoteRepository( "central", "default", "http://repo1.maven.org/maven2/" );
+ public static RemoteRepository newCentralRepository() {
+ return new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
}
}
View
1 repository/maven/src/main/java/org/ow2/kerneosstore/repository/maven/impl/Maven.java
@@ -118,6 +118,7 @@ public URL getModuleURI(String repositoryKey) {
Artifact artifact = resolver.getArtifact(repositoryKey);
return artifact.getFile().toURI().toURL();
} catch (Exception e) {
+ logger.error("Can't get the artifact \"" + repositoryKey + "\": " + e);
return null;
}
}
View
7 repository/maven/src/main/java/org/ow2/kerneosstore/repository/maven/impl/MavenThread.java
@@ -89,8 +89,11 @@ public void run() {
do {
logger.info("============================================================");
logger.info(MavenThread.class.getName());
- logger.info("ID: " + resolver.getRepository().getId());
- logger.info("URL: " + resolver.getRepository().getUrl());
+ logger.info("LOCAL: " + resolver.getSession().getLocalRepository().toString());
+ if (resolver.getRepository() != null) {
+ logger.info("ID: " + resolver.getRepository().getId());
+ logger.info("URL: " + resolver.getRepository().getUrl());
+ }
logger.info("------------------------------------------------------------");
logger.info("NO INDEX");
logger.info("============================================================");

0 comments on commit 2200015

Please sign in to comment.