use of org.eclipse.aether.RepositorySystem in project spf4j by zolyfarkas.
the class MavenRepositoryUtils method resolveArtifactAndDependencies.
public static Set<File> resolveArtifactAndDependencies(final List<RemoteRepository> repos, final File localRepo, final String scope, final String groupId, final String artifactId, final String classifier, final String extension, final String versionExpr) throws DependencyResolutionException {
RepositorySystem repositorySystem = getRepositorySystem();
RepositorySystemSession session = getRepositorySystemSession(repositorySystem, localRepo);
return resolveArtifactAndDependencies(scope, groupId, artifactId, classifier, extension, versionExpr, repos, repositorySystem, session);
}
use of org.eclipse.aether.RepositorySystem in project liferay-ide by liferay.
the class LiferayMavenProjectProvider method getData.
@Override
public <T> List<T> getData(String key, Class<T> type, Object... params) {
List<T> retval = null;
if ("profileIds".equals(key)) {
List<T> profileIds = new ArrayList<>();
try {
IMaven maven = MavenPlugin.getMaven();
List<Profile> profiles = maven.getSettings().getProfiles();
for (Profile profile : profiles) {
if (profile.getActivation() != null) {
if (profile.getActivation().isActiveByDefault()) {
continue;
}
}
profileIds.add(type.cast(profile.getId()));
}
if ((params[0] != null) && params[0] instanceof File) {
File locationDir = (File) params[0];
File pomFile = new File(locationDir, IMavenConstants.POM_FILE_NAME);
if (FileUtil.notExists(pomFile) && FileUtil.exists(locationDir.getParentFile())) {
// try one level up for when user is adding new module
pomFile = new File(locationDir.getParentFile(), IMavenConstants.POM_FILE_NAME);
}
if (FileUtil.exists(pomFile)) {
Model model = maven.readModel(pomFile);
File parentDir = pomFile.getParentFile();
while (model != null) {
for (org.apache.maven.model.Profile p : model.getProfiles()) {
profileIds.add(type.cast(p.getId()));
}
parentDir = parentDir.getParentFile();
if (FileUtil.exists(parentDir)) {
try {
model = maven.readModel(new File(parentDir, IMavenConstants.POM_FILE_NAME));
} catch (Exception e) {
model = null;
}
}
}
}
}
} catch (CoreException ce) {
LiferayMavenCore.logError(ce);
}
retval = profileIds;
} else if ("liferayVersions".equals(key)) {
List<T> possibleVersions = new ArrayList<>();
RepositorySystem system = AetherUtil.newRepositorySystem();
RepositorySystemSession session = AetherUtil.newRepositorySystemSession(system);
String groupId = params[0].toString();
String artifactId = params[1].toString();
String coords = groupId + ":" + artifactId + ":[6,)";
Artifact artifact = new DefaultArtifact(coords);
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
rangeRequest.addRepository(AetherUtil.newCentralRepository());
rangeRequest.addRepository(AetherUtil.newLiferayRepository());
try {
VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
List<Version> versions = rangeResult.getVersions();
for (Version version : versions) {
String val = version.toString();
if (!"6.2.0".equals(val) && !val.contains("7.0.0")) {
possibleVersions.add(type.cast(val));
}
}
retval = possibleVersions;
} catch (VersionRangeResolutionException vrre) {
}
} else if ("parentVersion".equals(key)) {
List<T> version = new ArrayList<>();
File locationDir = (File) params[0];
File parentPom = new File(locationDir, IMavenConstants.POM_FILE_NAME);
if (FileUtil.exists(parentPom)) {
try {
IMaven maven = MavenPlugin.getMaven();
Model model = maven.readModel(parentPom);
version.add(type.cast(model.getVersion()));
retval = version;
} catch (CoreException ce) {
LiferayMavenCore.logError("unable to get parent version", ce);
}
}
} else if ("parentGroupId".equals(key)) {
List<T> groupId = new ArrayList<>();
File locationDir = (File) params[0];
File parentPom = new File(locationDir, IMavenConstants.POM_FILE_NAME);
if (FileUtil.exists(parentPom)) {
try {
IMaven maven = MavenPlugin.getMaven();
Model model = maven.readModel(parentPom);
groupId.add(type.cast(model.getGroupId()));
retval = groupId;
} catch (CoreException ce) {
LiferayMavenCore.logError("unable to get parent groupId", ce);
}
}
} else if ("archetypeGAV".equals(key)) {
String frameworkType = (String) params[0];
String value = LiferayMavenCore.getPreferenceString("archetype-gav-" + frameworkType, "");
retval = Collections.singletonList(type.cast(value));
}
return retval;
}
use of org.eclipse.aether.RepositorySystem in project ceylon by eclipse.
the class Bug2414 method bug.
public static void bug(Artifact jarArtifact) {
// locator.getService(RepositorySystem.class);
final RepositorySystem system = null;
// MavenRepositorySystemUtils.newSession();
final DefaultRepositorySystemSession session = null;
ModuleCopycat copycat = new ModuleCopycat(rmb.buildManager(), new RepositoryManager() {
@Override
public void putArtifact(ArtifactContext artifactContext, File file) throws RepositoryException {
try {
InstallRequest installRequest = new InstallRequest();
installRequest.addArtifact(jarArtifact);
InstallResult result = system.install(session, installRequest);
} catch (InstallationException e) {
throw new RepositoryException(e);
}
}
});
}
use of org.eclipse.aether.RepositorySystem in project launcher by runelite.
the class ArtifactResolver method resolveArtifacts.
public List<ArtifactResult> resolveArtifacts(Artifact artifact) throws DependencyResolutionException {
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
collectRequest.setRepositories(repositories);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);
List<ArtifactResult> results = system.resolveDependencies(session, dependencyRequest).getArtifactResults();
// check to see if they're from the right repository
validate(results);
return results;
}
use of org.eclipse.aether.RepositorySystem in project mule by mulesoft.
the class RepositoryServiceFactory method createRepositoryService.
public RepositoryService createRepositoryService() {
RepositorySystem repositorySystem = new SpiRepositorySystemFactory().createRepositorySystem();
File repositoryFolder = createRepositoryFolderIfDoesNotExists();
List<RemoteRepository> remoteRepositories = collectRemoteRepositories();
DefaultRepositorySystemSession repositorySystemSession = new DefaultRepositorySystemSession();
repositorySystemSession.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(repositorySystemSession, new LocalRepository(repositoryFolder)));
return new DefaultRepositoryService(repositorySystem, repositorySystemSession, remoteRepositories);
}
Aggregations