GoogleCloudPlatform / gradle-appengine-plugin

Gradle plugin that provides tasks for uploading, running and managing Google App Engine projects
Apache License 2.0
236 stars 60 forks source link

Functional test runtime classpath doesn't include libraries #166

Closed xylo04 closed 9 years ago

xylo04 commented 9 years ago

While trying to upgrade the plugin from 1.9.7 to 1.9.17, I'm getting ClassNotFoundExceptions in the appengineFunctionalTest task. Upon closer inspection, I see the pertinent library JARs (for Restlet, in my case) being included in the classpath of the compileFunctionalTestJava task, but not the execution task. Here's a summary of my Gradle build log with debug and stacktrace enabled:

22:26:38.243 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':compileFunctionalTestJava'.
...
22:26:38.249 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -d /home/chris/git/choremonger/build/classes/functionalTest -g -classpath /home/chris/git/choremonger/build/classes/main:/home
/chris/git/choremonger/build/resources/main:/home/chris/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/1.3.9/40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf/jsr305-1.3.9.jar:<more jars>:/home/chris/.gradle/caches/modules-2/files-2.1/org.restlet.gae/org.restlet/2.2.1/b2c0fe435735c202b802b39a9e98c38e15
392c3b/org.restlet-2.2.1.jar:/home/chris/.gradle/caches/modules-2/files-2.1/org.restlet.gae/org.restlet.ext.jackson/2.2.1/c031bfb3cd0c5797a2497e7f784a83410c4837ea/org.restlet.ext.jackson-2.2.1.jar:/home/chris/.gradle/caches/modules
-2/files-2.1/org.restlet.gae/org.restlet.ext.servlet/2.2.1/549bc6eac583e3454a9e5d32dd51e6d3c779a826/org.restlet.ext.servlet-2.2.1.jar:/home/chris/.gradle/caches/modules-2/files-2.1/org.restlet.jse/org.restlet.ext.guice/2.2.1/ac15cf
98c26b48e554d443d73f43b416fe573f53/org.restlet.ext.guice-2.2.1.jar:<more jars> /home/chris/git/choremonger/src/functionalTest/java/com/xylo04/choremonger/web/functional/AbstractResourceTest.java <more java files>
...
Finished executing task ':compileFunctionalTestJava'
...
...
...
22:26:38.555 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':appengineFunctionalTest'.
...
22:26:38.752 [DEBUG] [org.gradle.process.internal.DefaultWorkerProcessFactory] Using application classpath [/home/chris/git/choremonger/build/classes/main, /home/chris/git/choremonger/build/resources/main, /home/chris/git/choremong
er/build/classes/functionalTest, /home/chris/git/choremonger/build/resources/functionalTest]
22:26:38.752 [DEBUG] [org.gradle.process.internal.DefaultWorkerProcessFactory] Using implementation classpath [file:/usr/local/lib/gradle-2.2.1/lib/plugins/gradle-dependency-management-2.2.1.jar, file:/usr/local/lib/gradle-2.2.1/li
b/plugins/jarjar-maven-settings-3.0.4.jar, <more jars, but not restlet>]
...
22:26:40.412 [DEBUG] [TestEventLogger] com.xylo04.choremonger.web.functional.PersonResourceTest > initializationError FAILED
22:26:40.413 [DEBUG] [TestEventLogger]     java.lang.NoClassDefFoundError: org/restlet/resource/ResourceException
22:26:40.413 [DEBUG] [TestEventLogger]         at java.lang.Class.getDeclaredMethods0(Native Method)
22:26:40.413 [DEBUG] [TestEventLogger]         at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
...
22:26:40.417 [DEBUG] [TestEventLogger]         Caused by:
22:26:40.417 [DEBUG] [TestEventLogger]         java.lang.ClassNotFoundException: org.restlet.resource.ResourceException
22:26:40.417 [DEBUG] [TestEventLogger]             at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
22:26:40.417 [DEBUG] [TestEventLogger]             at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

I'm actually attempting to learn more about Gradle and Groovy, so if you can provide a little guidance to using a local copy of the plugin in my project dependencies, I may be able to send you a pull request.

xylo04 commented 9 years ago

I should mention too, this used to work with my Restlet dependencies defined only as compile dependencies. I've tried duplicating them as functionalTestRuntime deps, but Gradle told me Cannot change configuration ':functionalTestRuntime' after it has been resolved. Duplicating the Restlet targets as testRuntime deps was fine with Gradle, but it didn't solve the issue.

loosebazooka commented 9 years ago

Yeah I think 1.9.17 might have a few issues with functionalTest that were fixed since it was released. I would try building off head here and maybe checking to see if that still works.

Clone this repo and do a "gradlew install snapshot" to install plugin version 1.9.17-SNAPSHOT into your local maven repo. Then just add mavenLocal() as a buildscript depednency to your project and change the version of your plugin to 1.9.17-SNAPSHOT.

your build file might look like :

buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
  }

  dependencies {
    classpath "com.google.appengine:gradle-appengine-plugin:1.9.17-SNAPSHOT"
  }
}
xylo04 commented 9 years ago

Yep, using the plugin at head WAI. I'll use that for now and look forward to the next release. Thanks for the pointers getting that set up!

loosebazooka commented 9 years ago

Okay I'll try to take a look again. Can you include a build file that demonstrates it? On Jan 26, 2015 7:50 PM, "Chris Keller" notifications@github.com wrote:

Yep, using the plugin at head WAI. I'll use that for now and look forward to the next release. Thanks for the pointers getting that set up!

— Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/gradle-appengine-plugin/issues/166#issuecomment-71570257 .

loosebazooka commented 9 years ago

Thanks, I think I didn't read your earlier message correctly, looks like this is fixed.