Gradle daemon not scoped correctly with own distribution

(Hendrik Haddorp) #1

Gradle Version: 2.13
Operating System: RHEL 7.2

I created my own Gradle distribution based on Gradle 2.13 with a custom init script. After I started the gradle daemon for my distribution the same daemon instance seems to get used as well if I want to start the a build for a plain Gradle 2.13. This has the effect that my init script is being used in places where it should not been.

(Stefan Oehme) #2

You observed correctly that the daemon is reused. But the init script is not bound to the daemon. It is only applied on projects that actually point to your custom distribution.

Do you see something else happening, i.e. your init script actually being applied to projects it shouldn’t be applied to? If so, could you share a small example that shows the problem?

(Hendrik Haddorp) #3

In my init script I apply a plugin using apply plugin: ....., to: gradle. I added some logging to the apply method of my plugin. This is not being shown when my normal build stats but in that build (which is building another plugin) I’m using the gradle test kit and once I start the GradleRunner I see the output from my plugin that is not referenced in this project.

As my setup is using multiple projects and artifactory as a maven repository it is a bit tricky to provide a test project.

(Benjamin Muschko) #4

I still don’t fully understand the setup you have in place. Would you mind putting together a sample project? It would help tremendously. The plugins can just have a simple System.out.println implementation. If that’s not possible, please provide a more detailed description of your environment and the test case you are executing with TestKit.

  • What’s the content of your init script within the custom distribution?
  • In your test case are you pointing to your custom distribution to execute the GradleRunner? If that’s not the case, are you executing the build that runs your test case with the custom distribution?
  • Please describe in detail what you are testing with TestKit and the hierarchy of plugins being applied in the test code.
  • When you say “not referenced in this project” do you mean the project being created as part of the test code?

(Hendrik Haddorp) #5

Ok, I created a sample setup and was able to reproduce it like this:

 1) git clone
 2) cd sample-gradle-init-plugin
 3) ./gradlew publisToMavenLocal
 4) cd ..

 5) git clone
 6) cd sample-gradle-distribution
 7) ./gradlew publisToMavenLocal
 8) cd ..

 9) git clone
10) cd sample-gradle-project
11) modify gradle/wrapper/ to point to local maven home (replace <home>)
12) ./gradlew dummy
-> output should show "***** Init Plugin is being applied *****" as the special gradle distribution with the init plugin is being used
-> the daemon for the sample distribution should be started now
13) cd ..

14) git clone
15) cd sample-gradle-plugin
16) ./gradlew clean build --info
-> my output contains "***** Init Plugin is being applied *****" below "sample.gradle.plugin.SamplePluginTest > testing sample plugin STANDARD_OUT"
   which implies that the init plugin from the sample distribution got applied
17) ./gradlew --stop
18) ./gradlew clean build --info
-> This time "***** Init Plugin is being applied *****" is not in the output, so the init plugin was not applied

Let me know if there are further questions.

(Benjamin Muschko) #6

Thanks for providing the sample code. I could reproduce the issue but could not the source of the issue yet. It will require me to dig much deeper. At the moment this looks like a bug in TestKit of some sort. I will keep you in the loop.