Search in sources :

Example 11 with PluginManagement

use of org.apache.maven.model.PluginManagement in project maven-plugins by apache.

the class SiteStageDeployMojo method getStagingSiteURL.

/**
 * Extract the value of the stagingSiteURL configuration parameter of
 * maven-site-plugin for the given project.
 *
 * @param project The MavenProject, not null
 * @return The stagingSiteURL for the project, or null if it doesn't have one
 */
private String getStagingSiteURL(MavenProject project) {
    final String sitePluginKey = "org.apache.maven.plugins:maven-site-plugin";
    if (project == null) {
        return null;
    }
    final Build build = project.getBuild();
    if (build == null) {
        return null;
    }
    Map<String, Plugin> plugins = build.getPluginsAsMap();
    Plugin sitePlugin = plugins.get(sitePluginKey);
    if (sitePlugin == null) {
        final PluginManagement buildPluginManagement = build.getPluginManagement();
        if (buildPluginManagement == null) {
            return null;
        }
        plugins = buildPluginManagement.getPluginsAsMap();
        sitePlugin = plugins.get(sitePluginKey);
    }
    if (sitePlugin == null) {
        return null;
    }
    final Xpp3Dom sitePluginConfiguration = (Xpp3Dom) sitePlugin.getConfiguration();
    if (sitePluginConfiguration == null) {
        return null;
    }
    final Xpp3Dom child = sitePluginConfiguration.getChild("stagingSiteURL");
    if (child == null) {
        return null;
    } else {
        return child.getValue();
    }
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Build(org.apache.maven.model.Build) Plugin(org.apache.maven.model.Plugin)

Example 12 with PluginManagement

use of org.apache.maven.model.PluginManagement in project maven-archetype by apache.

the class FilesetArchetypeCreator method createArchetypeProjectPom.

/**
 * Create the archetype project pom.xml file, that will be used to build the archetype.
 */
private File createArchetypeProjectPom(MavenProject project, ProjectBuildingRequest buildingRequest, Properties configurationProperties, File projectDir) throws TemplateCreationException, IOException {
    Model model = new Model();
    model.setModelVersion("4.0.0");
    // these values should be retrieved from the request with sensible defaults
    model.setGroupId(configurationProperties.getProperty(Constants.ARCHETYPE_GROUP_ID, project.getGroupId()));
    model.setArtifactId(configurationProperties.getProperty(Constants.ARCHETYPE_ARTIFACT_ID, project.getArtifactId()));
    model.setVersion(configurationProperties.getProperty(Constants.ARCHETYPE_VERSION, project.getVersion()));
    model.setPackaging("maven-archetype");
    model.setName(configurationProperties.getProperty(Constants.ARCHETYPE_ARTIFACT_ID, project.getArtifactId()));
    model.setUrl(configurationProperties.getProperty(Constants.ARCHETYPE_URL, project.getUrl()));
    model.setDescription(configurationProperties.getProperty(Constants.ARCHETYPE_DESCRIPTION, project.getDescription()));
    model.setLicenses(project.getLicenses());
    model.setDevelopers(project.getDevelopers());
    model.setScm(project.getScm());
    Build build = new Build();
    model.setBuild(build);
    if (project.getParent() != null) {
        MavenProject p = project.getParent();
        if (p.getDistributionManagement() != null) {
            model.setDistributionManagement(p.getDistributionManagement());
        }
        if (p.getBuildExtensions() != null) {
            for (Extension be : p.getBuildExtensions()) {
                model.getBuild().addExtension(be);
            }
        }
    }
    Extension extension = new Extension();
    extension.setGroupId("org.apache.maven.archetype");
    extension.setArtifactId("archetype-packaging");
    extension.setVersion(getArchetypeVersion());
    model.getBuild().addExtension(extension);
    Plugin plugin = new Plugin();
    plugin.setGroupId("org.apache.maven.plugins");
    plugin.setArtifactId("maven-archetype-plugin");
    plugin.setVersion(getArchetypeVersion());
    PluginManagement pluginManagement = new PluginManagement();
    pluginManagement.addPlugin(plugin);
    model.getBuild().setPluginManagement(pluginManagement);
    getLogger().debug("Creating archetype's pom");
    File archetypePomFile = new File(projectDir, Constants.ARCHETYPE_POM);
    archetypePomFile.getParentFile().mkdirs();
    copyResource("pom-prototype.xml", archetypePomFile);
    pomManager.writePom(model, archetypePomFile, archetypePomFile);
    return archetypePomFile;
}
Also used : Extension(org.apache.maven.model.Extension) PluginManagement(org.apache.maven.model.PluginManagement) MavenProject(org.apache.maven.project.MavenProject) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) File(java.io.File) Plugin(org.apache.maven.model.Plugin)

Aggregations

PluginManagement (org.apache.maven.model.PluginManagement)12 Plugin (org.apache.maven.model.Plugin)8 Build (org.apache.maven.model.Build)7 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)2 IsSnapshotDependency (com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency)2 IsSnapshotPlugin (com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotPlugin)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Artifact (org.apache.maven.artifact.Artifact)2 BuildBase (org.apache.maven.model.BuildBase)2 Dependency (org.apache.maven.model.Dependency)2 Model (org.apache.maven.model.Model)2 Profile (org.apache.maven.model.Profile)2 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 Extension (org.apache.maven.model.Extension)1 MavenProject (org.apache.maven.project.MavenProject)1 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)1 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)1 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)1