public abstract class ByteBuddyMojo extends AbstractMojo
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ByteBuddyMojo.Coordinate
A coordinate to locate a managed dependency.
|
static class |
ByteBuddyMojo.ForDependencyFolder
Transforms all jars for a folder containing jar files, typically project dependencies.
|
static class |
ByteBuddyMojo.ForExplicitLocations
Transforms specified classes from files in a folder or a jar file to a folder or jar file.
|
static class |
ByteBuddyMojo.ForLifecycleTypes
A version of the plugin that is bound to Maven's lifecycle.
|
protected static class |
ByteBuddyMojo.MavenBuildLogger
A
BuildLogger implementation for a Maven Log. |
protected static class |
ByteBuddyMojo.StalenessFilter
A filter for files that were written before a given timestamp, to avoid duplicate application.
|
protected static class |
ByteBuddyMojo.TransformationLogger
A
Plugin.Engine.Listener that logs several relevant events during the build. |
protected static class |
ByteBuddyMojo.Transformer
A transformer that is applied during the plugin's execution.
|
| Modifier and Type | Field and Description |
|---|---|
boolean |
classPathDiscovery
Scans the class path (or test class path) for Byte Buddy plugins to apply.
|
Discovery |
discovery
Determines if the build should discover Byte Buddy build plugins on this Maven plugin's class loader.
|
MojoExecution |
execution
The current execution of this plugin.
|
boolean |
extendedParsing
When set to
true, the debug information of class files should be parsed to extract parameter names. |
boolean |
failFast
When set to
true, this mojo fails immediately if a plugin cannot be applied. |
boolean |
failOnLiveInitializer
When transforming classes during build time, it is not possible to apply any transformations which require a class
in its loaded state.
|
Initialization |
initialization
The initializer used for creating a
ByteBuddy instance and for applying a transformation. |
Integer |
multiReleaseVersion
Defines the version to use for resolving multi-release jar files.
|
MavenProject |
project
The Maven project.
|
RepositorySystem |
repositorySystem
The currently used repository system.
|
RepositorySystemSession |
repositorySystemSession
The currently used system session for the repository system.
|
boolean |
skip
When set to
true, this mojo is not applied to the current module. |
int |
staleMilliseconds
Determines the tolerance of many milliseconds between this plugin run and the last edit are permitted
for considering a file as stale if the plugin was executed before.
|
String |
suffix
Specifies the method name suffix that is used when type's method need to be rebased.
|
int |
threads
Indicates the amount of threads used for parallel type processing or
0 for serial processing. |
List<Transformation> |
transformations
The list of transformations.
|
boolean |
warnOnEmptyTypeSet
When set to
true, this mojo warns of not having transformed any types. |
boolean |
warnOnMissingOutputDirectory
When set to
true, this mojo warns of an non-existent output directory. |
| Constructor and Description |
|---|
ByteBuddyMojo() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
apply(List<ByteBuddyMojo.Transformer> transformers,
List<String> elements,
Map<ByteBuddyMojo.Coordinate,String> coordinates)
Applies this mojo for the given setup.
|
void |
execute() |
protected abstract List<String> |
resolveClassPathElements(Map<ByteBuddyMojo.Coordinate,String> coordinates)
Resolves the class path elements of the relevant output directory.
|
protected Plugin.Engine.Summary |
transform(List<? extends String> classPath,
Map<ByteBuddyMojo.Coordinate,String> coordinates,
List<ByteBuddyMojo.Transformer> transformers,
Plugin.Engine.Source source,
Plugin.Engine.Target target,
File file,
boolean filtered)
Applies the instrumentation.
|
getLog, getPluginContext, setLog, setPluginContext@UnknownNull @Parameter(defaultValue="${project}", readonly=true) public MavenProject project
@UnknownNull @Parameter(defaultValue="${mojoExecution}", readonly=true) public MojoExecution execution
@UnknownNull @Component public RepositorySystem repositorySystem
@MaybeNull @Parameter(defaultValue="${repositorySystemSession}", readonly=true) public RepositorySystemSession repositorySystemSession
@MaybeNull @Parameter public List<Transformation> transformations
The list of transformations. A transformation must specify the plugin property, 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 as groupId,
artifactId and version. If any of the latter properties is not set, this projects coordinate is used.
For example, the following configuration applies the foo.Bar class which must implement Plugin from artifact
transform-artifact with this project's group and version:
<transformations> <transformation> <plugin>foo.Bar< /plugin> <artifactId>transform-artifact< /artifactId> < /transformation> < /transformations>
If the list of transformations is empty or is not supplied at all, this plugin does not apply but prints a warning.
@MaybeNull @Parameter public Initialization initialization
The initializer used for creating a ByteBuddy instance and for applying a transformation. By default,
a type is rebased. The initializer's entryPoint property can be set to any constant name of EntryPoint.Default
or 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.Qux class which must implement EntryPoint from
artifact initialization-artifact with this project's group and version:
<initialization> <entryPoint>foo.Qux< /entryPoint> <artifactId>initialization-artifact< /artifactId> < /initialization>
@MaybeNull @Parameter public String suffix
@Parameter(defaultValue="true", required=true) public boolean failOnLiveInitializer
false, this plugin does not throw an exception if such a live
initializer is defined during a transformation process.@Parameter(defaultValue="false", required=true) public boolean skip
true, this mojo is not applied to the current module.@Parameter(defaultValue="true", required=true) public boolean warnOnMissingOutputDirectory
true, this mojo warns of an non-existent output directory.@Parameter(defaultValue="true", required=true) public boolean warnOnEmptyTypeSet
true, this mojo warns of not having transformed any types.@Parameter(defaultValue="true", required=true) public boolean failFast
true, this mojo fails immediately if a plugin cannot be applied.@Parameter(defaultValue="false", required=true) public boolean extendedParsing
true, the debug information of class files should be parsed to extract parameter names.@MaybeNull @Parameter(defaultValue="EMPTY", required=true) public Discovery discovery
@Parameter(defaultValue="false", required=true) public boolean classPathDiscovery
@Parameter(defaultValue="0", required=true) public int threads
0 for serial processing.@Parameter(defaultValue="0", required=true) public int staleMilliseconds
-1 to disable.@MaybeNull @Parameter public Integer multiReleaseVersion
public void execute()
throws MojoExecutionException,
MojoFailureException
protected abstract List<String> resolveClassPathElements(Map<ByteBuddyMojo.Coordinate,String> coordinates) throws MojoExecutionException, MojoFailureException
coordinates - Versions for managed dependencies.MojoExecutionException - If the user configuration results in an error.MojoFailureException - If the plugin application raises an error.protected abstract void apply(List<ByteBuddyMojo.Transformer> transformers, List<String> elements, Map<ByteBuddyMojo.Coordinate,String> coordinates) throws MojoExecutionException, MojoFailureException, IOException
transformers - The transformers to apply.elements - The class path elements to consider.coordinates - Versions for managed dependencies.MojoExecutionException - If the plugin fails due to a user error.MojoFailureException - If the plugin fails due to an application error.IOException - If an I/O exception occurs.protected Plugin.Engine.Summary transform(List<? extends String> classPath, Map<ByteBuddyMojo.Coordinate,String> coordinates, List<ByteBuddyMojo.Transformer> transformers, Plugin.Engine.Source source, Plugin.Engine.Target target, File file, boolean filtered) throws MojoExecutionException, IOException
classPath - An iterable over all class path elements.coordinates - Versions for managed dependencies.transformers - The transformers to apply.source - The source for the plugin engine's application.target - The target for the plugin engine's application.file - The file representing the source location.filtered - true if files are already filtered and should not be checked for staleness.MojoExecutionException - If the plugin cannot be applied.IOException - If an I/O exception occurs.Copyright © 2014–2025. All rights reserved.