Example usage for org.apache.maven.project ProjectBuildingRequest getActiveProfileIds

List of usage examples for org.apache.maven.project ProjectBuildingRequest getActiveProfileIds

Introduction

In this page you can find the example usage for org.apache.maven.project ProjectBuildingRequest getActiveProfileIds.

Prototype

List<String> getActiveProfileIds();

Source Link

Usage

From source file:fr.fastconnect.factory.tibco.bw.maven.BWLifecycleParticipant.java

License:Apache License

private List<MavenProject> prepareProjects(List<MavenProject> projects, MavenSession session)
        throws MavenExecutionException {
    List<MavenProject> result = new ArrayList<MavenProject>();

    ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest();

    for (MavenProject mavenProject : projects) {
        logger.debug("project: " + mavenProject.getGroupId() + ":" + mavenProject.getArtifactId());

        List<String> oldActiveProfileIds = projectBuildingRequest.getActiveProfileIds();
        try {/*from w  w  w .  jav  a2  s . co m*/
            List<String> activeProfileIds = activateProfilesWithProperties(mavenProject, oldActiveProfileIds);
            if (activeProfileIds.size() != oldActiveProfileIds.size()) {
                projectBuildingRequest.setActiveProfileIds(activeProfileIds);
                if (mavenProject.getFile() != null) {
                    List<File> files = new ArrayList<File>();
                    files.add(mavenProject.getFile());
                    List<ProjectBuildingResult> results = null;
                    try {
                        results = projectBuilder.build(files, true, projectBuildingRequest);
                    } catch (ProjectBuildingException e) {
                    }

                    for (ProjectBuildingResult projectBuildingResult : results) {
                        mavenProject = projectBuildingResult.getProject();
                    }
                }
            }
        } finally {
            projectBuildingRequest.setActiveProfileIds(oldActiveProfileIds);
        }

        if (mavenProject.getPackaging().startsWith(AbstractBWMojo.BWEAR_TYPE)
                || "true".equals(propertiesManager.getPropertyValue("enableBWLifecycle"))) {
            addTIBCODependenciesToPlugin(mavenProject, logger);
        }
        result.add(mavenProject);
    }

    return result;
}