Skip to content

Commit

Permalink
Merge pull request #103 from nebula-plugins/fix-ivy-test-publication
Browse files Browse the repository at this point in the history
Fix how we create a graph when status is not provided via builder
  • Loading branch information
rpalcolea authored Dec 11, 2018
2 parents 7ddc323 + d8018ca commit f3fe2ad
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package nebula.test.dependencies

class DependencyGraphBuilder {

private static final DEFAULT_STATUS = 'integration'

Map<String, DependencyGraphNode> 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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit f3fe2ad

Please sign in to comment.