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());
}
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();
}
});
}
});
}
Aggregations