can there be a maven plugin instead of javaagent to reduce startup time of an application? Many ORM tools have both javaagent and maven plugin, so it should be possible - is it? Or at least something like "CompiledClassFilesBuilder" similar in functionality to AgentBuilder :-)
It is perfectly possible to use Byte Buddy from within a Maven plugin. You can implement a ClassFileLocator for the Maven target after the compile phase and redefine the classes within this folder using a ByteBuddy instance. The API is identical to that of the AgentBuilder inside a transformer.
You would need to implement such a plugin, though. There is none currently existing.
Do however note that this static transformation has its limitations. Using a plugin, it is not possible to redefine bootstrap classes of the VM. It would also be difficult to change library classes as they are external artifacts. Finally, Byte Buddy can register live callbacks that need to be set wt runtime.
UPDATE: I just added the plugin in question and will release a Maven Byte Buddy plugin in version 1.4.21. A transformation can be added as follows:
<plugin> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-maven-plugin</artifactId> <executions> <execution> <goal>transform</goal> </execution> </executions> <configuration> <transformations> <transformation> <plugin>net.bytebuddy.test.SimplePlugin</plugin> <!-- Optionally, specify groupId, artifactId, version of the class --> </transformation> </transformations> <!-- Optionally, add 'initialization' block with EntryPoint class --> </configuration> </plugin>
The two relevant interfaces
EntryPoint are added to the library directly and are straight-forward to implement.