use of org.eclipse.aether.repository.LocalRepository in project spring-boot by spring-projects.
the class ModifiedClassPathClassLoader method resolveCoordinates.
private static List<URL> resolveCoordinates(String[] coordinates) {
Exception latestFailure = null;
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");
RemoteRepository remoteRepository = new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build();
session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepository));
for (int i = 0; i < MAX_RESOLUTION_ATTEMPTS; i++) {
CollectRequest collectRequest = new CollectRequest(null, Arrays.asList(remoteRepository));
collectRequest.setDependencies(createDependencies(coordinates));
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
try {
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;
} catch (Exception ex) {
latestFailure = ex;
}
}
throw new IllegalStateException("Resolution failed after " + MAX_RESOLUTION_ATTEMPTS + " attempts", latestFailure);
}
use of org.eclipse.aether.repository.LocalRepository in project spring-boot by spring-projects.
the class SettingsXmlRepositorySystemSessionAutoConfigurationTests method propertyInterpolation.
@Test
void propertyInterpolation() {
final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
given(this.repositorySystem.newLocalRepositoryManager(eq(session), any(LocalRepository.class))).willAnswer((invocation) -> {
LocalRepository localRepository = invocation.getArgument(1);
return new SimpleLocalRepositoryManagerFactory().newInstance(session, localRepository);
});
TestPropertyValues.of("user.home:src/test/resources/maven-settings/property-interpolation", "foo:bar").applyToSystemProperties(() -> {
new SettingsXmlRepositorySystemSessionAutoConfiguration().apply(session, SettingsXmlRepositorySystemSessionAutoConfigurationTests.this.repositorySystem);
return null;
});
assertThat(session.getLocalRepository().getBasedir().getAbsolutePath()).endsWith(File.separatorChar + "bar" + File.separatorChar + "repository");
}
use of org.eclipse.aether.repository.LocalRepository in project zeppelin by apache.
the class Booter method newRepositorySystemSession.
public static RepositorySystemSession newRepositorySystemSession(RepositorySystem system, String localRepoPath) {
Validate.notNull(localRepoPath, "localRepoPath should have a value");
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository(resolveLocalRepoPath(localRepoPath));
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
if (LOGGER.isDebugEnabled()) {
session.setTransferListener(new TransferListener());
session.setRepositoryListener(new RepositoryListener());
}
return session;
}
use of org.eclipse.aether.repository.LocalRepository in project drools by kiegroup.
the class MavenRepository method removeLocalArtifact.
/**
* Utility method specifically suggested for testing purposes only.
*/
public void removeLocalArtifact(ReleaseId releaseId) {
// Taken by analogy of build-helper-maven-plugin
Artifact artifact = new DefaultArtifact(releaseId.getGroupId(), releaseId.getArtifactId(), null, releaseId.getVersion());
LocalRepository localRepo = new LocalRepository(getMavenRepositoryConfiguration().getLocalRepository());
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepositoryManager localRepositoryManager = aether.getSystem().newLocalRepositoryManager(session, localRepo);
session.setLocalRepositoryManager(localRepositoryManager);
session.setOffline(true);
String pathForLocalArtifact = localRepositoryManager.getPathForLocalArtifact(artifact);
File localArtifactDir = // File .jar
new File(localRepo.getBasedir(), pathForLocalArtifact).getParentFile();
if (!localArtifactDir.exists()) {
log.warn("The expected local maven repo dir for {} does not exist {}, nothing to delete.", releaseId, localArtifactDir);
return;
}
log.info("Erasing directory from local maven repository {}", localArtifactDir);
try {
FileUtils.deleteDirectory(localArtifactDir);
} catch (Exception e) {
log.error("Error while trying to erase directory from local maven repository {}", localArtifactDir);
}
}
use of org.eclipse.aether.repository.LocalRepository in project drools by kiegroup.
the class Aether method newRepositorySystemSession.
private RepositorySystemSession newRepositorySystemSession(Settings settings, RepositorySystem system) {
LocalRepository localRepo = new LocalRepository(localRepoDir);
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
session.setOffline(offline);
configureProxiesOnSession(settings, session);
configureHttpHeadersOnSession(settings, session);
return session;
}
Aggregations