Skip to content

Commit 697fe12

Browse files
committed
Exclude from analysis autogenerated classes
1 parent 468714c commit 697fe12

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/groovy/com/monits/gradle/sca/ClasspathAware.groovy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ import java.util.zip.ZipFile
3333
@CompileStatic
3434
trait ClasspathAware {
3535

36+
// AGP 3.3 and 3.4 still generated plain text R java classes
37+
private static final List<String> AUTOGENERATED_CLASSES = [
38+
'**/R.class',
39+
'**/R$*.class',
40+
'**/BuildConfig.class',
41+
'**/BuildConfig$*.class',
42+
].asImmutable()
43+
3644
private static final String DEBUG_SOURCESET = 'debug'
3745
private static final String MAIN_SOURCESET = 'main'
3846
private static final String TEST_SOURCESET = 'test'
@@ -136,7 +144,7 @@ trait ClasspathAware {
136144
* @return FileCollection pointing to all interesting .class files
137145
*/
138146
FileCollection getProjectClassTree(final Project proj, final String sourceSetName) {
139-
proj.files(pathToCompiledClasses(proj, sourceSetName))
147+
proj.fileTree(dir:pathToCompiledClasses(proj, sourceSetName), excludes:AUTOGENERATED_CLASSES)
140148
}
141149

142150
private static FileTree getJarsForAarDependencies(final Project project) {

0 commit comments

Comments
 (0)