Java Code Examples for org.apache.maven.project.MavenProject#getGoalConfiguration()

The following examples show how to use org.apache.maven.project.MavenProject#getGoalConfiguration() . 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
Source File: MavenProjectUtil.java    From ci.maven with Apache License 2.0 6 votes vote down vote up
/**
 * Get directory and targetPath configuration values from the Maven WAR plugin
 * @param proj the Maven project
 * @return a Map of source and target directories corresponding to the configuration keys
 * or null if the war plugin or its webResources or resource elements are not used. 
 * The map will be empty if the directory element is not used. The value field of the 
 * map is null when the targetPath element is not used.
 */
public static Map<String,String> getWebResourcesConfiguration(MavenProject proj) {
    Xpp3Dom dom = proj.getGoalConfiguration("org.apache.maven.plugins", "maven-war-plugin", null, null);
    if (dom != null) {
        Xpp3Dom web = dom.getChild("webResources");
        if (web != null) {
            Xpp3Dom resources[] = web.getChildren("resource");
            if (resources != null) {
                Map<String, String> result = new HashMap<String, String>();
                for (int i = 0; i < resources.length; i++) {
                    Xpp3Dom dir = resources[i].getChild("directory");
                    if (dir != null) {
                        Xpp3Dom target = resources[i].getChild("targetPath");
                        if (target != null) {
                            result.put(dir.getValue(), target.getValue());
                        } else {
                            result.put(dir.getValue(), null);
                        }
                    }
                }
                return result;
            }
        }
    }
    return null;
}
 
Example 2
Source File: MavenProjectUtil.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
/**
 * Get a configuration value from an execution of a plugin
 * @param proj the Maven project
 * @param pluginGroupId the plugin group id
 * @param pluginArtifactId the plugin artifact id
 * @param executionId the plugin execution id
 * @param key the configuration key to get from
 * @return the value corresponding to the configuration key
 */
public static String getPluginExecutionConfiguration(MavenProject proj, String pluginGroupId, String pluginArtifactId, String executionId, String key) {
    Xpp3Dom dom = proj.getGoalConfiguration(pluginGroupId, pluginArtifactId, executionId, null);
    if (dom != null) {
        Xpp3Dom val = dom.getChild(key);
        if (val != null) {
            return val.getValue();
        }
    }
    return null;
}
 
Example 3
Source File: MavenProjectUtil.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
/**
 * Get manifest file from plugin configuration
 * @param proj
 * @param pluginArtifactId
 * @return the manifest file
 */
public static File getManifestFile(MavenProject proj, String pluginArtifactId) {
    Xpp3Dom dom = proj.getGoalConfiguration("org.apache.maven.plugins", pluginArtifactId, null, null);
    if (dom != null) {
        Xpp3Dom archive = dom.getChild("archive");
        if (archive != null) {
            Xpp3Dom val = archive.getChild("manifestFile");
            if (val != null) {
                return new File(proj.getBasedir().getAbsolutePath() + "/" + val.getValue());
            }
        }
    }
    return null;
}
 
Example 4
Source File: PluginConfigSupport.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
private String getPluginConfiguration(MavenProject proj, String pluginGroupId, String pluginArtifactId,
        String key) {
    Xpp3Dom dom = proj.getGoalConfiguration(pluginGroupId, pluginArtifactId, null, null);
    if (dom != null) {
        Xpp3Dom val = dom.getChild(key);
        if (val != null) {
            return val.getValue();
        }
    }
    return null;
}
 
Example 5
Source File: AsciidoctorDoxiaParser.java    From asciidoctor-maven-plugin with Apache License 2.0 4 votes vote down vote up
protected Xpp3Dom getSiteConfig(MavenProject project) {
    return project.getGoalConfiguration("org.apache.maven.plugins", "maven-site-plugin", "site", "site");
}