use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class Maven2ServerIndexerImpl method addArtifact.
public MavenId addArtifact(int indexId, File artifactFile) throws MavenServerIndexerException {
try {
IndexingContext index = getIndex(indexId);
ArtifactContext artifactContext = myArtifactContextProducer.getArtifactContext(index, artifactFile);
if (artifactContext == null)
return null;
addArtifact(myIndexer, index, artifactContext);
org.sonatype.nexus.index.ArtifactInfo a = artifactContext.getArtifactInfo();
return new MavenId(a.groupId, a.artifactId, a.version);
} catch (Exception e) {
throw new MavenServerIndexerException(wrapException(e));
}
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class Maven3ServerIndexerImpl method processArtifacts.
@Override
public void processArtifacts(int indexId, MavenServerIndicesProcessor processor) throws RemoteException, MavenServerIndexerException {
try {
final int CHUNK_SIZE = 10000;
IndexReader r = getIndex(indexId).getIndexReader();
int total = r.numDocs();
List<MavenId> result = new ArrayList<MavenId>(Math.min(CHUNK_SIZE, total));
for (int i = 0; i < total; i++) {
if (r.isDeleted(i))
continue;
Document doc = r.document(i);
String uinfo = doc.get(SEARCH_TERM_COORDINATES);
if (uinfo == null)
continue;
List<String> parts = StringUtil.split(uinfo, "|");
String groupId = parts.get(0);
String artifactId = parts.get(1);
String version = parts.get(2);
if (groupId == null || artifactId == null || version == null)
continue;
result.add(new MavenId(groupId, artifactId, version));
if (result.size() == CHUNK_SIZE) {
processor.processArtifacts(result);
result.clear();
}
}
if (!result.isEmpty()) {
processor.processArtifacts(result);
}
} catch (Exception e) {
throw new MavenServerIndexerException(wrapException(e));
}
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class CustomMaven3RepositoryMetadataManager method resolve.
@Override
public void resolve(RepositoryMetadata metadata, RepositoryRequest request) throws RepositoryMetadataResolutionException {
super.resolve(metadata, request);
MavenWorkspaceMap map = myWorkspaceMap;
if (map == null)
return;
Metadata data = metadata.getMetadata();
Versioning versioning = data.getVersioning();
if (versioning == null) {
data.setVersioning(versioning = new Versioning());
}
for (MavenId each : map.getAvailableIds()) {
if (each.equals(data.getGroupId(), data.getArtifactId())) {
versioning.addVersion(each.getVersion());
}
}
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testDependencyWithUnresolvedParent.
public void _testDependencyWithUnresolvedParent() throws Exception {
File repo = new File(myDir, "/repo");
setRepositoryPath(repo.getPath());
initEmbedder();
VirtualFile m = createModulePom("foo-parent", "<groupId>test</groupId>" + "<artifactId>foo-parent</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
myEmbedder.execute(m, Collections.<String>emptyList(), Collections.<String>emptyList(), Arrays.asList("install"));
myEmbedder.reset();
File fooParentFile = new File(repo, "test/foo-parent/1/foo-parent-1.pom");
assertTrue(fooParentFile.exists());
m = createModulePom("foo", "<artifactId>foo</artifactId>" + "<version>1</version>" + "<parent>" + " <groupId>test</groupId>" + " <artifactId>foo-parent</artifactId>" + " <version>1</version>" + "</parent>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
myEmbedder.execute(m, Collections.<String>emptyList(), Collections.<String>emptyList(), Arrays.asList("install"));
myEmbedder.reset();
assertTrue(new File(repo, "test/foo/1/foo-1.pom").exists());
FileUtil.delete(fooParentFile);
// reset all caches
initEmbedder();
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>test</groupId>" + " <artifactId>foo</artifactId>" + " <version>1</version>" + " </dependency>" + "</dependencies>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
MavenServerExecutionResult result = myEmbedder.resolveProject(myProjectPom, Collections.<String>emptyList(), Collections.<String>emptyList());
assertNotNull(result.projectData);
assertOrderedElementsAreEqual(result.unresolvedArtifacts, new MavenId("test", "foo-parent", "1"));
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testUnresolvedSystemArtifacts.
public void _testUnresolvedSystemArtifacts() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>fff</groupId>" + " <artifactId>zzz</artifactId>" + " <version>666</version>" + " <scope>system</scope>" + " <systemPath>" + myProjectRoot.getPath() + "/foo.jar</systemPath>" + " </dependency>" + "</dependencies>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
MavenServerExecutionResult result = myEmbedder.resolveProject(myProjectPom, Collections.<String>emptyList(), Collections.<String>emptyList());
assertNotNull(result.projectData);
assertOrderedElementsAreEqual(result.unresolvedArtifacts, new MavenId("fff", "zzz", "666"));
}
Aggregations