
com.avaje.ebean.enhance.maven.MavenEnhanceTask Maven / Gradle / Ivy
package com.avaje.ebean.enhance.maven;
import com.avaje.ebean.enhance.agent.AgentManifestReader;
import com.avaje.ebean.enhance.agent.Transformer;
import com.avaje.ebean.enhance.ant.OfflineFileTransform;
import com.avaje.ebean.enhance.ant.TransformationListener;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
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.plugins.annotations.ResolutionScope;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
/**
* A Maven Plugin that can enhance entity beans etc for use by Ebean.
*
* You can use this plugin as part of your build process to enhance entity beans
* etc.
*
*
* The parameters are:
*
* - classSource This is the root directory where the .class files are
* found. If this is left out then this defaults to
* ${project.build.outputDirectory}.
* - classDestination This is the root directory where the .class files
* are written to. If this is left out then this defaults to the
* classSource.
* - packages A comma delimited list of packages that is searched for
* classes that need to be enhanced. If the package ends with ** or * then all
* subpackages are also searched.
* - transformArgs Arguments passed to the transformer. Typically a
* debug level in the form of debug=1 etc.
*
*
*
* {@code
*
*
* org.avaje.ebeanorm
* avaje-ebeanorm-mavenenhancer
* 4.6.1
*
*
* main
* process-classes
*
*
*
*
*
*
* enhance
*
*
*
*
*
* }
*
* To invoke explicitly:
{@code
*
* mvn avaje-ebeanormenhancer:enhance
*
* }
*
* @author Paul Mendelson, Vaughn Butt, Rob Bygrave
* @since 2.5, Mar, 2009
*/
@Mojo(name = "enhance", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class MavenEnhanceTask extends AbstractMojo {
/**
* The class path used to read related classes.
*/
@Parameter(property = "project.compileClasspathElements", required = true, readonly = true)
List* If the package name ends in "/**" then this recursively transforms all sub * packages as well. *
** This is optional. When not set the agent may visit more classes to see if they need * enhancement but will still enhance effectively and pretty quickly (ignoring standard * jdk classes and lots of common libraries and language sdk's). *
*/ @Parameter(name = "packages") String packages; /** * Set to true to fail the maven build if exceptions occurred during enhancement. */ @Parameter(name = "failOnExceptions") boolean failOnExceptions; public void execute() throws MojoExecutionException { final Log log = getLog(); if (classSource == null) { classSource = "target/classes"; } File f = new File(""); log.info("Current Directory: " + f.getAbsolutePath()); StringBuilder extraClassPath = new StringBuilder(); extraClassPath.append(classSource); if (classpath != null && !classpath.isEmpty()) { if (!extraClassPath.toString().endsWith(";")) { extraClassPath.append(";"); } extraClassPath.append(classpath); } // find the packages that we should process for enhancement AgentManifestReader manifestReader = new AgentManifestReader(); // maybe configured via manifest (preferred) manifestReader.read(new File(classSource+"/META-INF/ebean.mf")); // maybe explicitly configured manifestReader.addRaw(packages); // these are the local packages to enhance (local to this artifact) Set© 2015 - 2025 Weber Informatics LLC | Privacy Policy