Class BytecodeInjectionMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    public class BytecodeInjectionMojo
    extends org.apache.maven.plugin.AbstractMojo
    Used to inject resolved expression values into compiled bytecode.

    TODO : add checks as to whether the injection is needed to avoid file timestamp changes. Basically we should skip the injection if the class file field is already the injection value...

    • Field Detail

      • project

        protected org.apache.maven.project.MavenProject project
        The Maven Project Object
      • bytecodeInjections

        protected BytecodeInjection[] bytecodeInjections
        The injections to be performed.
      • loaderClassPath

        private javassist.LoaderClassPath loaderClassPath
      • classPool

        private javassist.ClassPool classPool
    • Constructor Detail

      • BytecodeInjectionMojo

        public BytecodeInjectionMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • buildProjectCompileClassLoader

        private java.lang.ClassLoader buildProjectCompileClassLoader()
                                                              throws org.apache.maven.plugin.MojoExecutionException
        Builds a ClassLoader based on the maven project's compile classpath elements.
        Returns:
        The ClassLoader made up of the maven project's compile classpath elements.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - Indicates an issue processing one of the classpath elements
      • projectCompileClasspathElements

        private java.util.List<java.lang.String> projectCompileClasspathElements()
                                                                          throws org.apache.maven.plugin.MojoExecutionException
        Essentially a call to MavenProject.getCompileClasspathElements() except that here we cast it to the generic type and internally handle DependencyResolutionRequiredException.
        Returns:
        The compile classpath elements
        Throws:
        org.apache.maven.plugin.MojoExecutionException - Indicates a DependencyResolutionRequiredException was encountered