use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method conventionPropertyTakesPrecedenceOverParentProperty.
@Test
public void conventionPropertyTakesPrecedenceOverParentProperty() {
Bean parent = new Bean();
parent.defineProperty("conventionProperty", "parent");
Bean bean = new Bean();
bean.setParent(parent.getAsDynamicObject());
Convention convention = bean.extensibleDynamicObject.getConvention();
ConventionBean conventionBean = new ConventionBean();
conventionBean.setConventionProperty("value");
convention.getPlugins().put("test", conventionBean);
assertThat(bean.getProperty("conventionProperty"), equalTo((Object) "value"));
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method inheritedConventionPropertiesTrackChanges.
@Test
public void inheritedConventionPropertiesTrackChanges() {
Bean bean = new Bean();
DynamicObject inherited = bean.getInheritable();
assertFalse(inherited.hasProperty("conventionProperty"));
Convention convention = bean.extensibleDynamicObject.getConvention();
ConventionBean conventionBean = new ConventionBean();
conventionBean.setConventionProperty("value");
convention.getPlugins().put("convention", conventionBean);
assertTrue(inherited.hasProperty("conventionProperty"));
assertThat(inherited.getProperty("conventionProperty"), equalTo((Object) "value"));
}
use of org.gradle.api.plugins.Convention in project jib by google.
the class GradleSourceFilesConfigurationTest method setUp.
@Before
public void setUp() throws URISyntaxException, IOException {
Project mockProject = Mockito.mock(Project.class);
Convention mockConvention = Mockito.mock(Convention.class);
JavaPluginConvention mockJavaPluginConvention = Mockito.mock(JavaPluginConvention.class);
SourceSetContainer mockSourceSetContainer = Mockito.mock(SourceSetContainer.class);
SourceSet mockMainSourceSet = Mockito.mock(SourceSet.class);
SourceSetOutput mockMainSourceSetOutput = Mockito.mock(SourceSetOutput.class);
Set<File> classesFiles = ImmutableSet.of(Paths.get(Resources.getResource("application/classes").toURI()).toFile());
FileCollection classesFileCollection = new TestFileCollection(classesFiles);
File resourcesOutputDir = Paths.get(Resources.getResource("application/resources").toURI()).toFile();
Set<File> allFiles = new HashSet<>(classesFiles);
allFiles.add(resourcesOutputDir);
allFiles.add(Paths.get(Resources.getResource("application/dependencies/libraryB.jar").toURI()).toFile());
allFiles.add(Paths.get(Resources.getResource("application/dependencies/libraryA.jar").toURI()).toFile());
allFiles.add(Paths.get(Resources.getResource("application/dependencies/dependency-1.0.0.jar").toURI()).toFile());
FileCollection runtimeFileCollection = new TestFileCollection(allFiles);
Mockito.when(mockProject.getConvention()).thenReturn(mockConvention);
Mockito.when(mockConvention.getPlugin(JavaPluginConvention.class)).thenReturn(mockJavaPluginConvention);
Mockito.when(mockJavaPluginConvention.getSourceSets()).thenReturn(mockSourceSetContainer);
Mockito.when(mockSourceSetContainer.getByName("main")).thenReturn(mockMainSourceSet);
Mockito.when(mockMainSourceSet.getOutput()).thenReturn(mockMainSourceSetOutput);
Mockito.when(mockMainSourceSetOutput.getClassesDirs()).thenReturn(classesFileCollection);
Mockito.when(mockMainSourceSetOutput.getResourcesDir()).thenReturn(resourcesOutputDir);
Mockito.when(mockMainSourceSet.getRuntimeClasspath()).thenReturn(runtimeFileCollection);
testGradleSourceFilesConfiguration = GradleSourceFilesConfiguration.getForProject(mockProject);
}
Aggregations