org.eclipse.aether.transport.http.HttpTransporterFactory Java Examples

The following examples show how to use org.eclipse.aether.transport.http.HttpTransporterFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DependencyResolver.java    From spring-init with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(ModelLocator.class).to(DefaultModelLocator.class).in(Singleton.class);
	bind(ModelReader.class).to(DefaultModelReader.class).in(Singleton.class);
	bind(ModelValidator.class).to(DefaultModelValidator.class).in(Singleton.class);
	bind(RepositoryConnectorFactory.class).to(BasicRepositoryConnectorFactory.class)
			.in(Singleton.class);
	bind(ArtifactDescriptorReader.class) //
			.to(DefaultArtifactDescriptorReader.class).in(Singleton.class);
	bind(VersionResolver.class) //
			.to(DefaultVersionResolver.class).in(Singleton.class);
	bind(VersionRangeResolver.class) //
			.to(DefaultVersionRangeResolver.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("snapshot")) //
			.to(SnapshotMetadataGeneratorFactory.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("versions")) //
			.to(VersionsMetadataGeneratorFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("http"))
			.to(HttpTransporterFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("file"))
			.to(FileTransporterFactory.class).in(Singleton.class);
}
 
Example #2
Source File: Helper.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public static RepositorySystem newRepositorySystem ()
{
    final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator ();

    locator.addService ( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class );
    locator.addService ( TransporterFactory.class, FileTransporterFactory.class );
    locator.addService ( TransporterFactory.class, HttpTransporterFactory.class );

    locator.setErrorHandler ( new ErrorHandler () {
        @Override
        public void serviceCreationFailed ( final Class<?> type, final Class<?> impl, final Throwable exception )
        {
            final Logger logger = LoggerFactory.getLogger ( impl );
            logger.warn ( "Service creation failed: " + type.getName (), exception );
        }
    } );

    return locator.getService ( RepositorySystem.class );
}
 
Example #3
Source File: DependencyResolver.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(ModelLocator.class).to(DefaultModelLocator.class).in(Singleton.class);
	bind(ModelReader.class).to(DefaultModelReader.class).in(Singleton.class);
	bind(ModelValidator.class).to(DefaultModelValidator.class).in(Singleton.class);
	bind(RepositoryConnectorFactory.class).to(BasicRepositoryConnectorFactory.class)
			.in(Singleton.class);
	bind(ArtifactDescriptorReader.class) //
			.to(DefaultArtifactDescriptorReader.class).in(Singleton.class);
	bind(VersionResolver.class) //
			.to(DefaultVersionResolver.class).in(Singleton.class);
	bind(VersionRangeResolver.class) //
			.to(DefaultVersionRangeResolver.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("snapshot")) //
			.to(SnapshotMetadataGeneratorFactory.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("versions")) //
			.to(VersionsMetadataGeneratorFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("http"))
			.to(HttpTransporterFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("file"))
			.to(FileTransporterFactory.class).in(Singleton.class);
}
 
Example #4
Source File: MavenUtil.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public static RepositorySystem newRepositorySystem ()
{
    final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator ();
    locator.addService ( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class );
    locator.addService ( TransporterFactory.class, FileTransporterFactory.class );
    locator.addService ( TransporterFactory.class, HttpTransporterFactory.class );

    locator.setErrorHandler ( new DefaultServiceLocator.ErrorHandler () {
        @Override
        public void serviceCreationFailed ( final Class<?> type, final Class<?> impl, final Throwable exception )
        {
            exception.printStackTrace ();
        }
    } );

    return locator.getService ( RepositorySystem.class );
}
 
Example #5
Source File: RemotePluginLoader.java    From digdag with Apache License 2.0 6 votes vote down vote up
private static RepositorySystem newRepositorySystem()
{
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    //locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
    //    @Override
    //    public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception)
    //    {
    //        exception.printStackTrace();
    //    }
    //});

    return locator.getService(RepositorySystem.class);
}
 
Example #6
Source File: MavenArtifactResolver.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
private RepositorySystem newRepositorySystem() {
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
	locator.addService(TransporterFactory.class, FileTransporterFactory.class);

	if (properties.isUseWagon()) {
		locator.addService(WagonProvider.class, StaticWagonProvider.class);
		locator.addService(WagonConfigurator.class, StaticWagonConfigurator.class);
		locator.addService(TransporterFactory.class, WagonTransporterFactory.class);
	} else {
		locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
	}

	locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
		@Override
		public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
			throw new RuntimeException(exception);
		}
	});
	return locator.getService(RepositorySystem.class);
}
 
Example #7
Source File: ManualRepositorySystemFactory.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
public static RepositorySystem newRepositorySystem()
{
/*
 * Aether's components implement org.eclipse.aether.spi.locator.Service to ease manual wiring and using the
 * prepopulated DefaultServiceLocator, we only need to register the repository connector and transporter
 * factories.
 */
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler()
    {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception)
        {
            exception.printStackTrace();
        }
    });

    return locator.getService(RepositorySystem.class);
}
 
Example #8
Source File: MavenUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static RepositorySystem newRepositorySystem() {
        /*
         * Aether's components implement
         * org.sonatype.aether.spi.locator.Service to ease manual wiring and
         * using the prepopulated DefaultServiceLocator, we only need to
         * register the repository connector factories.
         */

    DefaultServiceLocator locator = new DefaultServiceLocator();
    locator.addService(ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class);
    locator.addService(VersionResolver.class, DefaultVersionResolver.class);
    locator.addService(VersionRangeResolver.class, DefaultVersionRangeResolver.class);
    locator.addService(MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class);
    locator.addService(MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class);
    locator.setErrorHandler(new MyErrorHandler());

    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    //locator.addService(TransporterFactory.class, WagonTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);


    return locator.getService(RepositorySystem.class);
}
 
Example #9
Source File: AetherUtils.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private RepositorySystem getRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception)
        {
        	LOG.error("ServiceLocator failed", exception);
        }
    });

    return locator.getService(RepositorySystem.class);
}
 
Example #10
Source File: RemotePluginRepository.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
public static RepositorySystem newRepositorySystem() {
	/*
	 * Aether's components implement org.eclipse.aether.spi.locator.Service
	 * to ease manual wiring and using the prepopulated
	 * DefaultServiceLocator, we only need to register the repository
	 * connector and transporter factories.
	 */
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
	locator.addService(TransporterFactory.class, FileTransporterFactory.class);
	locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

	locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
		@Override
		public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
			exception.printStackTrace();
		}
	});

	return locator.getService(RepositorySystem.class);
}
 
Example #11
Source File: MavenPluginRepository.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
private RepositorySystem newRepositorySystem() {
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	
	locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
	locator.addService(TransporterFactory.class, FileTransporterFactory.class);
	locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

	locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
		@Override
		public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
			exception.printStackTrace();
		}
	});

	return locator.getService(RepositorySystem.class);
}
 
Example #12
Source File: AetherUtil.java    From vertx-deploy-tools with Apache License 2.0 6 votes vote down vote up
public static RepositorySystem newRepositorySystem() {
    /*
     * Aether's components implement org.eclipse.aether.spi.locator.Service to ease manual wiring and using the
     * prepopulated DefaultServiceLocator, we only need to register the repository connector and transporter
     * factories.
     */
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            LOG.error(exception.getMessage(), exception);
        }
    });
    return locator.getService(RepositorySystem.class);
}
 
Example #13
Source File: AetherUtil.java    From buck with Apache License 2.0 6 votes vote down vote up
public static ServiceLocator initServiceLocator() {
  DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
  locator.setErrorHandler(
      new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
          throw new RuntimeException(
              String.format(
                  "Failed to initialize service %s, implemented by %s: %s",
                  type.getName(), impl.getName(), exception.getMessage()),
              exception);
        }
      });
  locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
  locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
  locator.addService(TransporterFactory.class, FileTransporterFactory.class);
  // Use a no-op logger. Leaving this out would introduce a runtime dependency on log4j
  locator.addService(ILoggerFactory.class, NOPLoggerFactory.class);
  // Also requires log4j
  //    locator.addService(ILoggerFactory.class, Log4jLoggerFactory.class);
  return locator;
}
 
Example #14
Source File: ArtifactResolverTest.java    From revapi with Apache License 2.0 5 votes vote down vote up
public static RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            exception.printStackTrace();
        }
    });

    return locator.getService(RepositorySystem.class);
}
 
Example #15
Source File: Aether.java    From pro with GNU General Public License v3.0 5 votes vote down vote up
public static Aether create(Path mavenLocalRepository, List<URI> remoteRepositories) {
  // respository system
  var locator = MavenRepositorySystemUtils.newServiceLocator();
  locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
  locator.addService(TransporterFactory.class, FileTransporterFactory.class);
  locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

  locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
    @Override
    public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
      exception.printStackTrace();
    }
  });
  RepositorySystem system = locator.getService(RepositorySystem.class);

  // session
  var session = MavenRepositorySystemUtils.newSession();
  var localRepository = new LocalRepository(mavenLocalRepository.toString());
  session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepository));

  // central repository
  var central = new RemoteRepository.Builder("central", "default",
      "https://repo1.maven.org/maven2/").build();
  
  // remote repositories
  var remotes = Stream.concat(
        remoteRepositories.stream().map(uri -> new RemoteRepository.Builder(null, "default", uri.toString()).build()),
        Stream.of(central)
      )
      .collect(Collectors.toUnmodifiableList());
  
  return new Aether(system, session, remotes);
}
 
Example #16
Source File: AetherModule.java    From maven-repository-tools with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configure()
{
    install( new MavenResolverModule() );
    // alternatively, use the Guice Multibindings extensions
    bind( RepositoryConnectorFactory.class ).annotatedWith( Names.named( "basic" ) )
        .to( BasicRepositoryConnectorFactory.class );
    bind( TransporterFactory.class ).annotatedWith( Names.named( "file" ) ).to( FileTransporterFactory.class );
    bind( TransporterFactory.class ).annotatedWith( Names.named( "http" ) ).to( HttpTransporterFactory.class );
}
 
Example #17
Source File: ResolverImpl.java    From vertx-stack with Apache License 2.0 5 votes vote down vote up
private static DefaultServiceLocator getDefaultServiceLocator() {
  DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
  locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
  locator.addService(TransporterFactory.class, FileTransporterFactory.class);
  locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
  locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
    @Override
    public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
      LOGGER.error("Service creation failure: " + exception.getMessage(), exception);
    }
  });
  return locator;
}
 
Example #18
Source File: ModifiedClassPathRunner.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
private List<URL> resolveCoordinates(String[] coordinates) throws Exception {
	DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils
			.newServiceLocator();
	serviceLocator.addService(RepositoryConnectorFactory.class,
			BasicRepositoryConnectorFactory.class);
	serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class);
	RepositorySystem repositorySystem = serviceLocator
			.getService(RepositorySystem.class);
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	LocalRepository localRepository = new LocalRepository(
			System.getProperty("user.home") + "/.m2/repository");
	session.setLocalRepositoryManager(
			repositorySystem.newLocalRepositoryManager(session, localRepository));
	CollectRequest collectRequest = new CollectRequest(null,
			Arrays.asList(new RemoteRepository.Builder("central", "default",
					"https://repo.maven.apache.org/maven2").build()));

	collectRequest.setDependencies(createDependencies(coordinates));
	DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
	DependencyResult result = repositorySystem.resolveDependencies(session,
			dependencyRequest);
	List<URL> resolvedArtifacts = new ArrayList<>();
	for (ArtifactResult artifact : result.getArtifactResults()) {
		resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL());
	}
	return resolvedArtifacts;
}
 
Example #19
Source File: Maven.java    From bazel-deps with MIT License 5 votes vote down vote up
private static RepositorySystem newRepositorySystem() {
  DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
  locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
  locator.addService(TransporterFactory.class, FileTransporterFactory.class);
  locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

  locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
    @Override
    public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
      exception.printStackTrace();
    }
  });

  return locator.getService(RepositorySystem.class);
}
 
Example #20
Source File: ArtifactTransporter.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
private RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            throw new RuntimeException("Service creation failed", exception);
        }
    });

    return locator.getService(RepositorySystem.class);
}
 
Example #21
Source File: MavenResolverDependencyManagementVersionResolver.java    From initializr with Apache License 2.0 5 votes vote down vote up
private static ServiceLocator createServiceLocator() {
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	locator.addService(RepositorySystem.class, DefaultRepositorySystem.class);
	locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
	locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
	return locator;
}
 
Example #22
Source File: MavenArtifactResolver.java    From javafx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private RepositorySystem createRepositorySystem() {
    DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator();
    serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    serviceLocator.addService(TransporterFactory.class, FileTransporterFactory.class);
    serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    serviceLocator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            throw new RuntimeException(exception);
        }
    });
    return serviceLocator.getService(RepositorySystem.class);
}
 
Example #23
Source File: MavenInitializer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public static RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    return locator.getService(RepositorySystem.class);
}
 
Example #24
Source File: Utils.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static RepositorySystem getRepositorySystem() {

    DefaultServiceLocator locator =
            MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class,
            BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

    return locator.getService(RepositorySystem.class);
  }
 
Example #25
Source File: ArtifactDownload.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
private static RepositorySystem newRepositorySystem() {
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
	locator.addService(TransporterFactory.class, FileTransporterFactory.class);
	locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
	return locator.getService(RepositorySystem.class);

}
 
Example #26
Source File: Aether.java    From migration-tooling with Apache License 2.0 5 votes vote down vote up
static RepositorySystem newRepositorySystem() {
  DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
  locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
  locator.addService(TransporterFactory.class, FileTransporterFactory.class);
  locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
  return locator.getService(RepositorySystem.class);
}
 
Example #27
Source File: PluginAddCommand.java    From gyro with Apache License 2.0 5 votes vote down vote up
private boolean validate(String plugin) {
    try {
        DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();

        locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
        locator.addService(TransporterFactory.class, FileTransporterFactory.class);
        locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

        RepositorySystem system = locator.getService(RepositorySystem.class);
        DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
        String localDir = Paths.get(System.getProperty("user.home"), ".m2", "repository").toString();
        LocalRepository local = new LocalRepository(localDir);
        LocalRepositoryManager manager = system.newLocalRepositoryManager(session, local);

        session.setLocalRepositoryManager(manager);

        Artifact artifact = new DefaultArtifact(plugin);
        Dependency dependency = new Dependency(artifact, JavaScopes.RUNTIME);
        DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
        CollectRequest collectRequest = new CollectRequest(dependency, repositories);
        DependencyRequest request = new DependencyRequest(collectRequest, filter);
        system.resolveDependencies(session, request);

        return true;
    } catch (DependencyResolutionException e) {
        GyroCore.ui().write("@|bold %s|@ was not installed for the following reason(s):\n", plugin);

        for (Exception ex : e.getResult().getCollectExceptions()) {
            GyroCore.ui().write("   @|red %s|@\n", ex.getMessage());
        }

        GyroCore.ui().write("\n");

        return false;
    }
}
 
Example #28
Source File: RepositoryUtility.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new system configured for file and HTTP repository resolution.
 */
public static RepositorySystem newRepositorySystem() {
  DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
  locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
  locator.addService(TransporterFactory.class, FileTransporterFactory.class);
  locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

  return locator.getService(RepositorySystem.class);
}
 
Example #29
Source File: Util.java    From galleon with Apache License 2.0 5 votes vote down vote up
public static RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    return locator.getService(RepositorySystem.class);
}
 
Example #30
Source File: LibertyFeatureVersionIT.java    From boost with Eclipse Public License 1.0 5 votes vote down vote up
private RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    return locator.getService(RepositorySystem.class);
}