gretty
gretty copied to clipboard
allow to specify custom groovyVersion
like "toolVersion" in gradle PMD plugin, please allow to specify groovy version for gretty plugin. Or silently use groovy version already available in classpath.
Currently latest groovy is 2.3.6, gretty uses 2.3.3.
Then during "gradle appRun" exception occurs:
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.3 and you are trying to load version 2.3.6
As a hint - possible cause can be in "about" gradle plugin:
Groovy [2.3.3], project ':bootstrap', plugin [com.github.goldin.plugins.gradle.about.AboutPlugin] is applied, added task 'about'.
I upgraded Gretty on master to Groovy 2.3.6 (available on github, not released to maven central or jcenter yet). So, it should be working with your version of groovy.
I looked into the sources of Pmd plugin. "toolVersion" property affects the dependencies, which are injected by Pmd plugin to project's configuration:
config.incoming.beforeResolve {
if (config.dependencies.empty) {
VersionNumber version = VersionNumber.parse(extension.toolVersion)
String dependency = (version < VersionNumber.version(5))?
"pmd:pmd:$extension.toolVersion" : "net.sourceforge.pmd:pmd:$extension.toolVersion"
config.dependencies.add(project.dependencies.create(dependency))
}
}
Gretty does inject dependencies to the target project, but those are only servlet-api and servlet-container dependencies. Groovy is not injected to the target project. So there's nothing to fix here.
Gretty itself depends on Groovy. I don't think it would be possible to get rid of this dependency (or make it "dynamic").
You might try adding something like this to your build script:
buildscript {
classpath 'org.codehaus.groovy:groovy-all:2.3.6'
classpath 'org.akhikhl.gretty:gretty:+'
// ...
}
in attempt to override groovy versions used by various gradle plugins.
Hi Andrey, thanks for quick reply. I'm still investigating this issue, as it prevents from running appRun gretty task.
This is what i've found so far:
- localGroovy() returns 2.3.3 dependency bundled with Gradle 2.0
-
gradle dependencyInsight --configuration compile --dependency groovy
shows the following:
>gradle dependencyInsight --configuration compile --dependency groovy
:bootstrap:dependencyInsight
org.codehaus.groovy:groovy-all:2.3.6 (selected by rule)
+--- compile
\--- project:module:0.1.0-SNAPSHOT
\--- compile
(*) - dependencies omitted (listed previously)
BUILD SUCCESSFUL
Total time: 22.027 secs
Also found this https://github.com/evgeny-goldin/gradle-plugins/blob/master/common/src/main/groovy/com/github/goldin/plugins/gradle/common/BasePlugin.groovy
project.logger.info(
"Java version '${ System.getProperty( 'java.version' )}', Groovy version '$GroovySystem.version', " +
"$project evaluated, plugin '${ this.class.name }' is applied, " +
"added task${ tasks.size() == 1 ? '' : 's' } '${ tasks.keySet().sort().join( '\', \'' )}'." )
From http://groovy.codehaus.org/api/groovy/lang/GroovySystem.html it becomes clear that actual groovy version is printed.
Setting "compile"-time version of Groovy in buildscript, unfortunately, has no effect. What worked is to rollback to 2.3.3 groovy version.
Can you please look at sources of this "about" plugin? It looks like i'm missing smth. important by being unable to change resolved groovy version when i'm running "gretty" + "about" together. Or maybe this plugin does not favor "buildscript" instructions.
UPD: found this
Could you, please, create a simplest "build.gradle" allowing to reproduce the problem?
I also have this problem. We have been stuck with gretty 1.1.8.
Any version later will not allow use to use groovy-all: 2.4.3.
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.3'
This problem is consistent within several projects that use gretty.
If put in classpath 'org.akhikhl.gretty:gretty:1.2.3', then we get
Caused by: java.lang.ExceptionInInitializerError
at at org.codehaus.groovy.reflection.ClassInfo.isValidWeakMetaClass(ClassInfo.java:262)
at at org.codehaus.groovy.reflection.ClassInfo.getMetaClassForClass(ClassInfo.java:232)
at at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:277)
at at ch.qos.logback.classic.gaffer.GafferConfigurator.$getStaticMetaClass(GafferConfigurator.groovy)
at at ch.qos.logback.classic.gaffer.GafferConfigurator.
I recreated a project, I added all the same dependencies as my full project that was having the problem. No problems. The problems started as soon as I added logback.groovy to the project.
10:27:53,908 |-ERROR in ch.qos.logback.classic.util.ContextInitializer@4c7e1674 - Failed to instantiate ch.qos.logback.classic.gaffer.GafferConfigurator java.lang.reflect.InvocationTargetException at java.lang.reflect.InvocationTargetException at at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] at at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1002)
at at ch.qos.logback.classic.gaffer.GafferUtil.newGafferConfiguratorInstance(GafferUtil.java:52)
at at ch.qos.logback.classic.gaffer.GafferUtil.runGafferConfiguratorOn(GafferUtil.java:41)
at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:68)
at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:152)
at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:141)
at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:120)
at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:331)
at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:283)
at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:657)
at at org.springframework.web.contextder.initWebApplicationContext(ContextLoader.java:282)
at at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:800)
at at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
at at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
at at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)
at at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
at at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
at at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
at at org.akhikhl.gretty.JettyWebAppContext.super$10$doStart(JettyWebAppContext.groovy)
at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at at java.lang.reflect.Method.invoke(Method.java:606)
at at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206)
at at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130)
at at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150)
at at org.akhikhl.gretty.JettyWebAppContext.doStart(JettyWebAppContext.groovy:44)
at at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLva:68)le.ja
at at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163)
at at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at at org.eclipse.jetty.server.Server.start(Server.java:387)
at at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at at org.eclipse.jetty.util.component.LifeCycle$start$0.call(Unknown Source)
at at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at at org.akhikhl.gretty.JettyServerManager.startServer(JettyServerManager.groovy:47)
at at org.akhikhl.gretty.ServerManager$startServer$0.call(Unknown Source)
at at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at at org.codehaus.groovy.lsite.AbstractCallSite.call(AbstractCallSite.java:108)
at at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at at org.akhikhl.gretty.Runner.run(Runner.groovy:126)
at at org.akhikhl.gretty.Runner.this$2$run(Runner.groovy)
at at org.akhikhl.gretty.Runner$this$2$run.call(Unknown Source)
at at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at at org.akhikhl.gretty.Runner.main(Runner.groovy:53)
Caused by: java.lang.ExceptionInInitializerError
at at org.codehaus.groovy.reflection.ClassInfo.isValidWeakMetaClass(ClassInfo.java:262)
at at org.codehaus.groovy.reflection.ClassInfo.getMetaClassForClass(ClassInfo.java:232)
at at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:277)
at at ch.qos.logback.classic.gaffer.GafferConfigurator.$getStaticMetaClass(GafferConfigurator.groovy)
at at ch.qos.logback.classic.gaffer.GafferConfigurator.
10:27:53 INFO Initializing Spring root WebApplicationContext 10:27:55 WARN Failed startup of context o.a.g.JettyWebAppContext@7d09daf0{/security-service,file:/D:/workspaces/gretty/build/inplaceWebapp/,STARTING} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.support.ScheduledMethodRunnable#0': Cannot resolve reference to bean 'noopTask' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'noopTask' defined in class path resource [schedule/schedule-noop.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class groovy.lang.GroovySystem
Here is a sample project. https://github.com/matthew-b-payne/gretty-logback-groovy-bug
Fixed in Gretty 1.2.4
^^ is there a current snapshot to test this with? Think I am pointing to snapshots e.g classpath 'org.akhikhl.gretty:gretty:+'
Last one I see is: gretty-1.2.4-20150531.152233-7.pom.sha1 31-May-2015 15:22 40 bytes With that I believe it still exhibits the problem.
Matt
Yes, 1.2.4-SNAPSHOT is already at jfrog artifactory. I plan to release Gretty 1.2.4 tomorrow.
Cool, thank you for the work. That seemed to do the trick.
So, I hope this is related: I have a project that requires groovy 2.3.x.
When I upgrade Gretty to 2.0.0, it looks like the runtime environment is using Groovy 2.4.5, which causes tests to fail. Any ideas?