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

Prepare for Gradle 2.12's compileOnly configurations #239

Open tbroyer opened 8 years ago

tbroyer commented 8 years ago

Gradle 2.12 will automatically create a compileOnly configuration for each added SourceSet in a Java project (this is in the JavaBasePlugin, see here), and configure the source set's compilationClasspath to use it (as it extends the compile configuration).

The gradle-appengine-plugin currently:

  1. creates the functionalTestCompile and functionalTestRuntime configurations, which can actually be created on-the-fly by the JavaBasePlugin when creating the functionalTest source set (see here)
  2. configures the functionalTest source set's compilationClasspath (and runtimeClasspath) to “add” the main source set's output; but does it using the functionalTestCompile configuration, not the default compilationClasspath (and runtimeClasspath) as already populated by Gradle. When used with the upcoming Gradle 2.12, this means the functionalTestCompileOnly configuration created by Gradle will be ignored (but will still exist).

Now, maybe the default configuration I hint above wasn't done that way (or at all) in previous versions of Gradle, which explains why you create everything by hand here. I however thing it should be possible to somehow code defensively in preparation for Gradle 2.12 (either using the default value of compilationClasspath as configured by Gradle, or if it didn't always configure it automatically then looking for a functionalTestCompileOnly configuration and use it for the compilationClasspath in place of –or in addition to– the functionalTestCompile one that you create).

Disclaimer: I don't use AppEngine, I don't use this plugin; but I was asked to support functionalTest in my net.ltgt.apt plugin for Gradle (see https://github.com/tbroyer/gradle-apt-plugin/issues/18), and I also try to get its features integrated within Gradle proper, so I looked at the gradle-appengine-plugin source code and saw the above.

Note that supporting Gradle 2.12's compileOnly configurations using "feature detection" (rather than version comparision) would also mean that the gradle-appengine-plugin would automatically be compatible with the net.ltgt.apt plugin ;-)

loosebazooka commented 8 years ago

This is interesting, I'll take a look.