use of org.jboss.shrinkwrap.resolver.api.maven.repository.MavenRemoteRepository in project component-runtime by Talend.
the class Dependencies method findRepositories.
private static List<MavenRemoteRepository> findRepositories() {
final List<MavenRemoteRepository> repositories = new ArrayList<>();
final String repos = System.getProperty("talend.component.junit.maven.repositories");
if (repos != null && !repos.isEmpty()) {
for (final String repo : repos.split(",")) {
final String[] parts = repo.split("::");
final MavenRemoteRepository repository = MavenRemoteRepositories.createRemoteRepository(parts.length == 1 ? "repo_" + parts[0].replace(':', '_').replace('/', '_') : parts[0], parts.length == 1 ? parts[0] : parts[1], parts.length < 3 ? "default" : parts[2]);
repository.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_DAILY);
repository.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
repositories.add(repository);
}
} else if (!Boolean.getBoolean("talend.component.junit.maven.skipPomReading")) {
// try to grab from the root pom the repos - simplifying maven parsing for speed reasons and enough
// generally
File current = new File(".").getAbsoluteFile();
while (new File(current, "pom.xml").exists()) {
final File parent = current.getParentFile();
if (parent != null && new File(parent, "pom.xml").exists()) {
current = parent;
continue;
}
break;
}
final File pom = new File(current, "pom.xml");
if (pom.exists()) {
final PomEquippedResolveStage localPom = Maven.configureResolver().loadPomFromFile(pom);
final MavenWorkingSession mavenWorkingSession = PomEquippedResolveStageBaseImpl.class.cast(localPom).getMavenWorkingSession();
try {
final Field remoteRepositories = mavenWorkingSession.getClass().getDeclaredField("remoteRepositories");
if (!remoteRepositories.isAccessible()) {
remoteRepositories.setAccessible(true);
}
final List<RemoteRepository> pomRepos = List.class.cast(remoteRepositories.get(mavenWorkingSession));
if (pomRepos != null && !pomRepos.isEmpty()) {
pomRepos.forEach(r -> {
final MavenRemoteRepository repository = MavenRemoteRepositories.createRemoteRepository(r.getId(), r.getUrl(), "default");
repository.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_DAILY);
repository.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
repositories.add(repository);
});
}
} catch (final Exception e) {
throw new IllegalStateException("Check your shrinkwrap maven version", e);
}
}
}
if (!Boolean.getBoolean("talend.component.junit.maven.central.skip")) {
final MavenRemoteRepository central = MavenRemoteRepositories.createRemoteRepository("central_test_default", "http://repo.maven.apache.org/maven2/", "default");
central.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_WARN);
central.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);
repositories.add(central);
}
return repositories;
}
use of org.jboss.shrinkwrap.resolver.api.maven.repository.MavenRemoteRepository in project wildfly-swarm by wildfly-swarm.
the class ShrinkwrapArtifactResolvingHelper method defaultInstance.
public static ShrinkwrapArtifactResolvingHelper defaultInstance() {
return INSTANCE.updateAndGet(e -> {
if (e != null) {
return e;
}
MavenRemoteRepository jbossPublic = MavenRemoteRepositories.createRemoteRepository("jboss-public-repository-group", "https://repository.jboss.org/nexus/content/groups/public/", "default");
jbossPublic.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
jbossPublic.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);
MavenRemoteRepository gradleTools = MavenRemoteRepositories.createRemoteRepository("gradle", "http://repo.gradle.org/gradle/libs-releases-local", "default");
gradleTools.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
gradleTools.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);
Boolean offline = Boolean.valueOf(System.getProperty("swarm.resolver.offline", "false"));
final ConfigurableMavenResolverSystem resolver = Maven.configureResolver().withMavenCentralRepo(true).withRemoteRepo(jbossPublic).withRemoteRepo(gradleTools).workOffline(offline);
final String additionalRepos = System.getProperty(SwarmInternalProperties.BUILD_REPOS);
if (additionalRepos != null) {
Arrays.asList(additionalRepos.split(",")).forEach(r -> {
MavenRemoteRepository repo = MavenRemoteRepositories.createRemoteRepository(r, r, "default");
repo.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
repo.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);
resolver.withRemoteRepo(repo);
});
}
ShrinkwrapArtifactResolvingHelper helper = new ShrinkwrapArtifactResolvingHelper(resolver);
helper.session().setCache(new SimpleRepositoryCache());
helper.session().setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_DAILY);
helper.session().setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
return helper;
});
}
Aggregations