use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class JettyPlugin method apply.
public void apply(Project project) {
DeprecationLogger.nagUserOfPluginReplacedWithExternalOne("Jetty", "Gretty (https://github.com/akhikhl/gretty)");
project.getPluginManager().apply(WarPlugin.class);
JettyPluginConvention jettyConvention = new JettyPluginConvention();
Convention convention = project.getConvention();
convention.getPlugins().put("jetty", jettyConvention);
configureMappingRules(project, jettyConvention);
configureJettyRun(project);
configureJettyRunWar(project);
configureJettyStop(project, jettyConvention);
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ScalaBasePlugin method configureScalaCompile.
private static void configureScalaCompile(final Project project, final SourceSet sourceSet) {
String taskName = sourceSet.getCompileTaskName("scala");
final ScalaCompile scalaCompile = project.getTasks().create(taskName, ScalaCompile.class);
scalaCompile.dependsOn(sourceSet.getCompileJavaTaskName());
Convention scalaConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
SourceSetUtil.configureForSourceSet(sourceSet, scalaSourceSet.getScala(), scalaCompile, scalaCompile.getOptions(), project);
scalaCompile.setDescription("Compiles the " + scalaSourceSet.getScala() + ".");
scalaCompile.setSource(scalaSourceSet.getScala());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(taskName);
// cannot use convention mapping because the resulting object won't be serializable
// cannot compute at task execution time because we need association with source set
project.getGradle().addBuildListener(new BuildAdapter() {
@Override
public void projectsEvaluated(Gradle gradle) {
IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions();
if (incrementalOptions.getAnalysisFile() == null) {
String analysisFilePath = project.getBuildDir().getPath() + "/tmp/scala/compilerAnalysis/" + scalaCompile.getName() + ".analysis";
incrementalOptions.setAnalysisFile(new File(analysisFilePath));
}
if (incrementalOptions.getPublishedCode() == null) {
Jar jarTask = (Jar) project.getTasks().findByName(sourceSet.getJarTaskName());
incrementalOptions.setPublishedCode(jarTask == null ? null : jarTask.getArchivePath());
}
}
});
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method canGetAllProperties.
@Test
public void canGetAllProperties() {
Bean parent = new Bean();
parent.defineProperty("parentProperty", "parentProperty");
parent.setReadWriteProperty("ignore me");
parent.doSetReadOnlyProperty("ignore me");
Convention parentConvention = parent.extensibleDynamicObject.getConvention();
parentConvention.getPlugins().put("parent", new ConventionBean());
GroovyBean bean = new GroovyBean();
bean.defineProperty("additional", "additional");
bean.setReadWriteProperty("readWriteProperty");
bean.doSetReadOnlyProperty("readOnlyProperty");
bean.setGroovyProperty("groovyProperty");
Convention convention = bean.extensibleDynamicObject.getConvention();
ConventionBean conventionBean = new ConventionBean();
conventionBean.setConventionProperty("conventionProperty");
convention.getPlugins().put("bean", conventionBean);
bean.setParent(parent.getAsDynamicObject());
Map<String, Object> properties = bean.getProperties();
assertThat(properties.get("properties"), sameInstance((Object) properties));
assertThat(properties.get("readWriteProperty"), equalTo((Object) "readWriteProperty"));
assertThat(properties.get("readOnlyProperty"), equalTo((Object) "readOnlyProperty"));
assertThat(properties.get("parentProperty"), equalTo((Object) "parentProperty"));
assertThat(properties.get("additional"), equalTo((Object) "additional"));
assertThat(properties.get("groovyProperty"), equalTo((Object) "groovyProperty"));
assertThat(properties.get("groovyDynamicProperty"), equalTo(null));
assertThat(properties.get("conventionProperty"), equalTo((Object) "conventionProperty"));
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method canInvokeMethodDefinedByConvention.
@Test
public void canInvokeMethodDefinedByConvention() {
Bean bean = new Bean();
Convention convention = bean.extensibleDynamicObject.getConvention();
assertFalse(bean.hasMethod("conventionMethod", "a", "b"));
convention.getPlugins().put("bean", new ConventionBean());
assertTrue(bean.hasMethod("conventionMethod", "a", "b"));
assertThat(bean.getAsDynamicObject().invokeMethod("conventionMethod", "a", "b"), equalTo((Object) "convention:a.b"));
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method hasPropertyDefinedByConventionObject.
@Test
public void hasPropertyDefinedByConventionObject() {
Bean bean = new Bean();
Convention convention = bean.extensibleDynamicObject.getConvention();
assertFalse(bean.hasProperty("conventionProperty"));
assertFalse(bean.hasProperty("conventionProperty"));
convention.getPlugins().put("test", new ConventionBean());
assertTrue(bean.hasProperty("conventionProperty"));
}
Aggregations