Skip to content

Commit

Permalink
graadle module dependnecies that have the same version as root projec…
Browse files Browse the repository at this point in the history
…t should not be detected as snapshots | fixes #827
  • Loading branch information
bgalek committed Oct 4, 2024
1 parent a158fe6 commit e4dab4a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,46 @@ class VerifyReleaseIntegrationTest extends BaseIntegrationTest {
result.task(":verifyRelease").outcome == TaskOutcome.SUCCESS
}

def "should work in multimodule project setup"() {
def "should work in multimodule project setup versioning every module separately"() {
given:
initialMultiModuleProjectConfiguration()
initialMultiModuleMultiVersionProjectConfiguration()

when:
def result = runGradle(':verifyRelease')

then:
// no snapshot modules allowed by default
result.task(":verifyRelease").outcome == TaskOutcome.SUCCESS
}

void initialMultiModuleProjectConfiguration() {
def "should work in multimodule project setup with the same version for every module"() {
given:
initialMultiModuleSingleVersionProjectConfiguration()

when:
def result = runGradle(':verifyRelease')

then:
// snapshot modules with the same version as root project are ok
result.task(":verifyRelease").outcome == TaskOutcome.SUCCESS
}

void initialMultiModuleSingleVersionProjectConfiguration() {
buildFile('''
scmVersion {
versionCreator "versionWithBranch"
}
allprojects {
version = scmVersion.version
}
''')
generateSettingsFile(temporaryFolder)
generateGitIgnoreFile(temporaryFolder)
generateSubmoduleBuildFile("module1")
repository.commit(['.'], "initial commit of top level project")
}

void initialMultiModuleMultiVersionProjectConfiguration() {
buildFile('''
scmVersion {
versionCreator "versionWithBranch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.DependencyConstraint;
import org.gradle.api.internal.project.DefaultProject;

import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -55,6 +56,9 @@ private String toFullVersion(Object it) {
} else if (it instanceof DependencyConstraint) {
DependencyConstraint constraint = (DependencyConstraint) it;
return String.format("%s:%s:%s", constraint.getGroup(), constraint.getName(), constraint.getVersion());
} else if (it instanceof DefaultProject) {
DefaultProject project = ((DefaultProject) it);
return String.format("%s:%s:%s", project.getGroup(), project.getName(), project.getRootProject().getVersion());
}
return "";
}
Expand Down

0 comments on commit e4dab4a

Please sign in to comment.