File: README.md

package info (click to toggle)
byte-buddy 1.14.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,684 kB
  • sloc: java: 186,543; xml: 7,684; sh: 217; ansic: 101; makefile: 14
file content (41 lines) | stat: -rw-r--r-- 2,503 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Byte Buddy Maven Plugin

The **Byte Buddy Maven Plugin** enables you to apply bytecode enhancements during the build process. To activate this process, add the following sections to your project POM file:

###### pom.xml
```xml
  <build>
    <plugins>
      <plugin>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy-maven-plugin</artifactId>
        <version>LATEST</version>
        <executions>
          <execution>
            <goals>
              <goal>transform</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <transformations>
            <transformation>
              <groupId>net.bytebuddy</groupId>
              <artifactId>byte-buddy</artifactId>
              <version>LATEST</version>
              <plugin>net.bytebuddy.build.CachedReturnPlugin</plugin>
            </transformation>
          </transformations>
        </configuration>
      </plugin>
    </plugins>
  </build>
```

This example transformation uses a standard plugin that is shipped with Byte Buddy, which caches any method return value if annotated by `CachedReturnPlugin.Enhance`. The plugin in the example is applied onto the main source set, test classes can be transformed by specifying the *transform-test* goal. Furthermore, it is possible to transform production classes while retaining runtime classes by using *transform-runtime*, or to retain dependencies of all non-test scopes by *transform-extended*. Custom plugins must implement Byte Buddy's `Plugin` interface where the plugin's location is specified by Maven artifact coordinates as shown in the example. The coordinates can be dropped if the plugin is contained within the transformed artifact itself.

A plugin can declare a constructor that takes arguments of type `File`, `BuildLogger` or a Gradle-specific `Logger` where the class file root directory or an appropriate logger is provided. It is also possible to supply an argument explicitly by specifying an argument in the plugin configuration.

A plugin can be applied automatically when it is included as a dependency of the *byte-buddy-maven-plugin* configuration and if the plugin's containing jar file declares the plugin's name in the *META-INF/net.bytebuddy/build.plugins* file.

The plugin supports Maven's `BuildContext` and incremental build feature which is currently supported by the Eclipse IDE. To enable it, it needs to be activated explicitly by setting the `incremental` property to `true`.