Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011-2012 The Kuali Foundation Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php 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.
 
 package org.kuali.maven.plugins.externals;
 
 import java.io.File;
 import java.util.List;
 
 
Connect svn:externals definitions with a multi-module Maven build in an intelligent manner. This mojo creates a tag from a Subversion checkout containing svn:externals definitions that correspond to Maven modules. The version numbers in the respective poms are modified to reflect the current build. This allows the tag to be used to create reproducible builds. The binaries Maven produces off the tag, correspond exactly to the version numbers in the Maven pom's.

Goal:
tag
 
 public class TagMojo extends AbstractMojo {
 
 	SVNUtils svnUtils = SVNUtils.getInstance();
 	MojoHelper helper = MojoHelper.getInstance();

The prefix Maven needs in front of the real SCM url

Parameter:
expression="${externals.scmUrlPrefix}" default-value="scm:svn:"
 
 	private String scmUrlPrefix;

The location of a text file that contains the svn:externals definitions

Parameter:
expression="${externals.file}" default-value="${project.build.directory}/checkout/svn.externals"
 
 	private File file;

The directory where the new tag is checked out to

Parameter:
expression="${externals.checkoutDir}" default-value="${project.build.directory}/checkout"
 
 	private File checkoutDir;

Filename pattern used to discover Maven pom's

Parameter:
expression="${externals.pom}" default-value="pom.xml"
 
 	private String pom;

Directores to ignore when examining the file system for Maven pom's

Parameter:
expression="${externals.ignoreDirectories}" default-value="src,target,.svn,.git"
 
The Maven project object

Parameter:
expression="${project}"
Readonly:
 
 	private MavenProject project;

These mappings connect the svn:externals definitions with a property inside the root pom that controls what version each external is set to

Parameter:
 
 	private List<Mappingmappings;

The commit message for when the new tag is first created

Parameter:
expression="${externals.createTagMessage}" default-value="[externals-maven-plugin] Create tag"
 
 	private String createTagMessage;

The commit message for when the updated pom's and svn.external file is committed to the tag

Parameter:
expression="${externals.updateTagMessage}" default-value="[externals-maven-plugin] Tag maintenance"
The commit message for when the svn propset command is used to set externals on the tag

Parameter:
expression="${externals.externalsMessage}" default-value="[externals-maven-plugin] Set svn:externals"
The property where the current build number is stored. Jenkins automatically sets an environment variable called BUILD_NUMBER each time a job is run

Parameter:
expression="${externals.buildNumberProperty}" default-value="env.BUILD_NUMBER"
Either BUILDNUMBER, REVISION, or RELEASE

Parameter:
expression="${externals.tagStyle}" default-value="BUILDNUMBER"
	private TagStyle tagStyle;
	public void execute() throws MojoExecutionException {
		// Extract svn:externals info from the root of the checkout
		// Make sure the modules listed in the pom match the svn:externals definitions and the mappings provided in the plugin config
		// Calculate the build tag for the root
		BuildTag rootTag = .getBuildTag(.getBasedir(), gavbuildNumber);
		// Update build info for the root node
		.updateBuildInfo(noderootTagbuildNumber);
		// Calculate build tags for each module
		List<BuildTagmoduleTags = .getBuildTags(.getProperties(), externalsbuildNumber);
		// Update build information for nodes that represent an svn:external
		.updateBuildInfo(nodesmoduleTagsbuildNumber);
		// Recursively update the project gav's and parent gav's
		// Recursively update the corresponding Maven pom's
		// Update the properties in the root pom that hold version info for the modules
		// Update the <scm> info in the root pom
		// Create new svn:externals definitions based on the newly created tags
		List<SVNExternalnewExternals = .getExternals(moduleTags);
		// Create the module tags
		// Create the root tag
		// Update svn:externals definitions on the root tag so they point to the new module tags
		SVNCommitInfo info = .setExternals(rootTag.getTagUrl(), newExternals);
		getLog().info("Set " + newExternals.size() + " externals @ " + rootTag.getTagUrl());
		getLog().info("Committed revision " + info.getNewRevision() + ".");
		getLog().info("Checking out - " + rootTag.getTagUrl());
		getLog().info("Checkout dir - " + .getAbsolutePath());
			getLog().info("Deleting " + .getAbsolutePath());
		}
		long start = System.currentTimeMillis();
		long revision = .checkout(rootTag.getTagUrl(), nullnull);
		.logTime("Total checkout time: ", System.currentTimeMillis() - start);
		getLog().info("Checked out revision " + revision + ".");
		// Update the poms in the directory where the tag has been checked out
		// Update the svn.externals file in the tag
		// Commit the changes to the tag
	}
	public List<MappinggetMappings() {
		return ;
	}
	public void setMappings(List<Mappingmappings) {
		this. = mappings;
	}
		return ;
	}
	}
	public void setCreateTagMessage(String message) {
		this. = message;
	}
	}
	public void setExternalsMessage(String externalsMessage) {
		this. = externalsMessage;
	}
	public TagStyle getTagStyle() {
		return ;
	}
	public void setTagStyle(TagStyle tagStyle) {
		this. = tagStyle;
	}
	public String getScmUrlPrefix() {
		return ;
	}
	public void setScmUrlPrefix(String scmUrlPrefix) {
		this. = scmUrlPrefix;
	}
	public String getPom() {
		return ;
	}
	public void setPom(String pom) {
		this. = pom;
	}
	}
	public void setIgnoreDirectories(String ignoreDirectories) {
		this. = ignoreDirectories;
	}
	}
	public void setBuildNumberProperty(String buildNumberProperty) {
		this. = buildNumberProperty;
	}
	public File getCheckoutDir() {
		return ;
	}
	public void setCheckoutDir(File checkoutDir) {
		this. = checkoutDir;
	}
	public File getFile() {
		return ;
	}
	public void setFile(File file) {
		this. = file;
	}
	}
	public void setUpdateTagMessage(String updateTagMessage) {
		this. = updateTagMessage;
	}
New to GrepCode? Check out our FAQ X