0.11 and sourceSets (pmd, checkstyle and findbugs broken)

235 views
Skip to first unread message

Stefan Hoth

unread,
Jun 11, 2014, 6:14:25 AM6/11/14
to adt...@googlegroups.com
Hi,

just a quick question: In 0.11 of the plugin you changed the directory structure of some output files (e.g. build/lint-results.xml to build/outputs/lint-results.xml, build/classes to build/intermediates/classes etc).

We figured this out and could make our static code analysis tools work again but it seems they can't find the source sets anymore and come out with empty results or missing classes.

So my question is: Did you also rename gradleProject.android.sourceSets*.java.srcDirs or similar fields?

Thanks,
Stefan

Paul Blundell

unread,
Jun 11, 2014, 11:45:10 AM6/11/14
to adt...@googlegroups.com

Gradle Plugin 0.11 replaces the default File of source sets with DefaultAndroidSourceDirectorySet

For example this gradle code below:


project.subprojects.each { submodule -> submodule.android.sourceSets.each { sourceSet -> sourceSet.java.each { file ->

// This 'file' used to be of type java.io.File now it is com.android.build.gradle.internal.api.DefaultAndroidSourceDirectorySet

}

}}

Therefore if you made any assumptions about this variable (for instance using toString() ) they will now be broken. The new DefaultAndroidSourceDirectorySet has an overridden toString method that returns the toString of an internal list. Before you may have got "src/java/main" and now you will get "[src/java/main]".

This was a rough analysis, I'm sure the changelog has better insight.

Xavier Ducrohet

unread,
Jun 11, 2014, 1:02:38 PM6/11/14
to adt...@googlegroups.com
We didn't rename the fields, but android.sourceSets*.java is not the same type as before.

This is because we used to use an internal Gradle class and we needed to move away from using their internal classes to avoid breakage when Gradle does an update.

Long term we'll move to their new source model (introduced with the native support), but for now we had to get away from the internal stuff ASAP.

project.android.sourceSets*.java.srcDirs should still work.
Project.android.sourceSets*.java.sourceFiles also works and returns a FileTree with the include/exclude patterns applied.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Tom Billiet

unread,
Jun 20, 2014, 9:29:07 AM6/20/14
to adt...@googlegroups.com
Did also change something regarding the order how the sourcesets are evaluated?

We used to do this but it does no longer work:
AfterEvaluate {
  android.sourceSets.main.java.srcDir file(typesDir)
}
The directory is added to the sourceset but that is not picked up by the compileDebugJava task. If the directory is added without afterEvaluate it works fine, but unfortunately in my script I don't know the value yet at that point.

Thanks,
Tom

Op woensdag 11 juni 2014 19:02:38 UTC+2 schreef Xavier Ducrohet:

Stefan Hoth

unread,
Jun 20, 2014, 9:33:09 AM6/20/14
to adt...@googlegroups.com
My colleague Paul posted the explanation what we needed change a week ago but it seems to be lost in the moderation queue. I know you're busy right now, Xavier, but could you check please?

thx,
Stefan

Tom Billiet schrieb:
You received this message because you are subscribed to a topic in the Google Groups "adt-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adt-dev/Bt6hagxzqR0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adt-dev+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages