Specifying plugin class in bytebuddy gradle plugin - gradle

I have updated ByteBuddy Gradle plugin to the version 1.11.18.
Unlikely the previous version, where I could set up byteBuddy.transform.plugin as a string, in the latest version I have to set it up as a class.
Cannot cast object 'com.test.PluginImpl.class' with class 'java.lang.String' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: com.test.PluginImpl.class
I'm trying to figure out how to get the plugin applied
I followed the readme (https://github.com/raphw/byte-buddy/tree/master/byte-buddy-gradle-plugin#buildgradle):
byteBuddy {
transformation {
plugin = com.test.PluginImpl.class
}
}
However, I've got the error:
* What went wrong:
A problem occurred evaluating root project 'Test'.
> Could not get unknown property 'com' for object of type net.bytebuddy.build.gradle.Transformation.

Did you add the plugin to the buildsource? Groovy is a bit guessy when it comes to these things. Also try importing the class and using the unqualified name.
The old approach did no longer work properly with newer Gradle versions which is why I had to redo it.

Related

Caused by groovy.lang.MissingPropertyException Could not get unknown property 'android' for project ':lib1' of type org.gradle.api.Project

To solve my problem here: Applying JaCoCo to all Android Studio gradle modules, I applied the solution here. This works fine so far for modules with
plugins {
id("com.android.library")
}
As soon as I add the required apply from: '../jacoco/modules.gradle' into a module labeled as a Java library
plugins {
id("java-library")
}
I get a
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'android' for project ':lib1' of type org.gradle.api.Project.
I would like to add the apply from to the java library, so that JaCoCo reports were generated for them as well. What am I missin here?
I assume you have also applied the snippet from the “Improvements” section of the solution you have linked to your ../jacoco/modules.gradle file? In that case you could replace that snippet with the following:
project.afterEvaluate {
if (project.pluginManager.hasPlugin('com.android.library')) {
android.libraryVariants.all { variant ->
tasks.create(…)
}
} else {
tasks.create(…)
}
}
If that doesn’t solve it, then I’d recommend to run the build with Gradle’s --stacktrace option. That should give you more details on where exactly the missing property was found.
Without more information on your exact build setup it’s hard to really say more.

Gradle upgrade 7.2 > 7.3 breaks with "The value for this property is final and cannot be changed any further" (with Micronaut plugin?)

I'm using Micronaut 3.1.3 together with Gradle 7.2 to build my project.
After switching to Gradle 7.3, built breaks emitting some context-free error message:
$ ./gradlew clean build
Executed by Gradle 7.3
- using Java 11.0.13
- using Kotlin 1.5.31
- using Groovy 3.0.9
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project '[PROJECT]'.
> The value for this property is final and cannot be changed any further.
With --stacktrace a very long trace appears. The following excerpt makes me guess
that the problem might lay in the Micronaut plugin:
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project '[PROJECT]'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
[...]
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
Caused by: java.lang.IllegalStateException: The value for this property is final and cannot be changed any further.
at org.gradle.api.internal.provider.AbstractProperty$FinalizedValue.beforeMutate(AbstractProperty.java:489)
at org.gradle.api.internal.provider.AbstractProperty.assertCanMutate(AbstractProperty.java:263)
at org.gradle.api.internal.provider.AbstractProperty.setSupplier(AbstractProperty.java:212)
at org.gradle.api.internal.provider.DefaultProperty.set(DefaultProperty.java:71)
at org.gradle.api.tasks.testing.Test.useTestFramework(Test.java:979)
at org.gradle.api.tasks.testing.Test.useJUnitPlatform(Test.java:1049)
at org.gradle.api.tasks.testing.Test.useJUnitPlatform(Test.java:1032)
at io.micronaut.gradle.MicronautLibraryPlugin.lambda$null$1(MicronautLibraryPlugin.java:103)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:123)
[...]
at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:201)
at io.micronaut.gradle.MicronautLibraryPlugin.lambda$apply$4(MicronautLibraryPlugin.java:101)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:123)
[...]
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
Cause "problem occurred configuring root project" I'm not sure which part of my
build.gradle raises the problem. So following my first guess regarding Micronaut
plugin, here is an excerpt telling you the list of plugins in use and config of this plugin:
plugins {
id('org.jetbrains.kotlin.jvm') version "${kotlinVersion}"
id('groovy')
id('org.jetbrains.kotlin.kapt') version "${kotlinVersion}"
id('com.github.johnrengelman.shadow') version '7.+'
id('io.micronaut.application') version '2.+'
id('org.jetbrains.kotlin.plugin.allopen') version "${kotlinVersion}"
id('com.google.cloud.tools.jib') version '3.+'
id('org.openapi.generator') version '5.+'
id('com.heroku.sdk.heroku-gradle') version '2.+'
}
[...]
micronaut {
runtime('netty')
testRuntime('spock2')
processing {
incremental(true)
annotations('[PACKAGE]')
}
}
Maybe this gives enough information to tackle down the cause of the problem?
If not please let me know.
Regards
I hit the same issue with my Java build and asked for help on gradle slack channel. It found to be a change in Gradle 7.3 behavior.
This issue contains an explanation of the cause and how to fix it.
It helped me to solve the issue with my build: I had options defined in one of the test tasks and then useJUnitPlatform was applied across all test tasks afterwards using this snippet:
tasks.withType(Test).configureEach {
useJUnitPlatform() // <-- this line was breaking the build
}
This broke the build after migrating to Gradle 7.3. Removing options solved the problem for me.
Here's an issue requesting to convert this breaking behavior to a warning in Gradle 7.3 and make it a breaking change in 8.0.
FYI: Upgrade to Gradle 7.3.1 brings back successful builds.

Issue while building spring-framework source

I am facing some issue while building spring-framework source, what is the issue?
FAILURE: Build failed with an exception.
Where:
Build file '/home/steph/workspace_sts/spring-framework/spring-beans/spring-beans.gradle' line: 30
What went wrong:
A problem occurred evaluating project ':spring-beans'.
> No such property: values for class: org.gradle.api.internal.tasks.DefaultTaskDependency
Possible solutions: values
It seems to be saying that the class DefaultTaskDependency does not have a field and getter/setter called getValues()/setValues() but the gradle build file is passing in some data which it is trying to set by calling setValues() and passing whatever data is in the gradle.build file under values. I would double check which version of gradle spring source says it needs to be built with vs. what version you are building it with.

Grails 3 (Gradle) dependency without parent directory

Can I not use the following Gradle approach to dependencies in Grails? I do not have nor want a parent directory;
https://stackoverflow.com/a/19303545/2288004
When I try it, I get the the following error;
Caused by: java.lang.IllegalStateException: Expected method not found:
java.lang.NoSuchMethodException:
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.addApplicationListener(org.apache.catalina.deploy.ApplicationListener)
It works when I use a parent directory for the settings.gradle, but unfortunately it’s not how I want to structure the project.
The following was indeed the solution I was looking for,
include ":myplugin"
project(':myplugin').projectDir = new File(settingsDir, '../myplugin')
The error was down to how I was managing my tomcat dependencies between the two projects.
Tomcat was already being pulled in via the plugin but while I still needed to reference tomcat at compile time in the application, I also needed to make sure it was the same version, and so added the following just above "dependencies" to target the version I required;
ext['tomcat.version'] = '7.0.70'

Shadow project gradle file doesn't compile

while working with shadow plugin I tried to execute my Gradle code:
import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer
shadow {
transformer(AppendingTransformer) {
resource = 'META-INF/spring.handlers'
}
transformer(AppendingTransformer) {
resource = 'META-INF/spring.schemas'
}
}
As a result i received the folloqing error:
Could not find method transformer() for arguments [class com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer, build_bdpgdpxcevq273h2385je07ue$_run_closure2_closure5#1452aad2] on project ':ProjectX'.
Am i missing something? where does the 'transformer' function should be defined?
Your question lack some information, but from the error you pasted it looks like the shadow extension does not really contain a transformer method (thus trying to find it on the owner object - project). To me it means that you are probably using one of the latest (latest being the 1.2.2 version) versions of the shadow plugin whilst trying to configure it in some old not-supported way.
In the newer versions you should configure the plugin via the
shadowJar {
transform(AppendingTransformer) {
resource = 'NOTICE'
}
}
Configuration closure and not the old notiation
shadow {}
See here the new README file, and here the old README file.

Resources