Java Code Examples for org.jetbrains.idea.maven.utils.MavenUtil

The following examples show how to use org.jetbrains.idea.maven.utils.MavenUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root)
{
    try
    {
        //Create mule folders.
        final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/domain");
        final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources");
        final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory);
        createMuleDeployPropertiesFile(project, projectId, appDirectory);
        createPomFile(project, projectId, muleVersion, root);
        // execute when current dialog is closed (e.g. Project Structure)
        MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile)));

    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
Example 2
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
    super.setupRootModel(rootModel);

    addListener(new ModuleBuilderListener() {
        @Override
        public void moduleCreated(@NotNull Module module) {
            setMuleFramework(module);
        }
    });

    setMuleFacet(rootModel.getModule());

    final Project project = rootModel.getProject();
    final VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);

    //Check if this is a module and has parent
    final MavenId parentId = (this.getParentProject() != null ? this.getParentProject().getMavenId() : null);

    MavenUtil.runWhenInitialized(project, (DumbAwareRunnable) () -> {
        new MuleMavenProjectBuilderHelper().configure(project, getProjectId(), muleVersion, root, parentId);
    });
}
 
Example 3
public void setupRootModel(ModifiableRootModel rootModel) {
    final Project project = rootModel.getProject();

    final VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);

    // todo this should be moved to generic ModuleBuilder
    if (myJdk != null){
        rootModel.setSdk(myJdk);
    } else {
        rootModel.inheritSdk();
    }

    MavenUtil.runWhenInitialized(
        project, new DumbAwareRunnable() {
        public void run() {
            if (myEnvironmentForm != null) {
                myEnvironmentForm.setData(MavenProjectsManager.getInstance(project).getGeneralSettings());
            }

            new MavenModuleBuilderHelper(myProjectId, myAggregatorProject, myParentProject, myInheritGroupId,
                myInheritVersion, archetypeTemplate.getMavenArchetype(), myPropertiesToCreateByArtifact, "Create new Sling Maven module").configure(project, root, false);
            }
        }
    );
}
 
Example 4
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
    super.setupRootModel(rootModel);

    setMuleFacet(rootModel.getModule());

    final Project project = rootModel.getProject();
    final VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);
    MavenUtil.runWhenInitialized(project, (DumbAwareRunnable) () -> new MuleDomainMavenProjectBuilderHelper().configure(project, getProjectId(), muleVersion, root));
}
 
Example 5
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root, @Nullable MavenId parentId)
{
    try
    {
        //Create mule folders.
        final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/app");
        final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources");
        createLog4J(project, projectId, resources);
        final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory);
        createMuleDeployPropertiesFile(project, projectId, appDirectory);
        createMuleAppPropertiesFiles(project, appDirectory);
        VfsUtil.createDirectories(root.getPath() + "/src/main/api");
        //MUnit support
        VfsUtil.createDirectories(root.getPath() + "/src/test/munit");
        final VirtualFile testResources = VfsUtil.createDirectories(root.getPath() + "/src/test/resources");
        createLog4JTest(project, projectId, testResources);

        if (parentId == null)
            createPomFile(project, projectId, muleVersion, root);
        else
            createModulePomFile(project, projectId, root, parentId);

        // execute when current dialog is closed (e.g. Project Structure)
        MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile)));

    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
Example 6
@Override
public boolean validate() throws ConfigurationException {
    File mavenHome = MavenUtil.resolveMavenHomeDirectory(myEnvironmentForm.getMavenHome());
    if (mavenHome == null) {
        throw new ConfigurationException("Maven home directory is not specified");
    }

    if (!MavenUtil.isValidMavenHome(mavenHome)) {
        throw new ConfigurationException("Maven home directory is invalid: " + mavenHome);
    }

    return true;
}
 
Example 7
Source Project: MavenHelper   Source File: MavenDebugConfigurationType.java    License: Apache License 2.0 5 votes vote down vote up
public static void debugConfiguration(Project project, ProgramRunner.Callback callback,
		RunnerAndConfigurationSettings configSettings, Executor executor) {
	ProgramRunner runner = ProgramRunner.findRunnerById(DefaultDebugExecutor.EXECUTOR_ID);
	ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);

	try {
		runner.execute(env, callback);
	} catch (ExecutionException e) {
		MavenUtil.showError(project, "Failed to execute Maven goal", e);
	}
}
 
Example 8
@Override
public boolean isValid(Module module) {
    return MavenUtil.isMavenModule(module);
}
 
Example 9
private static void showError(Project project, Throwable e)
{
    MavenUtil.showError(project, "Failed to create a Mule Domain project", e);
}
 
Example 10
private static void showError(Project project, Throwable e)
{
    MavenUtil.showError(project, "Failed to create a Mule project", e);
}