Example usage for org.apache.maven.project MavenProject getBuildPlugins

List of usage examples for org.apache.maven.project MavenProject getBuildPlugins

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getBuildPlugins.

Prototype

public List<Plugin> getBuildPlugins() 

Source Link

Usage

From source file:org.wso2.developerstudio.eclipse.maven.multi.module.handlers.MvnMultiModuleWizard.java

License:Open Source License

/**
 * @param mavenProject//from   ww  w. ja va2  s . c o m
 * @param modules
 * @param selectedProjects
 * @param pomFile
 */
private void addMavenModules(IProject selectedProject, MavenProject mavenProject, List modules,
        List<IProject> selectedProjects, IFile pomFile) {
    modules.clear();
    for (IProject iProject : selectedProjects) {
        String relativePath = FileUtils
                .getRelativePath(selectedProject.getLocation().toFile(), iProject.getLocation().toFile())
                .replaceAll(Pattern.quote(File.separator), "/");
        if (!modules.contains(relativePath)) {
            modules.add(relativePath);
        }
    }

    try {
        MavenUtils.saveMavenProject(mavenProject, pomFile.getLocation().toFile());
        selectedProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (Exception e) {
        log.error("Error occured while trying to save the maven project", e);
    }

    try {
        MavenProject mproject = MavenUtils.getMavenProject(pomFile.getLocation().toFile());
        List<Plugin> buildPlugins = mproject.getBuildPlugins();
        if (buildPlugins.isEmpty()) {
            MavenUtils.updateWithMavenEclipsePlugin(pomFile.getLocation().toFile(), new String[] {},
                    new String[] { Constants.MAVEN_MULTI_MODULE_PROJECT_NATURE });
        } else {
            for (Plugin plugin : buildPlugins) {
                if (MAVEN_ECLIPSE_PLUGIN.equals(plugin.getId())) {
                    break;// Since plugin is already in the pom no need to
                          // add it again
                } else {
                    MavenUtils.updateWithMavenEclipsePlugin(pomFile.getLocation().toFile(), new String[] {},
                            new String[] { Constants.MAVEN_MULTI_MODULE_PROJECT_NATURE });
                }
            }
        }
        selectedProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (Exception e) {
        log.error("Error occured while trying to update the maven project with Eclipse Maven plugin.", e);
    }
}

From source file:org.wso2.developerstudio.eclipse.platform.ui.mvn.wizard.MvnMultiModuleWizard.java

License:Open Source License

/**
 * @param mavenProject//from   www . j  ava2  s. com
 * @param modules
 * @param selectedProjects
 * @param pomFile
 */
private void addMavenModules(IProject selectedProject, MavenProject mavenProject, List modules,
        List<IProject> selectedProjects, IFile pomFile) {
    modules.clear();
    for (IProject iProject : selectedProjects) {
        String relativePath = FileUtils
                .getRelativePath(selectedProject.getLocation().toFile(), iProject.getLocation().toFile())
                .replaceAll(Pattern.quote(File.separator), "/");
        if (!modules.contains(relativePath)) {
            modules.add(relativePath);
        }
    }

    try {
        MavenUtils.saveMavenProject(mavenProject, pomFile.getLocation().toFile());
        selectedProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (Exception e) {
        log.error("Error occured while trying to save the maven project", e);
    }

    try {
        MavenProject mproject = MavenUtils.getMavenProject(pomFile.getLocation().toFile());
        List<Plugin> buildPlugins = mproject.getBuildPlugins();
        if (buildPlugins.isEmpty()) {
            MavenUtils.updateWithMavenEclipsePlugin(pomFile.getLocation().toFile(), new String[] {},
                    new String[] { MAVEN_MULTI_MODULE_PROJECT_NATURE });
        } else {
            for (Plugin plugin : buildPlugins) {
                if (MAVEN_ECLIPSE_PLUGIN.equals(plugin.getId())) {
                    break;// Since plugin is already in the pom no need to
                          // add it again
                } else {
                    MavenUtils.updateWithMavenEclipsePlugin(pomFile.getLocation().toFile(), new String[] {},
                            new String[] { MAVEN_MULTI_MODULE_PROJECT_NATURE });
                }
            }
        }
        selectedProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (Exception e) {
        log.error("Error occured while trying to update the maven project with Eclipse Maven plugin.", e);
    }
}