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

com.itemis.maven.plugins.unleash.UnleashMojo Maven / Gradle / Ivy

Go to download

This plugin provides a generic alternative to the error-prone default release plugin provided by Maven. It is designed to require a minimal effort of work for releasing modules and being extensible to integrate in every project setup.

There is a newer version: 2.10.0
Show newest version
package com.itemis.maven.plugins.unleash;

import java.util.List;

import javax.inject.Named;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.components.interactivity.Prompter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.impl.Deployer;
import org.eclipse.aether.impl.Installer;
import org.eclipse.aether.impl.RemoteRepositoryManager;
import org.eclipse.aether.repository.RemoteRepository;

import com.google.common.base.Strings;
import com.itemis.maven.aether.ArtifactCoordinates;
import com.itemis.maven.plugins.cdi.AbstractCDIMojo;
import com.itemis.maven.plugins.cdi.annotations.MojoProduces;
import com.itemis.maven.plugins.cdi.annotations.ProcessingStep;

/**
 * A Maven {@link Mojo} which performs a release of the project it is started on.
* Release means that the versions of all modules are nailed down to real release versions so that the artifacts are * stable and reproducible. * Furthermore the whole project is built with these versions, SCM tags will be created and the artifacts will be * installed and deployed.
*
* Since this mojo depends on the base mojo of the CDI * Plugin Utils * project it implements a basic workflow which is fully configurable and extendable by nature.
*
* In order to get this plugin to work you will have to add the appropriate SCM Provider implementation as a plugin * dependency, such as SVN provider or * Git provider.
* You may also add further plugin dependencies that provider some additional {@link ProcessingStep} implementations you * want to use in your adapted workflow, f.i. CDI Plugin * Hooks. * * * @author Stanley Hillner * @since 1.0.0 */ @Mojo(name = "perform", aggregator = true, requiresProject = true) public class UnleashMojo extends AbstractCDIMojo { @Component @MojoProduces private RepositorySystem repoSystem; @Component @MojoProduces private RemoteRepositoryManager remoteRepositoryManager; @Component @MojoProduces private Deployer deployer; @Component @MojoProduces private Installer installer; @Component @MojoProduces private Prompter prompter; @Parameter(defaultValue = "${repositorySystemSession}", readonly = true, required = true) @MojoProduces private RepositorySystemSession repoSession; @Parameter(defaultValue = "${project.remotePluginRepositories}", readonly = true, required = true) @MojoProduces @Named("pluginRepositories") private List remotePluginRepos; @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true) @MojoProduces @Named("projectRepositories") private List remoteProjectRepos; @Parameter(defaultValue = "${localRepository}", readonly = true, required = true) @MojoProduces @Named("local") private ArtifactRepository LocalRepository; @Parameter(defaultValue = "${project}", readonly = true, required = true) @MojoProduces private MavenProject project; @Parameter(defaultValue = "${reactorProjects}", readonly = true, required = true) @MojoProduces @Named("reactorProjects") private List reactorProjects; @Parameter(defaultValue = "${settings}", readonly = true, required = true) @MojoProduces private Settings settings; ////////////////////////////// configuration parameters ////////////////////////////// ////////////////////////////// required @Parameter(defaultValue = "true", property = "unleash.allowLocalReleaseArtifacts", required = true) @MojoProduces @Named("allowLocalReleaseArtifacts") private boolean allowLocalReleaseArtifacts; @Parameter(defaultValue = "false", property = "unleash.commitBeforeTagging", required = true) @MojoProduces @Named("commitBeforeTagging") private boolean commitBeforeTagging; @Parameter(defaultValue = "${maven.home}", property = "unleash.mavenHome", required = true) @MojoProduces @Named("maven.home") private String mavenHome; @Parameter(defaultValue = "@{project.version}", property = "unleash.tagNamePattern", required = true) @MojoProduces @Named("tagNamePattern") private String tagNamePattern; //////////////////////////// optional @Parameter(property = "unleash.developmentVersion", required = false) @MojoProduces @Named("developmentVersion") private String developmentVersion; @Parameter(property = "unleash.profiles", required = false) @MojoProduces @Named("profiles") private List profiles; @Parameter(defaultValue = "", property = "unleash.releaseArgs", required = false) @MojoProduces @Named("releaseArgs") private String releaseArgs; @Parameter(property = "unleash.releaseVersion", required = false) @MojoProduces @Named("releaseVersion") private String releaseVersion; @Parameter(defaultValue = "[unleash-maven-plugin]", property = "unleash.scmMessagePrefix", required = false) private String scmMessagePrefix; @MojoProduces @Named("scmPassword") @Parameter(property = "unleash.scmPassword", required = false) private String scmPassword; @MojoProduces @Named("scmUsername") @Parameter(property = "unleash.scmUsername", required = false) private String scmUsername; @MojoProduces @Named("artifactSpyPlugin") private ArtifactCoordinates artifactSpyPluginCoordinates = new ArtifactCoordinates("com.itemis.maven.plugins", "artifact-spy-plugin", "1.0.3", "maven-plugin"); @MojoProduces private PluginDescriptor getPluginDescriptor() { return (PluginDescriptor) getPluginContext().get("pluginDescriptor"); } @MojoProduces @Named("scmMessagePrefix") private String getScmMessagePrefix() { if (this.scmMessagePrefix != null && !this.scmMessagePrefix.endsWith(" ")) { this.scmMessagePrefix = this.scmMessagePrefix + " "; } return Strings.nullToEmpty(this.scmMessagePrefix); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy