Search in sources :

Example 1 with IConventionAware

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

the class IdeaPlugin method configureIdeaModule.

private void configureIdeaModule(final Project project) {
    final GenerateIdeaModule task = project.getTasks().create("ideaModule", GenerateIdeaModule.class);
    task.setDescription("Generates IDEA module files (IML)");
    IdeaModuleIml iml = new IdeaModuleIml(task.getXmlTransformer(), project.getProjectDir());
    final IdeaModule module = instantiator.newInstance(IdeaModule.class, project, iml);
    task.setModule(module);
    ideaModel.setModule(module);
    ConventionMapping conventionMapping = ((IConventionAware) module).getConventionMapping();
    conventionMapping.map("sourceDirs", new Callable<Set<File>>() {

        @Override
        public Set<File> call() throws Exception {
            return Sets.newHashSet();
        }
    });
    conventionMapping.map("name", new Callable<String>() {

        @Override
        public String call() throws Exception {
            return project.getName();
        }
    });
    conventionMapping.map("contentRoot", new Callable<File>() {

        @Override
        public File call() throws Exception {
            return project.getProjectDir();
        }
    });
    conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {

        @Override
        public Set<File> call() throws Exception {
            return Sets.newHashSet();
        }
    });
    conventionMapping.map("excludeDirs", new Callable<Set<File>>() {

        @Override
        public Set<File> call() throws Exception {
            return Sets.newHashSet(project.getBuildDir(), project.file(".gradle"));
        }
    });
    conventionMapping.map("pathFactory", new Callable<PathFactory>() {

        @Override
        public PathFactory call() throws Exception {
            final PathFactory factory = new PathFactory();
            factory.addPathVariable("MODULE_DIR", task.getOutputFile().getParentFile());
            for (Map.Entry<String, File> entry : module.getPathVariables().entrySet()) {
                factory.addPathVariable(entry.getKey(), entry.getValue());
            }
            return factory;
        }
    });
    addWorker(task);
}
Also used : Set(java.util.Set) PathFactory(org.gradle.plugins.ide.idea.model.PathFactory) ConventionMapping(org.gradle.api.internal.ConventionMapping) IdeaModule(org.gradle.plugins.ide.idea.model.IdeaModule) IdeaModuleIml(org.gradle.plugins.ide.idea.model.IdeaModuleIml) IConventionAware(org.gradle.api.internal.IConventionAware) File(java.io.File)

Example 2 with IConventionAware

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

the class CompareGradleBuildsPlugin method apply.

public void apply(Project project) {
    project.getPluginManager().apply(ReportingBasePlugin.class);
    final ReportingExtension reportingExtension = project.getExtensions().findByType(ReportingExtension.class);
    project.getTasks().withType(CompareGradleBuilds.class, new Action<CompareGradleBuilds>() {

        @Override
        public void execute(final CompareGradleBuilds task) {
            ((IConventionAware) task).getConventionMapping().map("reportDir", new Callable<File>() {

                @Override
                public File call() throws Exception {
                    return reportingExtension.file(task.getName());
                }
            });
        }
    });
    project.getTasks().create("compareGradleBuilds", CompareGradleBuilds.class);
}
Also used : ReportingExtension(org.gradle.api.reporting.ReportingExtension) IConventionAware(org.gradle.api.internal.IConventionAware) Callable(java.util.concurrent.Callable)

Example 3 with IConventionAware

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

the class JacocoPlugin method configureTaskClasspathDefaults.

/**
     * Configures the classpath for Jacoco tasks using the 'jacocoAnt' configuration. Uses the version information declared in 'toolVersion' of the Jacoco extension if no dependencies are explicitly
     * declared.
     *
     * @param extension the JacocoPluginExtension
     */
private void configureTaskClasspathDefaults(final JacocoPluginExtension extension) {
    final Configuration config = this.project.getConfigurations().getAt(ANT_CONFIGURATION_NAME);
    project.getTasks().withType(JacocoBase.class, new Action<JacocoBase>() {

        @Override
        public void execute(JacocoBase task) {
            ((IConventionAware) task).getConventionMapping().map("jacocoClasspath", Callables.returning(config));
        }
    });
    config.defaultDependencies(new Action<DependencySet>() {

        @Override
        public void execute(DependencySet dependencies) {
            dependencies.add(project.getDependencies().create("org.jacoco:org.jacoco.ant:" + extension.getToolVersion()));
        }
    });
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) DependencySet(org.gradle.api.artifacts.DependencySet) JacocoBase(org.gradle.testing.jacoco.tasks.JacocoBase) IConventionAware(org.gradle.api.internal.IConventionAware)

Example 4 with IConventionAware

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

the class EnvJsPlugin method apply.

public void apply(final Project project) {
    project.getPluginManager().apply(RhinoPlugin.class);
    project.getPluginManager().apply(ReportingBasePlugin.class);
    JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
    final EnvJsExtension envJsExtension = ((ExtensionAware) jsExtension).getExtensions().create(EnvJsExtension.NAME, EnvJsExtension.class);
    final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), envJsExtension);
    final ConventionMapping conventionMapping = ((IConventionAware) envJsExtension).getConventionMapping();
    conventionMapping.map("js", new Callable<Configuration>() {

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

        public String call() {
            return EnvJsExtension.DEFAULT_DEPENDENCY_VERSION;
        }
    });
    final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class);
    project.getTasks().withType(BrowserEvaluate.class, new Action<BrowserEvaluate>() {

        public void execute(BrowserEvaluate task) {
            ((IConventionAware) task).getConventionMapping().map("evaluator", new Callable<EnvJsBrowserEvaluator>() {

                public EnvJsBrowserEvaluator call() {
                    RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(workerProcessBuilderFactory);
                    File workDir = project.getProjectDir();
                    Factory<File> envJsFactory = new Factory<File>() {

                        public File create() {
                            return envJsExtension.getJs().getSingleFile();
                        }
                    };
                    return new EnvJsBrowserEvaluator(handleFactory, rhinoExtension.getClasspath(), envJsFactory, project.getGradle().getStartParameter().getLogLevel(), workDir);
                }
            });
        }
    });
}
Also used : DefaultRhinoWorkerHandleFactory(org.gradle.plugins.javascript.rhino.worker.internal.DefaultRhinoWorkerHandleFactory) Configuration(org.gradle.api.artifacts.Configuration) RhinoExtension(org.gradle.plugins.javascript.rhino.RhinoExtension) BrowserEvaluate(org.gradle.plugins.javascript.envjs.browser.BrowserEvaluate) DefaultRhinoWorkerHandleFactory(org.gradle.plugins.javascript.rhino.worker.internal.DefaultRhinoWorkerHandleFactory) RhinoWorkerHandleFactory(org.gradle.plugins.javascript.rhino.worker.RhinoWorkerHandleFactory) JavaScriptExtension(org.gradle.plugins.javascript.base.JavaScriptExtension) WorkerProcessFactory(org.gradle.process.internal.worker.WorkerProcessFactory) DefaultRhinoWorkerHandleFactory(org.gradle.plugins.javascript.rhino.worker.internal.DefaultRhinoWorkerHandleFactory) RhinoWorkerHandleFactory(org.gradle.plugins.javascript.rhino.worker.RhinoWorkerHandleFactory) Factory(org.gradle.internal.Factory) ConventionMapping(org.gradle.api.internal.ConventionMapping) Callable(java.util.concurrent.Callable) EnvJsBrowserEvaluator(org.gradle.plugins.javascript.envjs.internal.EnvJsBrowserEvaluator) IConventionAware(org.gradle.api.internal.IConventionAware) File(java.io.File)

Example 5 with IConventionAware

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

the class JsHintPlugin method apply.

public void apply(Project project) {
    project.getPluginManager().apply(RhinoPlugin.class);
    project.getPluginManager().apply(ReportingBasePlugin.class);
    JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
    final JsHintExtension jsHintExtension = ((ExtensionAware) jsExtension).getExtensions().create(JsHintExtension.NAME, JsHintExtension.class);
    final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), jsHintExtension);
    ConventionMapping conventionMapping = ((IConventionAware) jsHintExtension).getConventionMapping();
    conventionMapping.map("js", new Callable<Configuration>() {

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

        public String call() {
            return JsHintExtension.DEFAULT_DEPENDENCY_VERSION;
        }
    });
    final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class);
    final ReportingExtension reportingExtension = project.getExtensions().getByType(ReportingExtension.class);
    project.getTasks().withType(JsHint.class, new Action<JsHint>() {

        public void execute(final JsHint task) {
            task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() {

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

                public FileCollection call() {
                    return jsHintExtension.getJs();
                }
            });
            task.getConventionMapping().map("jsonReport", new Callable<File>() {

                public File call() {
                    return reportingExtension.file(task.getName() + "/report.json");
                }
            });
        }
    });
}
Also used : ReportingExtension(org.gradle.api.reporting.ReportingExtension) 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) Callable(java.util.concurrent.Callable) IConventionAware(org.gradle.api.internal.IConventionAware)

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