Search in sources :

Example 1 with RhinoExtension

use of org.gradle.plugins.javascript.rhino.RhinoExtension 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)

Example 2 with RhinoExtension

use of org.gradle.plugins.javascript.rhino.RhinoExtension 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.internal.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.internal.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 3 with RhinoExtension

use of org.gradle.plugins.javascript.rhino.RhinoExtension 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)

Aggregations

Callable (java.util.concurrent.Callable)3 Configuration (org.gradle.api.artifacts.Configuration)3 ConventionMapping (org.gradle.api.internal.ConventionMapping)3 IConventionAware (org.gradle.api.internal.IConventionAware)3 JavaScriptExtension (org.gradle.plugins.javascript.base.JavaScriptExtension)3 RhinoExtension (org.gradle.plugins.javascript.rhino.RhinoExtension)3 File (java.io.File)1 ExtensionAware (org.gradle.api.plugins.ExtensionAware)1 ExtensionContainer (org.gradle.api.plugins.ExtensionContainer)1 ReportingExtension (org.gradle.api.reporting.ReportingExtension)1 Factory (org.gradle.internal.Factory)1 BrowserEvaluate (org.gradle.plugins.javascript.envjs.browser.BrowserEvaluate)1 EnvJsBrowserEvaluator (org.gradle.plugins.javascript.envjs.internal.EnvJsBrowserEvaluator)1 DefaultRhinoWorkerHandleFactory (org.gradle.plugins.javascript.rhino.worker.internal.DefaultRhinoWorkerHandleFactory)1 RhinoWorkerHandleFactory (org.gradle.plugins.javascript.rhino.worker.internal.RhinoWorkerHandleFactory)1 WorkerProcessFactory (org.gradle.process.internal.worker.WorkerProcessFactory)1