Update ByteBuddy to 1.10.18, adjust to new ByteBuddy gradle plugin #1596
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updating to ByteBuddy 1.10.18. The motivation is to include the following fix for WebLogic Server:
raphw/byte-buddy#965
In version 1.10.15, ByteBuddy changed how the Gradle plugin works. It is now automatically configured in a way which is incompatible with the current use case, therefore I configure the transformation task from the plugin manually. The specifics are included as comments for the new buildSrc classes, but I will include them in the decription as well:
ByteBuddyPluginConfigurator
:Starting from version 1.10.15, ByteBuddy gradle plugin transformation task autoconfiguration is hardcoded to be applied to javaCompile task. This causes the dependencies to be resolved during an afterEvaluate that runs before any afterEvaluate specified in the build script, which in turn makes it impossible to add dependencies in afterEvaluate. Additionally the autoconfiguration will attempt to scan the entire project for tasks which depend on the compile task, to make each task that depends on compile also depend on the transformation task. This is an extremely inefficient operation in this project to the point of causing a stack overflow in some environments.
To avoid all the issues with autoconfiguration, this class manually configures the ByteBuddy transformation task. This also allows it to be applied to source languages other than Java. The transformation task is configured to run between the compile and the classes tasks, assuming no other task depends directly on the compile task, but instead other tasks depend on classes task. Contrary to how the ByteBuddy plugin worked in versions up to 1.10.14, this changes the compile task output directory, as starting from 1.10.15, the plugin does not allow the source and target directories to be the same. The transformation task then writes to the original output directory of the compile task.
ClasspathByteBuddyPlugin
:Starting from version 1.10.15, ByteBuddy gradle plugin transformations require that plugin classes are given as class instances instead of a class name string. To be able to still use a plugin implementation that is not a buildscript dependency, this reimplements the previous logic by taking a delegate class name and class path as arguments and loading the plugin class from the provided classloader when the plugin is instantiated.
Manually verified that the shadowJar that is built includes the transformed classes.