use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ClasspathEntryHelper method setClasspathEntry.
//Copied from org.eclipse.m2e.jdt.internal.ClasspathEntryDescriptor
private void setClasspathEntry(IClasspathEntry entry) {
this.kind = entry.getEntryKind();
this.path = entry.getPath();
this.exported = entry.isExported();
this.outputLocation = entry.getOutputLocation();
this.accessRules = new ArrayList<>();
for (IAccessRule rule : entry.getAccessRules()) {
this.accessRules.add(rule);
}
this.attributes = new HashMap<>();
for (IClasspathAttribute attribute : entry.getExtraAttributes()) {
attributes.put(attribute.getName(), attribute.getValue());
}
this.sourcePath = entry.getSourceAttachmentPath();
this.sourceRootPath = entry.getSourceAttachmentRootPath();
setInclusionPatterns(entry.getInclusionPatterns());
setExclusionPatterns(entry.getExclusionPatterns());
this.combineAccessRules = entry.combineAccessRules();
String groupId = attributes.get(ClasspathManager.GROUP_ID_ATTRIBUTE);
String artifactId = attributes.get(ClasspathManager.ARTIFACT_ID_ATTRIBUTE);
String version = attributes.get(ClasspathManager.VERSION_ATTRIBUTE);
String packaging = attributes.get(ClasspathManager.PACKAGING_ATTRIBUTE);
String classifier = attributes.get(ClasspathManager.CLASSIFIER_ATTRIBUTE);
if (groupId != null && artifactId != null && version != null) {
this.artifactKey = new MavenArtifactKey(groupId, artifactId, version, packaging, classifier);
}
}
use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ClasspathManager method getArtifactKey.
private MavenArtifactKey getArtifactKey(IClasspathEntry classpathEntry) {
IClasspathAttribute[] attributes = classpathEntry.getExtraAttributes();
String groupId = null;
String artifactId = null;
String version = null;
String packaging = null;
String classifier = null;
for (IClasspathAttribute attribute : attributes) {
if (ClasspathManager.GROUP_ID_ATTRIBUTE.equals(attribute.getName())) {
groupId = attribute.getValue();
} else if (ClasspathManager.ARTIFACT_ID_ATTRIBUTE.equals(attribute.getName())) {
artifactId = attribute.getValue();
} else if (ClasspathManager.VERSION_ATTRIBUTE.equals(attribute.getName())) {
version = attribute.getValue();
} else if (ClasspathManager.PACKAGING_ATTRIBUTE.equals(attribute.getName())) {
packaging = attribute.getValue();
} else if (ClasspathManager.CLASSIFIER_ATTRIBUTE.equals(attribute.getName())) {
classifier = attribute.getValue();
}
}
if (groupId != null && artifactId != null && version != null) {
return new MavenArtifactKey(groupId, artifactId, version, packaging, classifier);
}
return null;
}
use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ClasspathManager method getClasspath.
private IClasspathEntry[] getClasspath(MavenProject mavenProject) {
ClasspathHelper helper = new ClasspathHelper(true);
List<MavenArtifact> dependencies = mavenProject.getDependencies();
for (MavenArtifact dependency : dependencies) {
File file = dependency.getFile();
if (file == null) {
continue;
}
ClasspathEntryHelper entry;
if (file.getPath().endsWith("pom.xml")) {
String path = file.getParentFile().getPath();
entry = helper.addProjectEntry(new Path(path.substring(workspacePath.length())));
} else {
entry = helper.addLibraryEntry(new Path(file.getPath()));
}
if (entry != null) {
MavenArtifactKey artifactKey = new MavenArtifactKey(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getExtension(), dependency.getClassifier());
entry.setArtifactKey(artifactKey);
attachSources(entry);
}
}
return helper.getEntries();
}
use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ProjectResolverTest method testResolveArtifact.
@Test
public void testResolveArtifact() throws Exception {
MavenArtifactKey artifactKey = new MavenArtifactKey("junit", "junit", "3.7", "jar", "");
MavenArtifact artifact = mavenServer.resolveArtifact(artifactKey, Collections.emptyList());
assertNotNull(artifact);
assertTrue(artifact.isResolved());
}
use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ProjectResolverTest method testResolveNotExistingArtifact.
@Test
public void testResolveNotExistingArtifact() throws Exception {
MavenArtifactKey artifactKey = new MavenArtifactKey("junit", "junit", "3.56", "jar", "");
MavenArtifact artifact = mavenServer.resolveArtifact(artifactKey, Collections.emptyList());
assertNotNull(artifact);
assertFalse(artifact.isResolved());
}
Aggregations