forked from Western-parotia/EaseLint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArtifactsImplProxy.java
34 lines (26 loc) · 1.44 KB
/
ArtifactsImplProxy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.buildsrc.lint;
import com.android.build.api.artifact.impl.ArtifactsImpl;
import com.android.build.gradle.internal.scope.InternalArtifactType;
import org.gradle.api.Task;
import org.gradle.api.file.FileSystemLocation;
import org.gradle.api.file.FileSystemLocationProperty;
import org.gradle.api.tasks.TaskProvider;
import kotlin.jvm.functions.Function1;
/**
* 通过java 文件访问kotlin 的 internal 方法,关闭 编译错误
* 另一种是通过反射,范型多的时候反射过于麻烦
*/
public class ArtifactsImplProxy {
final String LINT_PRINT_STACKTRACE_ENVIRONMENT_VARIABLE = "LINT_PRINT_STACKTRACE";
final String ANDROID_LINT_JARS_ENVIRONMENT_VARIABLE = "ANDROID_LINT_JARS";
final String PARTIAL_RESULTS_DIR_NAME = "out";
public <FILE_TYPE extends FileSystemLocation, TASK extends Task> void proxy(TaskProvider<TASK> taskProvider,
Function1<? super TASK, ? extends FileSystemLocationProperty<FILE_TYPE>> property,
ArtifactsImpl artifacts,
InternalArtifactType<FILE_TYPE> internalArtifactType) {
artifacts
.setInitialProvider(taskProvider, property)
.withName(PARTIAL_RESULTS_DIR_NAME)
.on(internalArtifactType);
}
}