Search in sources :

Example 11 with IConventionAware

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

the class RhinoPlugin method apply.

public void apply(Project project) {
    project.getPluginManager().apply(JavaScriptBasePlugin.class);
    JavaScriptExtension jsExtension = project.getExtensions().findByType(JavaScriptExtension.class);
    final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().create(RhinoExtension.NAME, RhinoExtension.class);
    final Configuration configuration = addClasspathConfiguration(project.getConfigurations());
    configureDefaultRhinoDependency(configuration, project.getDependencies(), rhinoExtension);
    ConventionMapping conventionMapping = ((IConventionAware) rhinoExtension).getConventionMapping();
    conventionMapping.map("classpath", new Callable<Configuration>() {

        public Configuration call() {
            return configuration;
        }
    });
    conventionMapping.map("version", new Callable<String>() {

        public String call() {
            return RhinoExtension.DEFAULT_RHINO_DEPENDENCY_VERSION;
        }
    });
    project.getTasks().withType(RhinoShellExec.class, new Action<RhinoShellExec>() {

        public void execute(RhinoShellExec task) {
            task.getConventionMapping().map("classpath", new Callable<FileCollection>() {

                public FileCollection call() {
                    return rhinoExtension.getClasspath();
                }
            });
            task.getConventionMapping().map("main", new Callable<String>() {

                public String call() {
                    return RhinoExtension.RHINO_SHELL_MAIN;
                }
            });
            task.setClasspath(rhinoExtension.getClasspath());
        }
    });
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) JavaScriptExtension(org.gradle.plugins.javascript.base.JavaScriptExtension) ConventionMapping(org.gradle.api.internal.ConventionMapping) IConventionAware(org.gradle.api.internal.IConventionAware) Callable(java.util.concurrent.Callable)

Example 12 with IConventionAware

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

the class CoffeeScriptBasePlugin method apply.

public void apply(Project project) {
    project.getPluginManager().apply(RhinoPlugin.class);
    JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
    ExtensionContainer extensionContainer = ((ExtensionAware) jsExtension).getExtensions();
    final CoffeeScriptExtension csExtension = extensionContainer.create(CoffeeScriptExtension.NAME, CoffeeScriptExtension.class);
    final Configuration jsConfiguration = addJsConfiguration(project.getConfigurations(), project.getDependencies(), csExtension);
    ConventionMapping conventionMapping = ((IConventionAware) csExtension).getConventionMapping();
    conventionMapping.map("js", new Callable<Configuration>() {

        @Override
        public Configuration call() {
            return jsConfiguration;
        }
    });
    conventionMapping.map("version", new Callable<String>() {

        @Override
        public String call() {
            return CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_VERSION;
        }
    });
    final RhinoExtension rhinoExtension = extensionContainer.getByType(RhinoExtension.class);
    project.getTasks().withType(CoffeeScriptCompile.class, new Action<CoffeeScriptCompile>() {

        @Override
        public void execute(CoffeeScriptCompile task) {
            task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() {

                public FileCollection call() {
                    return rhinoExtension.getClasspath();
                }
            });
            task.getConventionMapping().map("coffeeScriptJs", new Callable<FileCollection>() {

                public FileCollection call() {
                    return csExtension.getJs();
                }
            });
        }
    });
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) RhinoExtension(org.gradle.plugins.javascript.rhino.RhinoExtension) JavaScriptExtension(org.gradle.plugins.javascript.base.JavaScriptExtension) ConventionMapping(org.gradle.api.internal.ConventionMapping) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) Callable(java.util.concurrent.Callable) ExtensionAware(org.gradle.api.plugins.ExtensionAware) IConventionAware(org.gradle.api.internal.IConventionAware)

Example 13 with IConventionAware

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

the class JacocoPlugin method addDefaultReportTask.

private void addDefaultReportTask(final JacocoPluginExtension extension, final Test task) {
    final JacocoReport reportTask = project.getTasks().create("jacoco" + StringUtils.capitalize(task.getName()) + "Report", JacocoReport.class);
    reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    reportTask.setDescription(String.format("Generates code coverage report for the %s task.", task.getName()));
    reportTask.executionData(task);
    reportTask.sourceSets(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main"));
    ConventionMapping taskMapping = ((IConventionAware) reportTask).getConventionMapping();
    taskMapping.getConventionValue(reportTask.getReports(), "reports", false).all(new Action<Report>() {

        @Override
        public void execute(final Report report) {
            ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
            // reportMapping.map('enabled', Callables.returning(true));
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                reportMapping.map("destination", new Callable<File>() {

                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + report.getName());
                    }
                });
            } else {
                reportMapping.map("destination", new Callable<File>() {

                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + reportTask.getName() + "." + report.getName());
                    }
                });
            }
        }
    });
}
Also used : JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) JacocoReport(org.gradle.testing.jacoco.tasks.JacocoReport) Report(org.gradle.api.reporting.Report) ConventionMapping(org.gradle.api.internal.ConventionMapping) IConventionAware(org.gradle.api.internal.IConventionAware) File(java.io.File) JacocoReport(org.gradle.testing.jacoco.tasks.JacocoReport) Callable(java.util.concurrent.Callable)

Example 14 with IConventionAware

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

the class DistributionPlugin method apply.

@Override
public void apply(final ProjectInternal project) {
    project.getPluginManager().apply(BasePlugin.class);
    DistributionContainer distributions = project.getExtensions().create(DistributionContainer.class, "distributions", DefaultDistributionContainer.class, Distribution.class, instantiator, fileOperations);
    // TODO - refactor this action out so it can be unit tested
    distributions.all(new Action<Distribution>() {

        @Override
        public void execute(final Distribution dist) {
            ((IConventionAware) dist).getConventionMapping().map("baseName", new Callable<Object>() {

                @Override
                public Object call() throws Exception {
                    return dist.getName().equals(MAIN_DISTRIBUTION_NAME) ? project.getName() : String.format("%s-%s", project.getName(), dist.getName());
                }
            });
            dist.getContents().from("src/" + dist.getName() + "/dist");
            String zipTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_ZIP_NAME : dist.getName() + "DistZip";
            Task zipTask = configureArchiveTask(project, zipTaskName, dist, Zip.class);
            String tarTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_TAR_NAME : dist.getName() + "DistTar";
            Task tarTask = configureArchiveTask(project, tarTaskName, dist, Tar.class);
            addAssembleTask(project, dist, zipTask, tarTask);
            addInstallTask(project, dist);
        }
    });
    distributions.create(MAIN_DISTRIBUTION_NAME);
}
Also used : Zip(org.gradle.api.tasks.bundling.Zip) AbstractArchiveTask(org.gradle.api.tasks.bundling.AbstractArchiveTask) Task(org.gradle.api.Task) Tar(org.gradle.api.tasks.bundling.Tar) Distribution(org.gradle.api.distribution.Distribution) IConventionAware(org.gradle.api.internal.IConventionAware) Callable(java.util.concurrent.Callable) DistributionContainer(org.gradle.api.distribution.DistributionContainer) DefaultDistributionContainer(org.gradle.api.distribution.internal.DefaultDistributionContainer)

Aggregations

IConventionAware (org.gradle.api.internal.IConventionAware)14 ConventionMapping (org.gradle.api.internal.ConventionMapping)11 Callable (java.util.concurrent.Callable)8 File (java.io.File)5 Configuration (org.gradle.api.artifacts.Configuration)5 JavaScriptExtension (org.gradle.plugins.javascript.base.JavaScriptExtension)4 RhinoExtension (org.gradle.plugins.javascript.rhino.RhinoExtension)3 List (java.util.List)2 Set (java.util.Set)2 Action (org.gradle.api.Action)2 JavaVersion (org.gradle.api.JavaVersion)2 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)2 ReportingExtension (org.gradle.api.reporting.ReportingExtension)2 IdeaModule (org.gradle.plugins.ide.idea.model.IdeaModule)2 PathFactory (org.gradle.plugins.ide.idea.model.PathFactory)2 Predicate (com.google.common.base.Predicate)1 DefaultTypeTransformation.castToBoolean (org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToBoolean)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1