Skip to content

Commit 2860acb

Browse files
committed
Handle properly all sourcesets
1 parent eebb81f commit 2860acb

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/integTest/groovy/com/monits/gradle/sca/FindbugsIntegTest.groovy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,28 @@ class FindbugsIntegTest extends AbstractPerSourceSetPluginIntegTestFixture {
224224
| }
225225
|}
226226
'''.stripMargin()
227+
file('src/test/java/com/monits/ClassATest.java') << '''
228+
|package com.monits;
229+
|
230+
|import android.view.View;
231+
|
232+
|public class ClassATest {
233+
| public boolean isFoo() {
234+
| return new View(null).callOnClick();
235+
| }
236+
|}
237+
'''.stripMargin()
238+
file('src/androidTest/java/com/monits/ClassAAndroidTest.java') << '''
239+
|package com.monits;
240+
|
241+
|import android.view.View;
242+
|
243+
|public class ClassAAndroidTest {
244+
| public boolean isFoo() {
245+
| return new View(null).callOnClick();
246+
| }
247+
|}
248+
'''.stripMargin()
227249

228250
when:
229251
BuildResult result = gradleRunner()

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ final class AndroidHelper {
8686

8787
static String getCompileOutputDir(final Project project, final String sourceSetName, final String sourceSetPath) {
8888
if (getCurrentVersion(project) >= USES_JAVAC_TASK_OUTPUTS) {
89+
String outputDir = sourceSetName == 'androidTest' ? 'debugAndroidTest' :
90+
sourceSetName == 'test' ? 'debugUnitTest' :
91+
sourceSetName == 'main' ? 'debug' : sourceSetName
8992
return project.buildDir.absolutePath +
90-
"/intermediates/javac/${sourceSetName}/compile${sourceSetName.capitalize()}JavaWithJavac/classes/"
93+
"/intermediates/javac/${outputDir}/compile${outputDir.capitalize()}JavaWithJavac/classes/"
9194
}
9295

9396
project.buildDir.absolutePath + '/intermediates/classes/' + sourceSetPath + File.separator

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ trait ClasspathAware {
111111
// TODO : is it okay to always use debug?
112112
project.files(pathToCompiledClasses(project, DEBUG_SOURCESET)) +
113113
// TODO : is it okay to always include test classes?
114-
project.files(pathToCompiledClasses(project, 'testDebug')) +
114+
project.files(pathToCompiledClasses(project, TEST_SOURCESET)) +
115115
dependantModuleClasses
116116
)
117117
}

0 commit comments

Comments
 (0)