Search in sources :

Example 1 with ExtensionAware

use of org.gradle.api.plugins.ExtensionAware in project gradle by gradle.

the class AsmBackedClassGeneratorTest method mixesInExtensionAwareInterface.

@Test
public void mixesInExtensionAwareInterface() throws Exception {
    Class<? extends Bean> generatedClass = generator.generate(Bean.class);
    assertTrue(ExtensionAware.class.isAssignableFrom(generatedClass));
    Bean bean = generatedClass.newInstance();
    ExtensionAware dynamicBean = (ExtensionAware) bean;
    assertThat(dynamicBean.getExtensions(), notNullValue());
}
Also used : ExtensionAware(org.gradle.api.plugins.ExtensionAware) Test(org.junit.Test)

Example 2 with ExtensionAware

use of org.gradle.api.plugins.ExtensionAware 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

ExtensionAware (org.gradle.api.plugins.ExtensionAware)2 Callable (java.util.concurrent.Callable)1 Configuration (org.gradle.api.artifacts.Configuration)1 ConventionMapping (org.gradle.api.internal.ConventionMapping)1 IConventionAware (org.gradle.api.internal.IConventionAware)1 ExtensionContainer (org.gradle.api.plugins.ExtensionContainer)1 JavaScriptExtension (org.gradle.plugins.javascript.base.JavaScriptExtension)1 RhinoExtension (org.gradle.plugins.javascript.rhino.RhinoExtension)1 Test (org.junit.Test)1