Search in sources :

Example 6 with MavenArchetype

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));
}
Also used : ArrayList(java.util.ArrayList) MavenArchetype(org.jetbrains.idea.maven.model.MavenArchetype)

Example 7 with MavenArchetype

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");
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenArchetype(org.jetbrains.idea.maven.model.MavenArchetype)

Example 8 with MavenArchetype

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);
    }
}
Also used : MavenArchetype(org.jetbrains.idea.maven.model.MavenArchetype)

Example 9 with MavenArchetype

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);
}
Also used : MavenArchetype(org.jetbrains.idea.maven.model.MavenArchetype)

Example 10 with MavenArchetype

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;
}
Also used : List(java.util.List) MavenArchetype(org.jetbrains.idea.maven.model.MavenArchetype)

Aggregations

MavenArchetype (org.jetbrains.idea.maven.model.MavenArchetype)16 MavenId (org.jetbrains.idea.maven.model.MavenId)3 IOException (java.io.IOException)2 Archetype (org.apache.maven.archetype.catalog.Archetype)2 ArchetypeCatalog (org.apache.maven.archetype.catalog.ArchetypeCatalog)2 ArchetypeDataSource (org.apache.maven.archetype.source.ArchetypeDataSource)2 ArchetypeDataSourceException (org.apache.maven.archetype.source.ArchetypeDataSourceException)2 Element (org.jdom.Element)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 JDOMException (org.jdom.JDOMException)1 MavenProject (org.jetbrains.idea.maven.project.MavenProject)1