Search in sources :

Example 11 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class MavenModuleWizardStep method updateStep.

@Override
public void updateStep() {
    if (myArchetypes != null && myArchetypes.isSkipUpdateUI())
        return;
    if (isMavenizedProject()) {
        MavenProject parent = findPotentialParentProject(myProjectOrNull);
        myAggregator = parent;
        myParent = parent;
    }
    MavenId projectId = myBuilder.getProjectId();
    if (projectId == null) {
        setTestIfEmpty(myArtifactIdField, myBuilder.getName());
        setTestIfEmpty(myGroupIdField, myParent == null ? myBuilder.getName() : myParent.getMavenId().getGroupId());
        setTestIfEmpty(myVersionField, myParent == null ? "1.0-SNAPSHOT" : myParent.getMavenId().getVersion());
    } else {
        setTestIfEmpty(myArtifactIdField, projectId.getArtifactId());
        setTestIfEmpty(myGroupIdField, projectId.getGroupId());
        setTestIfEmpty(myVersionField, projectId.getVersion());
    }
    myInheritGroupIdCheckBox.setSelected(myBuilder.isInheritGroupId());
    myInheritVersionCheckBox.setSelected(myBuilder.isInheritVersion());
    if (myArchetypes != null) {
        myArchetypes.requestUpdate();
    }
    updateComponents();
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 12 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class MavenProjectImportProvider method createSteps.

public ModuleWizardStep[] createSteps(final WizardContext wizardContext) {
    final ProjectWizardStepFactory stepFactory = ProjectWizardStepFactory.getInstance();
    return new ModuleWizardStep[] { new MavenProjectImportStep(wizardContext), new SelectProfilesStep(wizardContext), new SelectImportedProjectsStep<MavenProject>(wizardContext) {

        @Override
        protected String getElementText(final MavenProject project) {
            final StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(project.getMavenId());
            VirtualFile root = ((MavenProjectBuilder) getBuilder()).getRootDirectory();
            if (root != null) {
                final String relPath = VfsUtilCore.getRelativePath(project.getDirectoryFile(), root, File.separatorChar);
                if (StringUtil.isNotEmpty(relPath)) {
                    stringBuilder.append(" [").append(relPath).append("]");
                }
            }
            if (!isElementEnabled(project)) {
                stringBuilder.append(" (project is ignored. See ").append(CommonBundle.settingsActionPath()).append(" | Maven | Ignored Files)");
            }
            return stringBuilder.toString();
        }

        @Override
        protected boolean isElementEnabled(MavenProject mavenProject) {
            Project project = wizardContext.getProject();
            if (project == null)
                return true;
            return !MavenProjectsManager.getInstance(project).isIgnored(mavenProject);
        }

        @Override
        public void updateDataModel() {
            super.updateDataModel();
            getWizardContext().setProjectName(((MavenProjectBuilder) getBuilder()).getSuggestedProjectName());
        }

        @Override
        public String getHelpId() {
            return "reference.dialogs.new.project.import.maven.page3";
        }
    }, stepFactory.createProjectJdkStep(wizardContext), stepFactory.createNameAndLocationStep(wizardContext) };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SelectImportedProjectsStep(com.intellij.projectImport.SelectImportedProjectsStep) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Project(com.intellij.openapi.project.Project) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) MavenProject(org.jetbrains.idea.maven.project.MavenProject) ProjectWizardStepFactory(com.intellij.ide.util.projectWizard.ProjectWizardStepFactory)

Example 13 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class InvalidProjectImportingTest method testInvalidRepositoryLayout.

public void testInvalidRepositoryLayout() throws Exception {
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<distributionManagement>" + "  <repository>" + "    <id>test</id>" + "    <url>http://www.google.com</url>" + // invalid layout
    "    <layout>nothing</layout>" + "  </repository>" + "</distributionManagement>");
    assertModules("project");
    MavenProject root = getRootProjects().get(0);
    assertProblems(root, "Cannot find layout implementation corresponding to: 'nothing' for remote repository with id: 'test'.");
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 14 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class InvalidProjectImportingTest method testDoNotFailIfRepositoryHasEmptyLayout.

public void testDoNotFailIfRepositoryHasEmptyLayout() throws Exception {
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<repositories>" + " <repository>" + "   <id>foo1</id>" + "   <url>bar1</url>" + "   <layout/>" + " </repository>" + "</repositories>" + "<pluginRepositories>" + " <pluginRepository>" + "   <id>foo2</id>" + "   <url>bar2</url>" + "   <layout/>" + " </pluginRepository>" + "</pluginRepositories>");
    MavenProject root = getRootProjects().get(0);
    assertProblems(root);
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 15 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class InvalidProjectImportingTest method testUnknownProblem.

public void testUnknownProblem() throws Exception {
    importProject("");
    assertModules("project");
    MavenProject root = getRootProjects().get(0);
    assertProblems(root, "'pom.xml' has syntax errors");
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Aggregations

MavenProject (org.jetbrains.idea.maven.project.MavenProject)132 VirtualFile (com.intellij.openapi.vfs.VirtualFile)40 MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)20 MavenId (org.jetbrains.idea.maven.model.MavenId)16 Project (com.intellij.openapi.project.Project)10 Nullable (org.jetbrains.annotations.Nullable)9 Bombed (com.intellij.idea.Bombed)8 Module (com.intellij.openapi.module.Module)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Result (com.intellij.openapi.application.Result)4 MavenArtifact (org.jetbrains.idea.maven.model.MavenArtifact)4 MavenEmbeddersManager (org.jetbrains.idea.maven.project.MavenEmbeddersManager)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 TextRange (com.intellij.openapi.util.TextRange)3 NotNull (org.jetbrains.annotations.NotNull)3 MavenRunnerParameters (org.jetbrains.idea.maven.execution.MavenRunnerParameters)3 MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)3 MavenProjectsTree (org.jetbrains.idea.maven.project.MavenProjectsTree)3