use of org.jetbrains.idea.maven.model.MavenArchetype in project intellij-community by JetBrains.
the class MavenIndicesManagerTest method assertArchetypeExists.
private void assertArchetypeExists(String archetypeId) {
Set<MavenArchetype> achetypes = myIndicesFixture.getIndicesManager().getArchetypes();
List<String> actualNames = new ArrayList<>();
for (MavenArchetype each : achetypes) {
actualNames.add(each.groupId + ":" + each.artifactId + ":" + each.version);
}
assertTrue(actualNames.toString(), actualNames.contains(archetypeId));
}
use of org.jetbrains.idea.maven.model.MavenArchetype 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.MavenArchetype in project intellij-community by JetBrains.
the class MavenArchetypesStep method updateArchetypeDescription.
private void updateArchetypeDescription() {
MavenArchetype sel = getSelectedArchetype();
String desc = sel == null ? null : sel.description;
if (StringUtil.isEmptyOrSpaces(desc)) {
myArchetypeDescriptionScrollPane.setVisible(false);
} else {
myArchetypeDescriptionScrollPane.setVisible(true);
myArchetypeDescriptionField.setText(desc);
}
}
use of org.jetbrains.idea.maven.model.MavenArchetype in project intellij-community by JetBrains.
the class MavenArchetypesStep method doAddArchetype.
private void doAddArchetype() {
MavenAddArchetypeDialog dialog = new MavenAddArchetypeDialog(myMainPanel);
if (!dialog.showAndGet()) {
return;
}
MavenArchetype archetype = dialog.getArchetype();
MavenIndicesManager.getInstance().addArchetype(archetype);
updateArchetypesList(archetype);
}
use of org.jetbrains.idea.maven.model.MavenArchetype in project intellij-community by JetBrains.
the class MavenArchetypesStep method groupAndSortArchetypes.
private static TreeNode groupAndSortArchetypes(Set<MavenArchetype> archetypes) {
List<MavenArchetype> list = new ArrayList<>(archetypes);
Collections.sort(list, (o1, o2) -> {
String key1 = o1.groupId + ":" + o1.artifactId;
String key2 = o2.groupId + ":" + o2.artifactId;
int result = key1.compareToIgnoreCase(key2);
if (result != 0)
return result;
return o2.version.compareToIgnoreCase(o1.version);
});
Map<String, List<MavenArchetype>> map = new TreeMap<>();
for (MavenArchetype each : list) {
String key = each.groupId + ":" + each.artifactId;
List<MavenArchetype> versions = map.get(key);
if (versions == null) {
versions = new ArrayList<>();
map.put(key, versions);
}
versions.add(each);
}
DefaultMutableTreeNode result = new DefaultMutableTreeNode("root", true);
for (List<MavenArchetype> each : map.values()) {
MavenArchetype eachArchetype = each.get(0);
DefaultMutableTreeNode node = new DefaultMutableTreeNode(eachArchetype, true);
for (MavenArchetype eachVersion : each) {
DefaultMutableTreeNode versionNode = new DefaultMutableTreeNode(eachVersion, false);
node.add(versionNode);
}
result.add(node);
}
return result;
}
Aggregations