Skip to content

Commit

Permalink
Merge pull request #89 from chali/FixMultiModuleBuild
Browse files Browse the repository at this point in the history
Fix verification for multimodule build with submodule dependency
  • Loading branch information
chali authored Jan 30, 2018
2 parents fe3a1db + 6f847a3 commit 9869e8c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ class VerifyPublicationTask extends DefaultTask {
forVerification.each {
ModuleVersionIdentifier id = it.module.id
ComponentMetadataDetails metadata = details[id]
int projectStatus = metadata.statusScheme.indexOf(project.status)
int moduleStatus = metadata.statusScheme.indexOf(metadata.status)
if (moduleStatus < projectStatus) {
DefinedDependency definedDependency = definedDependencies["${id.group}:${id.name}".toString()]
def (String definedDependencyToPrint, String configuration) = getDefinedDependencyWithConfiguration(definedDependency, id)
throw new BuildCancelledException("""
//we cannot collect metadata for dependencies on another modules in multimodule build
if (metadata != null) {
int projectStatus = metadata.statusScheme.indexOf(project.status)
int moduleStatus = metadata.statusScheme.indexOf(metadata.status)
if (moduleStatus < projectStatus) {
DefinedDependency definedDependency = definedDependencies["${id.group}:${id.name}".toString()]
def (String definedDependencyToPrint, String configuration) = getDefinedDependencyWithConfiguration(definedDependency, id)
throw new BuildCancelledException("""
Module '${id.group}:${id.name}' resolved to version '${id.version}'.
It cannot be used because it has status: '${metadata.status}' which is less then your current project status: '${project.status}' in your status scheme: ${metadata.statusScheme}.
*** OPTIONS ***
1) Use specific version with higher status or 'latest.${project.status}'.
2) ignore this check with "${configuration} nebulaPublishVerification.ignore('$definedDependencyToPrint')".
""".stripIndent())
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,56 @@ class PublishVerificationPluginIntegrationSpec extends IntegrationSpec {
result.standardOutput.contains(":publishNebulaIvyPublicationToDistIvyRepository")
}

def 'should work with multi project build'() {
given:
def projectStatus = 'release'
def expectedFailureDependency = 'foo:bar:1.0-SNAPSHOT'
DependencyGraphBuilder builder = new DependencyGraphBuilder()
builder.addModule(expectedFailureDependency)
DependencyGraph graph = builder.build()
def generator = new GradleDependencyGenerator(graph)
File mavenRepoDir = generator.generateTestMavenRepo()

buildFile << """
allprojects {
${applyPlugin(IvyPublishPlugin)}
apply plugin: 'java'
group = 'test.nebula.netflix'
status = '$projectStatus'
version = '1.0'
repositories {
maven {
url "file://$mavenRepoDir.canonicalPath"
}
}
${publishingRepos()}
}
"""

settingsFile.text = '''\
rootProject.name='testhello'
'''

addSubproject('common')
addSubproject('consumer', """
dependencies {
compile project(':common')
compile '$expectedFailureDependency'
}
""")

when:
def result = runTasksWithFailure('build', 'publishNebulaIvyPublicationToDistIvyRepository')

then:
assertFailureMessage(result, expectedFailureDependency, projectStatus)

}

def 'should work with java-library plugin'() {
given:
def projectStatus = 'release'
Expand Down

0 comments on commit 9869e8c

Please sign in to comment.