Open patkujawa-wf opened 2 years ago
Another example which works until I can get this sweet plugin to work is in https://stackoverflow.com/questions/45856846/how-can-i-share-build-code-script-for-all-my-gradle-projects-not-just-subprojec
allprojects {
tasks.withType(Test) {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}
}
That's odd but there is nothing different about the way the plugin is published. Have you tried running with info or debug log level turned on to perhaps get some clue? Could you also try with a specific version such as 3.1.0
instead of the +
wildcard to see if it works?
Aha, it was an issue with trying to use the plugin id, which apparently isn't supported in init scripts.
This seems to have worked:
initscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'com.adarshr:gradle-test-logger-plugin:+'
}
}
allprojects {
apply plugin: com.adarshr.gradle.testlogger.TestLoggerPlugin
}
Whoops, I guess the work isn't done. Now I get this exception over and over when I run my tests:
Failed to notify test listener.
org.gradle.internal.event.ListenerNotificationException: Failed to notify test listener.
...
Caused by: java.lang.AbstractMethodError: groovy/lang/GroovyObject.getProperty(Ljava/lang/String;)Ljava/lang/Object;
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190)
at groovy.lang.Closure.getPropertyTryThese(Closure.java:313)
at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:307)
at groovy.lang.Closure.getProperty(Closure.java:296)
at com.adarshr.gradle.testlogger.logger.SequentialTestLogger$_afterTest_closure2.doCall(SequentialTestLogger.groovy:39)
at com.adarshr.gradle.testlogger.logger.SequentialTestLogger$_afterTest_closure2.call(SequentialTestLogger.groovy)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2330)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2315)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2356)
at com.adarshr.gradle.testlogger.logger.SequentialTestLogger.afterTest(SequentialTestLogger.groovy:36)
at com.adarshr.gradle.testlogger.logger.TestLoggerAdapter.afterTest(TestLoggerAdapter.groovy:81)
at com.adarshr.gradle.testlogger.logger.TestLoggerWrapper.afterTest(TestLoggerWrapper.groovy:25)
at jdk.internal.reflect.GeneratedMethodAccessor368.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:43)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:245)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:157)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:61)
... 41 more
Perhaps something to do with being written in groovy? I can test with the normal way of using this plugin and see if that also fails similarly.
I get the same exception when using the plugin in my project's build.gradle, so perhaps just something with my setup?
@patkujawa-wf same here
The exception you are seeing is mostly as a result of https://github.com/radarsh/gradle-test-logger-plugin/issues/241#issuecomment-1060628271. There is nothing that can be done about that if you are using Gradle < 7 and plugin version > 3.1.0 I'm afraid.
Is it possible to use this plugin as an init script?
I use https://github.com/ben-manes/gradle-versions-plugin#using-a-gradle-init-script for all my projects, which is very convenient and allows me to keep it out of each repo. I'd like to do the same for gradle-test-logger-plugin, but I'm running into "Plugin with id 'com.adarshr.test-logger' not found." when I mimic the instructions.
I've created a
$HOME/.gradle/init.d/gradle-test-logger-plugin.gradle
(similar to my current$HOME/.gradle/init.d/add-versions-plugin.gradle
that's working) with these contents:I've tried a few variations of
repositories
and using buildscript instead of initscript, but all end up with the samePlugin with id 'com.adarshr.test-logger' not found.
failure.