diff --git a/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/AnimalSnifferPlugin.groovy b/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/AnimalSnifferPlugin.groovy index 02fabd3..014faa4 100644 --- a/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/AnimalSnifferPlugin.groovy +++ b/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/AnimalSnifferPlugin.groovy @@ -58,7 +58,7 @@ class AnimalSnifferPlugin implements Plugin { private Project project private AnimalSnifferExtension extension private AnimalSnifferSignatureExtension buildExtension - private boolean init; + private boolean init @Override void apply(Project project) { @@ -158,7 +158,7 @@ class AnimalSnifferPlugin implements Plugin { } } configureCheckTask(checkTask, - project.provider { project.files(sourceSet.allJava.srcDirs ) }, + project.provider { project.files(sourceSet.allJava.srcDirs) }, sourceSet.getTaskName(ANIMALSNIFFER_CACHE, null), sourceSet.classesTaskName, sourceSet.compileClasspath) @@ -209,10 +209,11 @@ class AnimalSnifferPlugin implements Plugin { @SuppressWarnings('ClassForName') private TaskProvider createAndroidClassesCollector(String taskName, Object variant) { TaskProvider collectClasses = project.tasks.register(taskName, AndroidClassesCollector) - Class scopedArtifactsScopeType = Class - .forName('com.android.build.api.variant.ScopedArtifacts.Scope') - Class scopedArtifactTypeClasses = Class - .forName('com.android.build.api.artifact.ScopedArtifact.CLASSES') + // use variant class loader because plugin classpath did not "see" android deps + Class scopedArtifactsScopeType = variant.class.classLoader + .loadClass('com.android.build.api.variant.ScopedArtifacts$Scope') + Class scopedArtifactTypeClasses = variant.class.classLoader + .loadClass('com.android.build.api.artifact.ScopedArtifact$CLASSES') variant.artifacts.forScope(scopedArtifactsScopeType.PROJECT).use(collectClasses) .toGet(scopedArtifactTypeClasses.INSTANCE, diff --git a/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/util/AndroidClassesCollector.groovy b/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/util/AndroidClassesCollector.groovy index 7e3c9e5..8187522 100644 --- a/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/util/AndroidClassesCollector.groovy +++ b/src/main/groovy/ru/vyarus/gradle/plugin/animalsniffer/util/AndroidClassesCollector.groovy @@ -28,7 +28,8 @@ abstract class AndroidClassesCollector extends DefaultTask { @OutputDirectory abstract DirectoryProperty getOutputDirectory() - protected AndroidClassesCollector() { + @SuppressWarnings('AbstractClassWithPublicConstructor') + AndroidClassesCollector() { outputDirectory.value(project.layout.buildDirectory.dir('intermediates/animal_sniffer/' + name)) }