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

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

Introduction

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

Prototype

public Xpp3Dom getGoalConfiguration(String pluginGroupId, String pluginArtifactId, String executionId,
            String goalId) 

Source Link

Usage

From source file:aQute.bnd.maven.plugin.BndMavenPlugin.java

License:Open Source License

private File loadProjectProperties(Builder builder, MavenProject project) throws Exception {
    // Load parent project properties first
    MavenProject parentProject = project.getParent();
    if (parentProject != null) {
        loadProjectProperties(builder, parentProject);
    }//from   www . ja  va 2  s .  c  o  m

    // Merge in current project properties
    Xpp3Dom configuration = project.getGoalConfiguration("biz.aQute.bnd", "bnd-maven-plugin",
            mojoExecution.getExecutionId(), mojoExecution.getGoal());
    File baseDir = project.getBasedir();
    if (baseDir != null) { // file system based pom
        File pomFile = project.getFile();
        builder.updateModified(pomFile.lastModified(), "POM: " + pomFile);
        // check for bnd file
        String bndFileName = Project.BNDFILE;
        if (configuration != null) {
            Xpp3Dom bndfileElement = configuration.getChild("bndfile");
            if (bndfileElement != null) {
                bndFileName = bndfileElement.getValue();
            }
        }
        File bndFile = IO.getFile(baseDir, bndFileName);
        if (bndFile.isFile()) {
            logger.debug("loading bnd properties from file: {}", bndFile);
            // we use setProperties to handle -include
            builder.setProperties(bndFile.getParentFile(), builder.loadProperties(bndFile));
            return bndFile;
        }
        // no bnd file found, so we fall through
    }
    // check for bnd-in-pom configuration
    if (configuration != null) {
        Xpp3Dom bndElement = configuration.getChild("bnd");
        if (bndElement != null) {
            logger.debug("loading bnd properties from bnd element in pom: {}", project);
            UTF8Properties properties = new UTF8Properties();
            properties.load(bndElement.getValue(), project.getFile(), builder);
            if (baseDir != null) {
                String here = baseDir.toURI().getPath();
                here = Matcher.quoteReplacement(here.substring(0, here.length() - 1));
                properties = properties.replaceAll("\\$\\{\\.\\}", here);
            }
            // we use setProperties to handle -include
            builder.setProperties(baseDir, properties);
        }
    }
    return project.getFile();
}

From source file:org.apache.felix.bundleplugin.JarPluginConfiguration.java

License:Apache License

private static PlexusConfiguration getPluginConfiguration(MavenProject project, String groupId,
        String artifactId) {/*from w w w. j  av a 2 s  .c o  m*/
    Xpp3Dom pluginConfig = project.getGoalConfiguration(groupId, artifactId, null, null);

    return new XmlPlexusConfiguration(pluginConfig);
}

From source file:org.asciidoctor.maven.site.AsciidoctorDoxiaParser.java

License:Apache License

protected Xpp3Dom getSiteConfig(MavenProject project) {
    return project.getGoalConfiguration("org.apache.maven.plugins", "maven-site-plugin", "site", "site");
}

From source file:org.ops4j.pax.construct.lifecycle.BundleCompilerMojo.java

License:Apache License

/**
 * Copy additional compiler settings from maven-compiler-plugin section (only handles simple configuration items)
 * //from   ww w  .  j a  va  2  s .com
 * @param mojo compiler mojo
 * @param project maven project
 */
protected static void mergeCompilerConfiguration(AbstractCompilerMojo mojo, MavenProject project) {
    Plugin core = new Plugin();
    core.setGroupId("org.apache.maven.plugins");
    core.setArtifactId("maven-compiler-plugin");

    Plugin pax = new Plugin();
    pax.setGroupId("org.ops4j");
    pax.setArtifactId("maven-pax-plugin");

    // load pluginManagement
    project.getBuild().addPlugin(core);
    project.getBuild().addPlugin(pax);

    Xpp3Dom coreConfig = project.getGoalConfiguration(core.getGroupId(), core.getArtifactId(), null, null);
    Xpp3Dom paxConfig = project.getGoalConfiguration(pax.getGroupId(), pax.getArtifactId(), null, null);

    if (null != coreConfig) {
        ReflectMojo baseMojo = new ReflectMojo(mojo, AbstractCompilerMojo.class);

        Xpp3Dom[] configuration = coreConfig.getChildren();
        for (int i = 0; i < configuration.length; i++) {
            // don't override pax settings
            String name = configuration[i].getName();
            if ((null == paxConfig || null == paxConfig.getChild(name)) && baseMojo.hasField(name)) {
                // only use non-empty settings
                String value = configuration[i].getValue();
                if (null != value) {
                    mojo.getLog().debug("Using compiler setting: " + name + "=" + value);
                    baseMojo.setField(name, value);
                }
            }
        }
    }
}