Search in sources :

Example 26 with ConventionMapping

use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.

the class JavaBasePlugin method createCompileJavaTaskForBinary.

private void createCompileJavaTaskForBinary(final SourceSet sourceSet, final SourceDirectorySet sourceDirectorySet, final Project target) {
    JavaCompile compileTask = target.getTasks().create(sourceSet.getCompileJavaTaskName(), JavaCompile.class);
    compileTask.setDescription("Compiles " + sourceDirectorySet + ".");
    compileTask.setSource(sourceDirectorySet);
    ConventionMapping conventionMapping = compileTask.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {

        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    SourceSetUtil.configureAnnotationProcessorPath(sourceSet, compileTask.getOptions(), target);
    SourceSetUtil.configureOutputDirectoryForSourceSet(sourceSet, sourceDirectorySet, compileTask, target);
}
Also used : DslObject(org.gradle.api.internal.plugins.DslObject) JavaCompile(org.gradle.api.tasks.compile.JavaCompile) ConventionMapping(org.gradle.api.internal.ConventionMapping)

Example 27 with ConventionMapping

use of org.gradle.api.internal.ConventionMapping in project gradle by gradle.

the class BuildDashboardPlugin method apply.

public void apply(final Project project) {
    project.getPluginManager().apply(ReportingBasePlugin.class);
    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
    buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
    buildDashboardTask.setGroup("reporting");
    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {

        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });
    Action<Task> captureReportingTasks = new Action<Task>() {

        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }
            Reporting reporting = (Reporting) task;
            buildDashboardTask.aggregate(reporting);
            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };
    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
Also used : DslObject(org.gradle.api.internal.plugins.DslObject) DslObject(org.gradle.api.internal.plugins.DslObject) Reporting(org.gradle.api.reporting.Reporting) DirectoryReport(org.gradle.api.reporting.DirectoryReport) ConventionMapping(org.gradle.api.internal.ConventionMapping) GenerateBuildDashboard(org.gradle.api.reporting.GenerateBuildDashboard)

Aggregations

ConventionMapping (org.gradle.api.internal.ConventionMapping)27 IConventionAware (org.gradle.api.internal.IConventionAware)11 Callable (java.util.concurrent.Callable)10 File (java.io.File)9 Set (java.util.Set)6 FileCollection (org.gradle.api.file.FileCollection)6 Action (org.gradle.api.Action)5 Configuration (org.gradle.api.artifacts.Configuration)5 JavaVersion (org.gradle.api.JavaVersion)4 DslObject (org.gradle.api.internal.plugins.DslObject)4 JavaBasePlugin (org.gradle.api.plugins.JavaBasePlugin)4 IdeaModule (org.gradle.plugins.ide.idea.model.IdeaModule)4 JavaScriptExtension (org.gradle.plugins.javascript.base.JavaScriptExtension)4 Predicate (com.google.common.base.Predicate)3 List (java.util.List)3 TextResource (org.gradle.api.resources.TextResource)3 EarPlugin (org.gradle.plugins.ear.EarPlugin)3 IdeaLanguageLevel (org.gradle.plugins.ide.idea.model.IdeaLanguageLevel)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2