use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method additionalObjectPropertiesAreInherited.
@Test
public void additionalObjectPropertiesAreInherited() {
Bean other = new Bean();
other.defineProperty("other", "value");
Bean bean = new Bean();
bean.extensibleDynamicObject.addObject(other.getAsDynamicObject(), ExtensibleDynamicObject.Location.BeforeConvention);
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasProperty("other"));
assertThat(inherited.getProperty("other"), equalTo((Object) "value"));
assertThat(inherited.getProperties().get("other"), equalTo((Object) "value"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method conventionPropertiesAreInherited.
@Test
public void conventionPropertiesAreInherited() {
Bean bean = new Bean();
Convention convention = bean.extensibleDynamicObject.getConvention();
ConventionBean conventionBean = new ConventionBean();
conventionBean.setConventionProperty("value");
convention.getPlugins().put("convention", conventionBean);
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasProperty("conventionProperty"));
assertThat(inherited.getProperty("conventionProperty"), equalTo((Object) "value"));
assertThat(inherited.getProperties().get("conventionProperty"), equalTo((Object) "value"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method conventionMethodsAreInherited.
@Test
public void conventionMethodsAreInherited() {
Bean bean = new Bean();
Convention convention = bean.extensibleDynamicObject.getConvention();
convention.getPlugins().put("convention", new ConventionBean());
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasMethod("conventionMethod", "a", "b"));
assertThat(inherited.invokeMethod("conventionMethod", "a", "b"), equalTo((Object) "convention:a.b"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method extraPropertiesAreInherited.
@Test
public void extraPropertiesAreInherited() {
Bean bean = new Bean();
bean.defineProperty("additional", "value");
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasProperty("additional"));
assertThat(inherited.getProperty("additional"), equalTo((Object) "value"));
assertThat(inherited.getProperties().get("additional"), equalTo((Object) "value"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class AntFileCollectionBuilder method addToAntBuilder.
@Override
public Object addToAntBuilder(Object node, String childNodeName) {
final DynamicObject dynamicObject = new BeanDynamicObject(node);
dynamicObject.invokeMethod(childNodeName == null ? "resources" : childNodeName, new Closure(this) {
public Object doCall(Object ignore) {
for (File file : files) {
dynamicObject.invokeMethod("file", Collections.singletonMap("file", AntUtil.maskFilename(file.getAbsolutePath())));
}
return null;
}
});
return node;
}
Aggregations