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

com.github.jasonmfehr.combiner.mojo.CombinerMojo Maven / Gradle / Ivy

package com.github.jasonmfehr.combiner.mojo;

import java.util.List;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import com.github.jasonmfehr.combiner.logging.ParameterizedLogger;
import com.github.jasonmfehr.combiner.pipeline.PipelineExecutor;

/**
 * combiner-maven-plugin
 * 
 * @author jasonmfehr
 * @since 1.0.0
 */
@Mojo(name="combine", defaultPhase=LifecyclePhase.PROCESS_SOURCES, threadSafe=true)
public class CombinerMojo extends AbstractMojo {

	/**
	 * list of combinations with each one representing a set of 
	 * resources to combine and the pipeline implementations to 
	 * use when combining them
	 */
	@Parameter(required=true)
	private List combinations;
	
	/**
	 * determines if the plugin execution should be skipped
	 */
	@Parameter(property="combiner.skip", defaultValue="false")
	private Boolean skip;
	
	@Component
	private MavenProject mavenProject;
	
	@Component
	private MojoExecution mojoExecution;
	
	@Component
	private PipelineExecutor pipelineExecutor;
	
	@Component
	private ParameterizedLogger logger;
	
	public void execute() throws MojoExecutionException, MojoFailureException {
		logger.setLogger(this.getLog());
		
		if(!Boolean.TRUE.equals(this.skip)){
			this.logger.debugWithParams("Entering {0} goal", mojoExecution.getGoal());
			pipelineExecutor.execute(this.combinations, this.mavenProject);
			this.logger.debugWithParams("Exiting {0} goal", mojoExecution.getGoal());
		}else{
			this.logger.info("skipping combiner-maven-plugin execution");
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy