diff --git a/src/main/groovy/nebula/test/dependencies/DependencyGraphBuilder.groovy b/src/main/groovy/nebula/test/dependencies/DependencyGraphBuilder.groovy index 14169d1..cb8ddaf 100644 --- a/src/main/groovy/nebula/test/dependencies/DependencyGraphBuilder.groovy +++ b/src/main/groovy/nebula/test/dependencies/DependencyGraphBuilder.groovy @@ -1,17 +1,23 @@ package nebula.test.dependencies class DependencyGraphBuilder { + + private static final DEFAULT_STATUS = 'integration' + Map modules = [:] DependencyGraphBuilder addModule(String coordinate) { - def (group, artifact, version) = coordinate.trim().tokenize(':') - addModule(group, artifact, version) + def (group, artifact, version, status) = coordinate.trim().tokenize(':') + addModule(group, artifact, version, status) } DependencyGraphBuilder addModule(String group, String artifact, String version) { - String key = "${group}:${artifact}:${version}".toString() - modules[key] = new DependencyGraphNode(coordinate: new Coordinate(group: group, artifact: artifact, version: version)) + addModule(group, artifact, version, DEFAULT_STATUS) + } + DependencyGraphBuilder addModule(String group, String artifact, String version, String status) { + String key = "${group}:${artifact}:${version}".toString() + modules[key] = new DependencyGraphNode(coordinate: new Coordinate(group: group, artifact: artifact, version: version), status: status ?: DEFAULT_STATUS) this } diff --git a/src/test/groovy/nebula/test/dependencies/GradleDependencyGeneratorSpec.groovy b/src/test/groovy/nebula/test/dependencies/GradleDependencyGeneratorSpec.groovy index 3812411..286aa37 100644 --- a/src/test/groovy/nebula/test/dependencies/GradleDependencyGeneratorSpec.groovy +++ b/src/test/groovy/nebula/test/dependencies/GradleDependencyGeneratorSpec.groovy @@ -47,6 +47,56 @@ class GradleDependencyGeneratorSpec extends Specification { } } + def 'publishes ivy status using DependencyGraphBuilder.addModule - passing status'() { + given: + def directory = 'build/testdependencies/ivypublishAddModuleWithStatus' + def graph = new DependencyGraphBuilder().addModule('test.resolved:a:1.0.0:release') + .addModule('test.resolved:a:1.1.0:release').build() + def generator = new GradleDependencyGenerator(graph, directory) + + when: + generator.generateTestIvyRepo() + + then: + def ivyRepo = new File('build/testdependencies/ivypublishAddModuleWithStatus') + def xml = new File(ivyRepo, 'ivyrepo/test/resolved/a/1.1.0/a-1.1.0-ivy.xml') + xml.exists() + xml.text.contains("status=\"release\"") + } + + def 'publishes ivy status using DependencyGraphBuilder.addModule'() { + given: + def directory = 'build/testdependencies/ivypublishAddModule' + def graph = new DependencyGraphBuilder().addModule('test.resolved:a:1.0.0') + .addModule('test.resolved:a:1.1.0').build() + def generator = new GradleDependencyGenerator(graph, directory) + + when: + generator.generateTestIvyRepo() + + then: + def ivyRepo = new File('build/testdependencies/ivypublishAddModule') + def xml = new File(ivyRepo, 'ivyrepo/test/resolved/a/1.1.0/a-1.1.0-ivy.xml') + xml.exists() + xml.text.contains("status=\"integration\"") + } + + def 'DependencyGraphBuilder using map for DependencyGraph'() { + given: + def directory = 'build/testdependencies/ivypublishMap' + def graph = ['test.resolved:a:1.0.0', 'test.resolved:a:1.1.0'] + def generator = new GradleDependencyGenerator(new DependencyGraph(graph), directory) + + when: + generator.generateTestIvyRepo() + + then: + def ivyRepo = new File('build/testdependencies/ivypublishMap') + def xml = new File(ivyRepo, 'ivyrepo/test/resolved/a/1.1.0/a-1.1.0-ivy.xml') + xml.exists() + xml.text.contains("status=\"integration\"") + } + def 'generate an ivy repo'() { def directory = 'build/testdependencies/testivyrepo' def graph = ['test.ivy:foo:1.0.0']