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

org.smallframework.mavenplugin.goal.EnhanceASMMojo Maven / Gradle / Ivy

The newest version!
package org.smallframework.mavenplugin.goal;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import sf.codegen.EntityEnhancerASM;
import sf.codegen.IEntityEnhancer;

import java.io.File;

/**
 * Goal which touches a timestamp file.
 */
@Mojo(name = "enhanceASM", defaultPhase = LifecyclePhase.PROCESS_CLASSES)
public class EnhanceASMMojo extends AbstractMojo {
    /**
     * @parameter property="${enhance.path}"
     */
    @Parameter(defaultValue = "${enhance.path}")
    private String path;

    /**
     * The directory containing generated classes.
     * @parameter property="${project.build.outputDirectory}"
     * @required
     */
    @Parameter(defaultValue = "${project.build.outputDirectory}")
    private File classesDirectory;

    /**
     * 基路径
     * @parameter property="${basedir}"
     * @required
     * @readonly
     */
    @Parameter(defaultValue = "${basedir}")
    protected String basedir;

    public void setPath(String path) {
        this.path = path;
    }

    public void execute() {
        long time = System.currentTimeMillis();
        try {
            this.getLog().info("Ormbuilder enhanceing entity classes......");
            File f = null;
            if (path == null) {
                f = classesDirectory;
            } else {
                f = new File(path);
            }
            this.getLog().info("Ormbuilder enhance entity classes working path is: " + f.getAbsolutePath());

            IEntityEnhancer en = new EntityEnhancerASM().addRoot(f.toURI().toURL());
            en.enhance();

            this.getLog().info("Ormbuilder enhance entity classes total use " + (System.currentTimeMillis() - time) + "ms");
        } catch (Exception e) {
            this.getLog().error(e);
        }
    }

    public String getPath() {
        return path;
    }

    public File getClassesDirectory() {
        return classesDirectory;
    }

    public String getBasedir() {
        return basedir;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy