I have a gradle race condition intermittent behavior on resources

(Dean Hiller) #1

JPA conflicts a bit with src/main/resources in that I had to do something like this

//ok, this is the deal here. JPA/hibernate made the decision to look for a persistence.xml file
//AND scan for classes with @Entity in the directory OR jar with that xml file only
//maven(and I hate this) a long time ago separated src/main/java and src/main/resources but
//this screws tools in many situations like this one so this puts it back so the output is at
//least put to the same location
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
compileJava.doLast {
//I literally just added this so next time it happens, I can look for this log…
logger.warn(“processed resources=”+sourceSets.main.output.resourcesDir)

I am on this gradle version

I am using these parallel gradle properties though (which claim to be in experimental mode)

The speedup is too nice to not have these. I am going to comment out configureondemand and see if I can still reproduce it over the next week though.

My issue however is that there is some sort of race condition though the tasks that I am most interested appear to go in order just fine…


However, the src/main/resources on this project are only copied over 90% of the time to the output directories. The funny thing is the directories are there from src/main/resources. The class files are there as well. Just all the resources are missing but only 1 every 10 runs or so AND my script does a ‘./gradlew clean build’ every time and I just run the .sh script.

It’s very weird and seems to be some sort of race condition.

I will add more info as I find out myself what is going on but I am hoping a little it may be a known issue or something or I am doing something wrong.

(Dean Hiller) #2

More info. commenting out

but I still hit the issue AND I see my log file as well which is before tests run

processed resources=/Library/Workflow/webpieces/webserver/webpiecesServerBuilder/templateProject/WEBPIECESxAPPNAME/output/classes/main

but alas, no resource files are there this run. What other logs can I add to debug this situation?

I really want org.gradle.parallel=true as the speedup is 2 minutes 20 seconds down to 52 seconds, but it seems the parallel keeps hitting the race condition(when I comment it out, I never see it fail).

Is there something behind this method

that kicks off a background thing that I need to somehow block on before tests are run?