All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.researchgate.release.BaseScmPlugin.groovy Maven / Gradle / Ivy

Go to download

gradle-release is a plugin for providing a Maven-like release process to project using Gradle.

There is a newer version: 2.4.0
Show newest version
package net.researchgate.release

import org.gradle.api.Plugin
import org.gradle.api.Project

/**
 * Base class for all SCM-specific plugins
 * @author evgenyg
 */
abstract class BaseScmPlugin extends PluginHelper implements Plugin {

	private final String pluginName = this.class.simpleName
	private T convention

	void apply(Project project) {

		this.project = project

		project.task('checkCommitNeeded', group: ReleasePlugin.RELEASE_GROUP,
				description: 'Checks to see if there are any added, modified, removed, or un-versioned files.') << this.&checkCommitNeeded
		project.task('checkUpdateNeeded', group: ReleasePlugin.RELEASE_GROUP,
				description: 'Checks to see if there are any incoming or outgoing changes that haven\'t been applied locally.') << this.&checkUpdateNeeded

        setConvention()

    }

	/**
	 * Called by {@link ReleasePlugin} when plugin's convention needs to be set.
	 */
	final void setConvention() { convention = (T) setConvention(pluginName, buildConventionInstance()) }

	/**
	 * Convenience method for sub-classes to access their own convention instance.
	 * @return this plugin convention instance.
	 */
	@SuppressWarnings('ConfusingMethodName')
	final T convention() { convention(pluginName, convention.class)}

	/**
	 * Retrieves convention instance to be set for this plugin.
	 * @return convention instance to be set for this plugin.
	 */
	abstract T buildConventionInstance()

	abstract void init()

	abstract void checkCommitNeeded()

	abstract void checkUpdateNeeded()

	abstract void createReleaseTag(String message = "")

	abstract void commit(String message)

	abstract void revert()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy