com.therouter.plugin.TheRouterPlugin.groovy Maven / Gradle / Ivy
package com.therouter.plugin
import com.android.build.gradle.AppExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
public class TheRouterPlugin implements Plugin {
public static final String WARNING = "warning";
public static final String ERROR = "error";
public static final String DELETE = "delete";
@Override
void apply(Project project) {
project.extensions.create('TheRouter', TheRouterExtension)
boolean isLibrary = project.getPlugins().hasPlugin("com.android.library")
if (!isLibrary) {
def android = project.extensions.getByType(AppExtension)
def therouterTransform = new TheRouterTransform(project)
android.registerTransform(therouterTransform)
// def android = project.extensions.getByType(AndroidComponentsExtension.class)
// android.onVariants(android.selector().all(), new Action() {
// @Override
// void execute(Variant variant) {
// TaskProvider getAllClassesTask = project.tasks.register("${variant.name}TheRouter", TheRouterGetAllClassesTask.class)
// variant.artifacts
// .forScope(ScopedArtifacts.Scope.ALL)
// .use(getAllClassesTask)
// .toTransform(ScopedArtifact.CLASSES.INSTANCE, { it.getAllJars() }, { it.getAllDirectories() }, { it.getOutput() })
// }
// })
} else {
throw new RuntimeException("`apply plugin: 'therouter'` must call in app module! You need remove at ${project.name} module.")
}
}
}