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();
}
}
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;
}
Aggregations