All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.browserstack.BrowserstackGradleTool Maven / Gradle / Ivy

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
                    );
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy