org.apache.continuum.utils.release.ReleaseUtil Maven / Gradle / Ivy
package org.apache.continuum.utils.release;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.shared.release.versions.DefaultVersionInfo;
import org.apache.maven.shared.release.versions.VersionInfo;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class ReleaseUtil
{
@SuppressWarnings( "unchecked" )
public static Map getReleasePluginParameters( String workingDirectory, String pomFilename )
throws Exception
{
Map params = new HashMap();
// TODO: Use the model reader so we'll can get the plugin configuration from parent too
Model model = getMavenModel( workingDirectory, pomFilename );
if ( model.getBuild() != null && model.getBuild().getPlugins() != null )
{
for ( Plugin plugin : (List) model.getBuild().getPlugins() )
{
if ( plugin.getGroupId() != null && plugin.getGroupId().equals( "org.apache.maven.plugins" ) &&
plugin.getArtifactId() != null && plugin.getArtifactId().equals( "maven-release-plugin" ) )
{
Xpp3Dom dom = (Xpp3Dom) plugin.getConfiguration();
// TODO: use constants
if ( dom != null )
{
Xpp3Dom configuration = dom.getChild( "releaseLabel" );
if ( configuration != null )
{
params.put( "scm-tag", configuration.getValue() );
}
configuration = dom.getChild( "tag" );
if ( configuration != null )
{
params.put( "scm-tag", configuration.getValue() );
}
configuration = dom.getChild( "tagBase" );
if ( configuration != null )
{
params.put( "scm-tagbase", configuration.getValue() );
}
configuration = dom.getChild( "preparationGoals" );
if ( configuration != null )
{
params.put( "preparation-goals", configuration.getValue() );
}
configuration = dom.getChild( "arguments" );
if ( configuration != null )
{
params.put( "arguments", configuration.getValue() );
}
configuration = dom.getChild( "scmCommentPrefix" );
if ( configuration != null )
{
params.put( "scm-comment-prefix", configuration.getValue() );
}
configuration = dom.getChild( "autoVersionSubmodules" );
if ( configuration != null )
{
params.put( "auto-version-submodules", Boolean.valueOf( configuration.getValue() ) );
}
configuration = dom.getChild( "addSchema" );
if ( configuration != null )
{
params.put( "add-schema", Boolean.valueOf( configuration.getValue() ) );
}
configuration = dom.getChild( "useReleaseProfile" );
if ( configuration != null )
{
params.put( "use-release-profile", Boolean.valueOf( configuration.getValue() ) );
}
configuration = dom.getChild( "goals" );
if ( configuration != null )
{
String goals = configuration.getValue();
if ( model.getDistributionManagement() != null &&
model.getDistributionManagement().getSite() != null )
{
goals += " site-deploy";
}
params.put( "perform-goals", goals );
}
}
}
}
}
return params;
}
public static void processProject( String workingDirectory, String pomFilename, boolean autoVersionSubmodules,
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy