Search in sources :

Example 56 with TaskAction

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

the class GroovyCompile method compile.

@Override
@TaskAction
protected void compile() {
    checkGroovyClasspathIsNonEmpty();
    DefaultGroovyJavaJointCompileSpec spec = createSpec();
    WorkResult result = getCompiler(spec).execute(spec);
    setDidWork(result.getDidWork());
}
Also used : DefaultGroovyJavaJointCompileSpec(org.gradle.api.internal.tasks.compile.DefaultGroovyJavaJointCompileSpec) WorkResult(org.gradle.api.tasks.WorkResult) TaskAction(org.gradle.api.tasks.TaskAction)

Example 57 with TaskAction

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

the class AntlrTask method execute.

@TaskAction
public void execute(IncrementalTaskInputs inputs) {
    final Set<File> grammarFiles = new HashSet<File>();
    final Set<File> sourceFiles = getSource().getFiles();
    final AtomicBoolean cleanRebuild = new AtomicBoolean();
    inputs.outOfDate(new Action<InputFileDetails>() {

        public void execute(InputFileDetails details) {
            File input = details.getFile();
            if (sourceFiles.contains(input)) {
                grammarFiles.add(input);
            } else {
                // classpath change?
                cleanRebuild.set(true);
            }
        }
    });
    inputs.removed(new Action<InputFileDetails>() {

        @Override
        public void execute(InputFileDetails details) {
            if (details.isRemoved()) {
                cleanRebuild.set(true);
            }
        }
    });
    if (cleanRebuild.get()) {
        GFileUtils.cleanDirectory(outputDirectory);
        grammarFiles.addAll(sourceFiles);
    }
    AntlrWorkerManager manager = new AntlrWorkerManager();
    AntlrSpec spec = new AntlrSpecFactory().create(this, grammarFiles, sourceDirectorySet);
    AntlrResult result = manager.runWorker(getProject().getProjectDir(), getWorkerProcessBuilderFactory(), getAntlrClasspath(), spec);
    evaluate(result);
}
Also used : AntlrSpecFactory(org.gradle.api.plugins.antlr.internal.AntlrSpecFactory) AntlrResult(org.gradle.api.plugins.antlr.internal.AntlrResult) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) InputFileDetails(org.gradle.api.tasks.incremental.InputFileDetails) AntlrSpec(org.gradle.api.plugins.antlr.internal.AntlrSpec) AntlrWorkerManager(org.gradle.api.plugins.antlr.internal.AntlrWorkerManager) File(java.io.File) HashSet(java.util.HashSet) TaskAction(org.gradle.api.tasks.TaskAction)

Example 58 with TaskAction

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

the class ModelReport method report.

@TaskAction
public void report() {
    Project project = getProject();
    StyledTextOutput textOutput = getTextOutputFactory().create(ModelReport.class);
    ModelNodeRenderer renderer = new ModelNodeRenderer(isShowHidden(), getFormat());
    TextModelReportRenderer textModelReportRenderer = new TextModelReportRenderer(renderer);
    textModelReportRenderer.setOutput(textOutput);
    textModelReportRenderer.startProject(project);
    ModelRegistry modelRegistry = getModelRegistry();
    ModelNode rootNode = modelRegistry.realizeNode(ModelPath.ROOT);
    // Ensure binding validation has been done. This should happen elsewhere
    modelRegistry.bindAllReferences();
    textModelReportRenderer.render(rootNode);
    textModelReportRenderer.completeProject(project);
    textModelReportRenderer.complete();
}
Also used : Project(org.gradle.api.Project) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) ModelNodeRenderer(org.gradle.api.reporting.model.internal.ModelNodeRenderer) TextModelReportRenderer(org.gradle.api.reporting.model.internal.TextModelReportRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ModelNode(org.gradle.model.internal.core.ModelNode) TaskAction(org.gradle.api.tasks.TaskAction)

Example 59 with TaskAction

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

the class AbstractReportTask method generate.

@TaskAction
public void generate() {
    ProjectReportGenerator projectReportGenerator = new ProjectReportGenerator() {

        @Override
        public void generateReport(Project project) throws IOException {
            generate(project);
            if (shouldCreateReportFile()) {
                project.getLogger().lifecycle("See the report at: {}", new ConsoleRenderer().asClickableFileUrl(getOutputFile()));
            }
        }
    };
    ReportGenerator reportGenerator = new ReportGenerator(getRenderer(), getClientMetaData(), getOutputFile(), getTextOutputFactory(), projectReportGenerator);
    reportGenerator.generateReport(new TreeSet<Project>(getProjects()));
}
Also used : Project(org.gradle.api.Project) ProjectReportGenerator(org.gradle.api.tasks.diagnostics.internal.ProjectReportGenerator) ReportGenerator(org.gradle.api.tasks.diagnostics.internal.ReportGenerator) ProjectReportGenerator(org.gradle.api.tasks.diagnostics.internal.ProjectReportGenerator) ConsoleRenderer(org.gradle.internal.logging.ConsoleRenderer) TaskAction(org.gradle.api.tasks.TaskAction)

Example 60 with TaskAction

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

the class ComponentReport method report.

@TaskAction
public void report() {
    Project project = getProject();
    StyledTextOutput textOutput = getTextOutputFactory().create(ComponentReport.class);
    ComponentReportRenderer renderer = new ComponentReportRenderer(getFileResolver(), getBinaryRenderer());
    renderer.setOutput(textOutput);
    renderer.startProject(project);
    Collection<ComponentSpec> components = new ArrayList<ComponentSpec>();
    ComponentSpecContainer componentSpecs = modelElement("components", ComponentSpecContainer.class);
    if (componentSpecs != null) {
        components.addAll(componentSpecs.values());
    }
    ModelMap<ComponentSpec> testSuites = modelElement("testSuites", modelMap(ComponentSpec.class));
    if (testSuites != null) {
        components.addAll(testSuites.values());
    }
    renderer.renderComponents(components);
    ProjectSourceSet sourceSets = modelElement("sources", ProjectSourceSet.class);
    if (sourceSets != null) {
        renderer.renderSourceSets(sourceSets);
    }
    BinaryContainer binaries = modelElement("binaries", BinaryContainer.class);
    if (binaries != null) {
        renderer.renderBinaries(binaries.values());
    }
    renderer.completeProject(project);
    renderer.complete();
}
Also used : Project(org.gradle.api.Project) ProjectSourceSet(org.gradle.language.base.ProjectSourceSet) ComponentSpecContainer(org.gradle.platform.base.ComponentSpecContainer) ComponentReportRenderer(org.gradle.api.reporting.components.internal.ComponentReportRenderer) BinaryContainer(org.gradle.platform.base.BinaryContainer) ArrayList(java.util.ArrayList) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ComponentSpec(org.gradle.platform.base.ComponentSpec) 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