use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenModuleBuilderTest method testCreatingFromArchetype.
public void testCreatingFromArchetype() throws Exception {
if (!hasMavenInstallation())
return;
setArchetype(new MavenArchetype("org.apache.maven.archetypes", "maven-archetype-quickstart", "1.0", null, null));
MavenId id = new MavenId("org.foo", "module", "1.0");
createNewModule(id);
List<MavenProject> projects = MavenProjectsManager.getInstance(myProject).getProjects();
assertEquals(1, projects.size());
MavenProject project = projects.get(0);
assertEquals(id, project.getMavenId());
assertNotNull(myProjectRoot.findFileByRelativePath("src/main/java/org/foo/App.java"));
assertNotNull(myProjectRoot.findFileByRelativePath("src/test/java/org/foo/AppTest.java"));
assertSources("module", "src/main/java");
assertTestSources("module", "src/test/java");
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class Maven3ServerIndexerImpl method addArtifact.
@Override
public MavenId addArtifact(int indexId, File artifactFile) throws RemoteException, 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 Maven2ServerIndexerImpl method processArtifacts.
public void processArtifacts(int indexId, MavenServerIndicesProcessor processor) throws 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 MavenServerEmbedderTest method _testUnresolvedArtifacts.
public void _testUnresolvedArtifacts() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>fff</groupId>" + " <artifactId>zzz</artifactId>" + " <version>666</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("fff", "zzz", "666"));
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testUnresolvedSystemArtifactsWithoutPath.
public void _testUnresolvedSystemArtifactsWithoutPath() throws Exception {
// need to repair model before resolving
if (ignore())
return;
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>fff</groupId>" + " <artifactId>zzz</artifactId>" + " <version>666</version>" + " <scope>system</scope>" + " </dependency>" + "</dependencies>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
MavenServerExecutionResult result = myEmbedder.resolveProject(myProjectPom, Collections.<String>emptyList(), Collections.<String>emptyList());
assertNotNull(result);
assertOrderedElementsAreEqual(result.unresolvedArtifacts, new MavenId("fff", "zzz", "666"));
}
Aggregations