Skip to content

Commit

Permalink
fix android project init
Browse files Browse the repository at this point in the history
  • Loading branch information
xvik committed Nov 16, 2024
1 parent 1b9e39c commit 21311b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AnimalSnifferPlugin implements Plugin<Project> {
private Project project
private AnimalSnifferExtension extension
private AnimalSnifferSignatureExtension buildExtension
private boolean init;
private boolean init

@Override
void apply(Project project) {
Expand Down Expand Up @@ -158,7 +158,7 @@ class AnimalSnifferPlugin implements Plugin<Project> {
}
}
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)
Expand Down Expand Up @@ -209,10 +209,11 @@ class AnimalSnifferPlugin implements Plugin<Project> {
@SuppressWarnings('ClassForName')
private TaskProvider<AndroidClassesCollector> createAndroidClassesCollector(String taskName, Object variant) {
TaskProvider<AndroidClassesCollector> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit 21311b5

Please sign in to comment.