use of org.apache.maven.artifact.Artifact in project intellij-community by JetBrains.
the class Maven30AetherModelConverter method convertAetherDependencyNodes.
public static List<MavenArtifactNode> convertAetherDependencyNodes(MavenArtifactNode parent, Collection<DependencyNode> nodes, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) {
List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
for (DependencyNode each : nodes) {
Artifact a = RepositoryUtils.toArtifact(each.getDependency().getArtifact());
MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);
Map<?, ?> data = each.getData();
//String premanagedVersion = DependencyManagerUtils.getPremanagedVersion(each);
//String premanagedScope = DependencyManagerUtils.getPremanagedScope(each);
//Object winner = data.get(ConflictResolver.NODE_DATA_WINNER);
//if(winner instanceof DependencyNode) {
// DependencyNode winnerNode = (DependencyNode)winner;
// if(!StringUtil.equals(each.getVersion().toString(), winnerNode.getVersion().toString())) {
// state = MavenArtifactState.CONFLICT;
// Artifact winnerArtifact = RepositoryUtils.toArtifact(winnerNode.getDependency().getArtifact());
// relatedArtifact = convertArtifact(winnerArtifact, nativeToConvertedMap, localRepository);
// }
//}
//
MavenArtifactNode newNode = new MavenArtifactNode(parent, ma, MavenArtifactState.ADDED, null, each.getDependency().getScope(), each.getPremanagedVersion(), each.getPremanagedScope());
newNode.setDependencies(convertAetherDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
result.add(newNode);
}
return result;
}
use of org.apache.maven.artifact.Artifact in project intellij-community by JetBrains.
the class Maven2ModelConverter method convertDependencyNodes.
public static List<MavenArtifactNode> convertDependencyNodes(MavenArtifactNode parent, Collection<DependencyNode> nodes, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) {
List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
for (DependencyNode each : nodes) {
Artifact a = each.getArtifact();
MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);
MavenArtifactState state = MavenArtifactState.ADDED;
switch(each.getState()) {
case DependencyNode.INCLUDED:
break;
case DependencyNode.OMITTED_FOR_CONFLICT:
state = MavenArtifactState.CONFLICT;
break;
case DependencyNode.OMITTED_FOR_DUPLICATE:
state = MavenArtifactState.DUPLICATE;
break;
case DependencyNode.OMITTED_FOR_CYCLE:
state = MavenArtifactState.CYCLE;
break;
default:
assert false : "unknown dependency node state: " + each.getState();
}
MavenArtifact relatedMA = each.getRelatedArtifact() == null ? null : convertArtifact(each.getRelatedArtifact(), nativeToConvertedMap, localRepository);
MavenArtifactNode newNode = new MavenArtifactNode(parent, ma, state, relatedMA, each.getOriginalScope(), each.getPremanagedVersion(), each.getPremanagedScope());
newNode.setDependencies(convertDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
result.add(newNode);
}
return result;
}
use of org.apache.maven.artifact.Artifact in project intellij-community by JetBrains.
the class Maven3ServerEmbedderImpl method resolveTransitively.
@NotNull
@Override
public List<MavenArtifact> resolveTransitively(@NotNull List<MavenArtifactInfo> artifacts, @NotNull List<MavenRemoteRepository> remoteRepositories) throws RemoteException, MavenServerProcessCanceledException {
try {
Set<Artifact> toResolve = new LinkedHashSet<Artifact>();
for (MavenArtifactInfo each : artifacts) {
toResolve.add(createArtifact(each));
}
Artifact project = getComponent(ArtifactFactory.class).createBuildArtifact("temp", "temp", "666", "pom");
Set<Artifact> res = getComponent(ArtifactResolver.class).resolveTransitively(toResolve, project, Collections.EMPTY_MAP, myLocalRepository, convertRepositories(remoteRepositories), getComponent(ArtifactMetadataSource.class)).getArtifacts();
return MavenModelConverter.convertArtifacts(res, new THashMap<Artifact, MavenArtifact>(), getLocalRepositoryFile());
} catch (ArtifactResolutionException e) {
Maven3ServerGlobals.getLogger().info(e);
} catch (ArtifactNotFoundException e) {
Maven3ServerGlobals.getLogger().info(e);
} catch (Exception e) {
throw rethrowException(e);
}
return Collections.emptyList();
}
use of org.apache.maven.artifact.Artifact in project intellij-community by JetBrains.
the class MavenModelConverter method convertDependencyNodes.
public static List<MavenArtifactNode> convertDependencyNodes(MavenArtifactNode parent, Collection<DependencyNode> nodes, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) {
List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
for (DependencyNode each : nodes) {
Artifact a = each.getArtifact();
MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);
MavenArtifactState state = MavenArtifactState.ADDED;
switch(each.getState()) {
case DependencyNode.INCLUDED:
break;
case DependencyNode.OMITTED_FOR_CONFLICT:
state = MavenArtifactState.CONFLICT;
break;
case DependencyNode.OMITTED_FOR_DUPLICATE:
state = MavenArtifactState.DUPLICATE;
break;
case DependencyNode.OMITTED_FOR_CYCLE:
state = MavenArtifactState.CYCLE;
break;
default:
assert false : "unknown dependency node state: " + each.getState();
}
MavenArtifact relatedMA = each.getRelatedArtifact() == null ? null : convertArtifact(each.getRelatedArtifact(), nativeToConvertedMap, localRepository);
MavenArtifactNode newNode = new MavenArtifactNode(parent, ma, state, relatedMA, each.getOriginalScope(), each.getPremanagedVersion(), each.getPremanagedScope());
newNode.setDependencies(convertDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
result.add(newNode);
}
return result;
}
use of org.apache.maven.artifact.Artifact in project intellij-community by JetBrains.
the class Maven3AetherModelConverter method convertAetherDependencyNodes.
public static List<MavenArtifactNode> convertAetherDependencyNodes(MavenArtifactNode parent, Collection<DependencyNode> nodes, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) {
List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
for (DependencyNode each : nodes) {
Artifact a = toArtifact(each.getDependency());
MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);
Map<?, ?> data = each.getData();
String premanagedVersion = DependencyManagerUtils.getPremanagedVersion(each);
String premanagedScope = DependencyManagerUtils.getPremanagedScope(each);
MavenArtifactState state = MavenArtifactState.ADDED;
MavenArtifact relatedArtifact = null;
String scope = each.getDependency().getScope();
Object winner = data.get(ConflictResolver.NODE_DATA_WINNER);
if (winner instanceof DependencyNode) {
DependencyNode winnerNode = (DependencyNode) winner;
scope = winnerNode.getDependency().getScope();
Artifact winnerArtifact = toArtifact(winnerNode.getDependency());
relatedArtifact = convertArtifact(winnerArtifact, nativeToConvertedMap, localRepository);
nativeToConvertedMap.put(a, relatedArtifact);
if (!StringUtil.equals(each.getVersion().toString(), winnerNode.getVersion().toString())) {
state = MavenArtifactState.CONFLICT;
} else {
state = MavenArtifactState.DUPLICATE;
}
}
ma.setScope(scope);
MavenArtifactNode newNode = new MavenArtifactNode(parent, ma, state, relatedArtifact, each.getDependency().getScope(), premanagedVersion, premanagedScope);
newNode.setDependencies(convertAetherDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
result.add(newNode);
}
return result;
}
Aggregations