Skip to content
Browse files

allow to run offline

  • Loading branch information...
1 parent cc4e600 commit 0490bd4b479b345bc8dbd8a5b0b95cc709a273dd @mkristian committed Sep 24, 2012
Showing with 11 additions and 9 deletions.
  1. 0 Test.md
  2. +2 −2 lib/jbundler/aether.rb
  3. +9 −7 src/main/java/jbundler/Aether.java
View
0 Test.md
No changes.
View
4 lib/jbundler/aether.rb
@@ -85,11 +85,11 @@ def self.setup_classloader
java_import 'jbundler.Aether'
end
- def initialize(config = Config.new)
+ def initialize(config = Config.new, offline = false)
unless defined? Aether
self.class.setup_classloader
end
- @aether = Aether.new(config.local_repository, config.verbose)
+ @aether = Aether.new(config.local_repository, config.verbose, offline)
end
def add_artifact(coordinate, extension = nil)
View
16 src/main/java/jbundler/Aether.java
@@ -39,13 +39,13 @@
private List<Artifact> artifacts = new LinkedList<Artifact>();
private List<RemoteRepository> repos = new LinkedList<RemoteRepository>();
private Installer installer;
-
- public Aether(String localRepo, boolean verbose){
+
+ public Aether(String localRepo, boolean verbose, boolean offline){
ServiceLocator locator = newServiceLocator();
repoSystem = locator.getService( RepositorySystem.class );
installer = locator.getService( Installer.class );
- session = newSession( repoSystem, localRepo, verbose );
+ session = newSession( repoSystem, localRepo, verbose, offline );
RemoteRepository central = new RemoteRepository( "central", "default", "http://repo1.maven.org/maven2/" );
repos.add(central);
@@ -61,12 +61,14 @@ private ServiceLocator newServiceLocator() {
return locator;
}
- private RepositorySystemSession newSession( RepositorySystem system, String localRepoPath, boolean verbose ) {
+ private RepositorySystemSession newSession( RepositorySystem system, String localRepoPath, boolean verbose,
+ boolean offline ) {
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
LocalRepository localRepo = new LocalRepository( localRepoPath );
session.setLocalRepositoryManager( system.newLocalRepositoryManager( localRepo ) );
session.setRepositoryListener( new SimpleRepositoryListener(verbose, session.getLocalRepositoryManager()) );
+ session.setOffline(offline);
return session;
}
@@ -77,7 +79,7 @@ public void addArtifact(String coordinate){
public void addRepository(String id, String url){
repos.add(new RemoteRepository(id, "default", url));
}
-
+
public void resolve() throws DependencyCollectionException, DependencyResolutionException {
if (artifacts.size() == 0){
throw new IllegalArgumentException("no artifacts given");
@@ -87,15 +89,15 @@ public void resolve() throws DependencyCollectionException, DependencyResolution
for( Artifact a: artifacts ){
collectRequest.addDependency( new Dependency( a, "compile" ) );
}
-
+
for( RemoteRepository r: repos ){
collectRequest.addRepository( r );
}
node = repoSystem.collectDependencies( session, collectRequest ).getRoot();
DependencyRequest dependencyRequest = new DependencyRequest( node, null );
-
+
repoSystem.resolveDependencies( session, dependencyRequest );
}

0 comments on commit 0490bd4

Please sign in to comment.
Something went wrong with that request. Please try again.