diff --git a/sbt-version-policy/src/main/scala/sbtversionpolicy/SbtVersionPolicySettings.scala b/sbt-version-policy/src/main/scala/sbtversionpolicy/SbtVersionPolicySettings.scala index de62bc0..eca1619 100644 --- a/sbt-version-policy/src/main/scala/sbtversionpolicy/SbtVersionPolicySettings.scala +++ b/sbt-version-policy/src/main/scala/sbtversionpolicy/SbtVersionPolicySettings.scala @@ -314,22 +314,35 @@ object SbtVersionPolicySettings { } } }.value, - versionPolicyFindIssues := { - val dependencyIssues = versionPolicyFindDependencyIssues.value - val mimaIssues = versionPolicyFindMimaIssues.value - assert( - dependencyIssues.map(_._1.revision).toSet == mimaIssues.map(_._1.revision).toSet, - "Dependency issues and Mima issues must be checked against the same previous releases" - ) - for ((previousModule, dependencyReport) <- dependencyIssues) yield { - val (_, problems) = - mimaIssues - .find { case (id, _) => previousModule.revision == id.revision } - .get // See assertion above - previousModule -> (dependencyReport, problems) - } - }, - versionPolicyAssessCompatibility := { + versionPolicyFindIssues := Def.ifS((versionPolicyFindIssues / skip).toTask)(Def.task { + streams.value.log.debug("Not finding incompatibilities with previous releases because 'versionPolicyFindIssues / skip' is 'true'") + Seq.empty[(ModuleID, (DependencyCheckReport, Seq[(IncompatibilityType, Problem)]))] + })( + Def.ifS[Seq[(ModuleID, (DependencyCheckReport, Seq[(IncompatibilityType, Problem)]))]](Def.task { + versionPolicyPreviousVersions.value.isEmpty + })(Def.task { + throw new MessageOnlyException("Unable to find compatibility issues because versionPolicyPreviousVersions is empty.") + })(Def.task { + versionPolicyPreviousVersions.value + val dependencyIssues = versionPolicyFindDependencyIssues.value + val mimaIssues = versionPolicyFindMimaIssues.value + assert( + dependencyIssues.map(_._1.revision).toSet == mimaIssues.map(_._1.revision).toSet, + "Dependency issues and Mima issues must be checked against the same previous releases" + ) + for ((previousModule, dependencyReport) <- dependencyIssues) yield { + val (_, problems) = + mimaIssues + .find { case (id, _) => previousModule.revision == id.revision } + .get // See assertion above + previousModule -> (dependencyReport, problems) + } + }) + ).value, + versionPolicyAssessCompatibility := Def.ifS((versionPolicyAssessCompatibility / skip).toTask)(Def.task { + streams.value.log.debug("Not assessing the compatibility with previous releases because 'versionPolicyAssessCompatibility / skip' is 'true'") + Seq.empty[(ModuleID, Compatibility)] + })(Def.task { // Results will be flawed if the `versionPolicyIntention` is set to `BinaryCompatible` or `None` // because `versionPolicyFindIssues` only reports the issues that violate the intended compatibility level if (versionPolicyIntention.?.value.exists(_ != Compatibility.BinaryAndSourceCompatible)) { @@ -353,12 +366,13 @@ object SbtVersionPolicySettings { } previousRelease -> compatibility } - } + }).value ) def skipSettings = Seq( versionCheck / skip := (publish / skip).value, - versionPolicyCheck / skip := (publish / skip).value + versionPolicyCheck / skip := (publish / skip).value, + versionPolicyAssessCompatibility / skip := (publish / skip).value, ) def schemesGlobalSettings = Seq( diff --git a/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/build.sbt b/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/build.sbt index 85df998..910700b 100644 --- a/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/build.sbt +++ b/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/build.sbt @@ -14,3 +14,10 @@ val v101 = version := "1.0.1", versionPolicyIntention := Compatibility.BinaryCompatible ) + +val root = + project.in(file(".")) + .settings( + name := "library-test-skip-root", + ) + .aggregate(v101) diff --git a/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/test b/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/test index b1447dd..547c8e7 100644 --- a/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/test +++ b/sbt-version-policy/src/sbt-test/sbt-version-policy/skip-publish/test @@ -8,3 +8,7 @@ > set v101/publish/skip := true > v101/versionPolicyCheck > v101/versionCheck + +-> root/versionPolicyAssessCompatibility +> set root/publish/skip := true +> root/versionPolicyAssessCompatibility