Class ByteBuddyMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- net.bytebuddy.build.maven.ByteBuddyMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
ByteBuddyMojo.ForProductionTypes,ByteBuddyMojo.ForTestTypes
public abstract class ByteBuddyMojo extends org.apache.maven.plugin.AbstractMojoA Maven plugin for applying Byte Buddy transformations during a build.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classByteBuddyMojo.ForProductionTypesA Byte Buddy plugin that transforms a project's production class files.static classByteBuddyMojo.ForTestTypesA Byte Buddy plugin that transforms a project's test class files.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringartifactIdThe built project's artifact id.protected booleanfailFastWhen set totrue, this mojo fails immediately if a plugin cannot be applied.protected booleanfailOnLiveInitializerWhen transforming classes during build time, it is not possible to apply any transformations which require a class in its loaded state.protected java.lang.StringgroupIdThe built project's group id.protected InitializationinitializationThe initializer used for creating aByteBuddyinstance and for applying a transformation.protected java.lang.StringpackagingThe built project's packaging.protected org.apache.maven.project.MavenProjectprojectThe Maven project.protected java.util.List<org.eclipse.aether.repository.RemoteRepository>remoteRepositoriesA list of all remote repositories.protected org.eclipse.aether.RepositorySystemrepositorySystemThe currently used repository system.protected org.eclipse.aether.RepositorySystemSessionrepositorySystemSessionThe currently used system session for the repository system.protected booleanskipWhen set totrue, this mojo is not applied to the current module.protected java.lang.StringsuffixSpecifies the method name suffix that is used when type's method need to be rebased.protected java.util.List<Transformation>transformationsThe list of transformations.protected java.lang.StringversionThe built project's version.protected booleanwarnOnMissingOutputDirectoryWhen set totrue, this mojo warns of an non-existent output directory.
-
Constructor Summary
Constructors Constructor Description ByteBuddyMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidexecute()protected abstract java.util.List<java.lang.String>getClassPathElements()Returns the class path elements of the relevant output directory.protected abstract java.lang.StringgetOutputDirectory()Returns the output directory to search for class files.
-
-
-
Field Detail
-
groupId
@Parameter(defaultValue="${project.groupId}", required=true, readonly=true) protected java.lang.String groupIdThe built project's group id.
-
artifactId
@Parameter(defaultValue="${project.artifactId}", required=true, readonly=true) protected java.lang.String artifactIdThe built project's artifact id.
-
version
@Parameter(defaultValue="${project.version}", required=true, readonly=true) protected java.lang.String versionThe built project's version.
-
packaging
@Parameter(defaultValue="${project.packaging}", required=true, readonly=true) protected java.lang.String packagingThe built project's packaging.
-
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject projectThe Maven project.
-
transformations
@Parameter protected java.util.List<Transformation> transformations
The list of transformations. A transformation must specify the
pluginproperty, containing the name of a class to apply. Additionally, it is possible to optionally specify Maven coordinates for a project that contains this plugin class asgroupId,artifactIdandversion. If any of the latter properties is not set, this projects coordinate is used.For example, the following configuration applies the
foo.Barclass which must implementPluginfrom artifacttransform-artifactwith this project's group and version:<transformations> <transformation> <plugin>foo.Bar< /plugin> <artifactId>transform-artifact< /artifactId> < /transformation> < /transformations>If the list of
transformationsis empty or is not supplied at all, this plugin does not apply but prints a warning.
-
initialization
@Parameter protected Initialization initialization
The initializer used for creating a
ByteBuddyinstance and for applying a transformation. By default, a type is rebased. The initializer'sentryPointproperty can be set to any constant name ofEntryPoint.Defaultor to a class name. If the latter applies, it is possible to set Maven coordinates for a Maven plugin which defines this class where any property defaults to this project's coordinates.For example, the following configuration applies the
foo.Quxclass which must implementEntryPointfrom artifactinitialization-artifactwith this project's group and version:<initialization> <entryPoint>foo.Qux< /entryPoint> <artifactId>initialization-artifact< /artifactId> < /initialization>
-
suffix
@Parameter protected java.lang.String suffix
Specifies the method name suffix that is used when type's method need to be rebased. If this property is not set or is empty, a random suffix will be appended to any rebased method. If this property is set, the supplied value is appended to the original method name.
-
failOnLiveInitializer
@Parameter(defaultValue="true", required=true) protected boolean failOnLiveInitializerWhen transforming classes during build time, it is not possible to apply any transformations which require a class in its loaded state. Such transformations might imply setting a type's static field to a user interceptor or similar transformations. If this property is set tofalse, this plugin does not throw an exception if such a live initializer is defined during a transformation process.
-
skip
@Parameter(defaultValue="false", required=true) protected boolean skipWhen set totrue, this mojo is not applied to the current module.
-
warnOnMissingOutputDirectory
@Parameter(defaultValue="true", required=true) protected boolean warnOnMissingOutputDirectoryWhen set totrue, this mojo warns of an non-existent output directory.
-
failFast
@Parameter(defaultValue="true", required=true) protected boolean failFastWhen set totrue, this mojo fails immediately if a plugin cannot be applied.
-
repositorySystem
@Component protected org.eclipse.aether.RepositorySystem repositorySystem
The currently used repository system.
-
repositorySystemSession
@Parameter(defaultValue="${repositorySystemSession}", required=true, readonly=true) protected org.eclipse.aether.RepositorySystemSession repositorySystemSessionThe currently used system session for the repository system.
-
remoteRepositories
@Parameter(defaultValue="${project.remoteProjectRepositories}", required=true, readonly=true) protected java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepositoriesA list of all remote repositories.
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getOutputDirectory
protected abstract java.lang.String getOutputDirectory()
Returns the output directory to search for class files.- Returns:
- The output directory to search for class files.
-
getClassPathElements
protected abstract java.util.List<java.lang.String> getClassPathElements()
Returns the class path elements of the relevant output directory.- Returns:
- The class path elements of the relevant output directory.
-
-