Search in sources :

Example 61 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class DependentComponentsReport method report.

@TaskAction
public void report() {
    // Cross-project ModelRegistry operations do not happen concurrently.
    synchronized (DependentComponentsReport.class) {
        Project project = getProject();
        ModelRegistry modelRegistry = getModelRegistry();
        DependentBinariesResolver dependentBinariesResolver = modelRegistry.find("dependentBinariesResolver", DependentBinariesResolver.class);
        StyledTextOutput textOutput = getTextOutputFactory().create(DependentComponentsReport.class);
        TextDependentComponentsReportRenderer reportRenderer = new TextDependentComponentsReportRenderer(dependentBinariesResolver, showNonBuildable, showTestSuites);
        reportRenderer.setOutput(textOutput);
        reportRenderer.startProject(project);
        Set<ComponentSpec> allComponents = getAllComponents(modelRegistry);
        if (showTestSuites) {
            allComponents.addAll(getAllTestSuites(modelRegistry));
        }
        reportRenderer.renderComponents(getReportedComponents(allComponents));
        reportRenderer.renderLegend();
        reportRenderer.completeProject(project);
        reportRenderer.complete();
    }
}
Also used : Project(org.gradle.api.Project) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) DependentBinariesResolver(org.gradle.platform.base.internal.dependents.DependentBinariesResolver) TextDependentComponentsReportRenderer(org.gradle.api.reporting.dependents.internal.TextDependentComponentsReportRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ComponentSpec(org.gradle.platform.base.ComponentSpec) TaskAction(org.gradle.api.tasks.TaskAction)

Example 62 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class AntTarget method executeAntTarget.

@TaskAction
protected void executeAntTarget() {
    File oldBaseDir = target.getProject().getBaseDir();
    target.getProject().setBaseDir(baseDir);
    try {
        target.performTasks();
    } finally {
        target.getProject().setBaseDir(oldBaseDir);
    }
}
Also used : File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Example 63 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class GeneratorTask method generate.

@SuppressWarnings("UnusedDeclaration")
@TaskAction
void generate() {
    File inputFile = getInputFileIfExists();
    if (inputFile != null) {
        try {
            domainObject = generator.read(inputFile);
        } catch (RuntimeException e) {
            throw new GradleException(String.format("Cannot parse file '%s'.\n" + "       Perhaps this file was tinkered with? In that case try delete this file and then retry.", inputFile), e);
        }
    } else {
        domainObject = generator.defaultInstance();
    }
    beforeConfigured.execute(domainObject);
    generator.configure(domainObject);
    afterConfigured.execute(domainObject);
    generator.write(domainObject, getOutputFile());
}
Also used : GradleException(org.gradle.api.GradleException) File(java.io.File) OutputFile(org.gradle.api.tasks.OutputFile) InputFile(org.gradle.api.tasks.InputFile) TaskAction(org.gradle.api.tasks.TaskAction)

Example 64 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class FindBugs method run.

@TaskAction
public void run() throws IOException, InterruptedException {
    new FindBugsClasspathValidator(JavaVersion.current()).validateClasspath(Iterables.transform(getFindbugsClasspath().getFiles(), new Function<File, String>() {

        @Override
        public String apply(File input) {
            return input.getName();
        }
    }));
    FindBugsSpec spec = generateSpec();
    FindBugsWorkerManager manager = new FindBugsWorkerManager();
    getLogging().captureStandardOutput(LogLevel.DEBUG);
    getLogging().captureStandardError(LogLevel.DEBUG);
    FindBugsResult result = manager.runWorker(getProject().getProjectDir(), getWorkerProcessBuilderFactory(), getFindbugsClasspath(), spec);
    evaluateResult(result);
}
Also used : Function(com.google.common.base.Function) FindBugsSpec(org.gradle.api.plugins.quality.internal.findbugs.FindBugsSpec) FindBugsWorkerManager(org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerManager) FindBugsClasspathValidator(org.gradle.api.plugins.quality.internal.findbugs.FindBugsClasspathValidator) File(java.io.File) FindBugsResult(org.gradle.api.plugins.quality.internal.findbugs.FindBugsResult) TaskAction(org.gradle.api.tasks.TaskAction)

Example 65 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class CompositeBuildTaskDelegate method executeTasksInOtherBuild.

@TaskAction
public void executeTasksInOtherBuild() {
    IncludedBuilds includedBuilds = getServices().get(IncludedBuilds.class);
    IncludedBuildExecuter builder = getServices().get(IncludedBuildExecuter.class);
    IncludedBuild includedBuild = includedBuilds.getBuild(build);
    BuildIdentifier buildId = new DefaultBuildIdentifier(includedBuild.getName());
    // sourceBuild is currently always root build in a composite
    builder.execute(new DefaultBuildIdentifier(":", true), buildId, tasks);
}
Also used : DefaultBuildIdentifier(org.gradle.api.internal.artifacts.component.DefaultBuildIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) DefaultBuildIdentifier(org.gradle.api.internal.artifacts.component.DefaultBuildIdentifier) IncludedBuildExecuter(org.gradle.initialization.IncludedBuildExecuter) IncludedBuilds(org.gradle.initialization.IncludedBuilds) IncludedBuild(org.gradle.api.initialization.IncludedBuild) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TaskAction (org.gradle.api.tasks.TaskAction)92 File (java.io.File)40 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)22 GradleException (org.gradle.api.GradleException)15 ArrayList (java.util.ArrayList)11 InputFile (org.gradle.api.tasks.InputFile)11 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)10 OutputFile (org.gradle.api.tasks.OutputFile)10 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)9 IOException (java.io.IOException)8 Project (org.gradle.api.Project)8 WorkResult (org.gradle.api.tasks.WorkResult)8 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)8 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)7 InvalidUserDataException (org.gradle.api.InvalidUserDataException)7 HashSet (java.util.HashSet)6 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)5 AndroidLibrary (com.android.builder.model.AndroidLibrary)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4