com.browserstack.BrowserstackGradleTool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-tool Show documentation
Show all versions of gradle-tool Show documentation
A Gradle plugin to run espresso test with Browserstack SDK
The newest version!
package com.browserstack;
import com.android.build.api.artifact.ScopedArtifact;
import com.android.build.api.variant.ApplicationAndroidComponentsExtension;
import com.android.build.api.variant.ScopedArtifacts;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskProvider;
public class BrowserstackGradleTool implements Plugin {
private static final browserstack.shaded.org.slf4j.Logger logger = com.browserstack.logger.BrowserstackLoggerFactory.getLogger(BrowserstackGradleTool.class);
@Override
public void apply(Project project) {
UtilityMethods.setProject(project);
logger.info("Starting Browserstack Helper plugin");
ApplicationAndroidComponentsExtension androidComponents = project.getExtensions().getByType(ApplicationAndroidComponentsExtension.class);
androidComponents.onVariants(androidComponents.selector().all(), variant -> {
TaskProvider taskProvider = project.getTasks().register(variant.getName() + "ModifyClasses", ModifyClassesTask.class);
if(variant.getAndroidTest() == null) return;
logger.info("Found AndroidTest");
variant.getAndroidTest()
.getArtifacts()
.forScope(ScopedArtifacts.Scope.ALL)
.use(taskProvider)
.toTransform(
ScopedArtifact.CLASSES.INSTANCE,
ModifyClassesTask::getAllJars,
ModifyClassesTask::getAllDirs,
ModifyClassesTask::getOutput
);
});
}
}