Skip to content

Commit

Permalink
Honor publish / skip setting (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrf authored Apr 28, 2021
1 parent 8f93569 commit 323d010
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 7 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,26 @@ The following compatibility types are available:
If no rules for a module are found in `versionPolicyDependencySchemes`, `versionPolicyDefaultScheme` is used
as a compatibility type. Its default value is `VersionCompatibility.PackVer` (package versioning policy).

### Disable the tasks `versionPolicyCheck` or `versionCheck` on a specific project

You can disable the tasks `versionPolicyCheck` and `versionCheck` at the
project level by using the `skip` key.

By default, both `versionPolicyCheck / skip` and `versionCheck / skip` are
initialized to `(publish / skip).value`. So, to disable both tasks on
a given project, set the following:

~~~ scala
publish / skip := true
~~~

Or, if you need more fine-grained control:

~~~ scala
versionPolicyCheck / skip := true
versionCheck / skip := true
~~~

## Acknowledgments

<img src="https://scala.epfl.ch/resources/img/scala-center-swirl.png" width="40px" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object SbtVersionPolicyPlugin extends AutoPlugin {
SbtVersionPolicySettings.updateSettings ++
SbtVersionPolicySettings.reconciliationSettings ++
SbtVersionPolicySettings.previousArtifactsSettings ++
SbtVersionPolicySettings.findIssuesSettings
SbtVersionPolicySettings.findIssuesSettings ++
SbtVersionPolicySettings.skipSettings

}
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ object SbtVersionPolicySettings {
if (anyError)
throw new Exception("Compatibility check failed (see messages above)")
},
versionCheck := {
versionCheck := Def.ifS((versionCheck / skip).toTask)(Def.task {
()
})(Def.task {
val intention =
versionPolicyIntention.?.value
.getOrElse(throw new MessageOnlyException("Please set the key versionPolicyIntention to declare the compatibility guarantees of this release"))
val versionValue = version.value
val s = streams.value
val projectId = thisProject.value.id
val s = streams.value
val projectId = thisProject.value.id

if (Compatibility.isValidVersion(intention, versionValue)) {
s.log.info(s"$projectId/$versionValue is a valid version number with respect to the compatibility guarantees '$intention'")
Expand All @@ -238,11 +240,13 @@ object SbtVersionPolicySettings {
else "You must increment the minor version number to publish a source incompatible release."
throw new MessageOnlyException(s"$projectId/$versionValue is not a valid version number. $detail")
}
},
versionPolicyCheck := {
}).value,
versionPolicyCheck := Def.ifS((versionPolicyCheck / skip).toTask)(Def.task {
()
})(Def.task {
val ignored1 = versionPolicyMimaCheck.value
val ignored2 = versionPolicyReportDependencyIssues.value
},
}).value,
versionPolicyForwardCompatibilityCheck := {
import MimaPlugin.autoImport._
val it = MimaIssues.forwardBinaryIssuesIterator.value
Expand Down Expand Up @@ -288,6 +292,11 @@ object SbtVersionPolicySettings {
}).value
)

def skipSettings = Seq(
versionCheck / skip := (publish / skip).value,
versionPolicyCheck / skip := (publish / skip).value
)

def schemesGlobalSettings = Seq(
versionPolicyDependencySchemes := Seq.empty,
versionScheme := Some("early-semver")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ThisBuild / organization := "com.example"
ThisBuild / scalaVersion := "2.13.2"

val v100 =
project.in(file("v1-0-0")).settings(
name := "library-test-skip",
version := "1.0.0",
versionPolicyIntention := Compatibility.None
)

val v101 =
project.in(file("v1-0-1")).settings(
name := "library-test-skip",
version := "1.0.1",
versionPolicyIntention := Compatibility.BinaryCompatible
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % sys.props("plugin.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
> v100/publishLocal
> reload

-> v101/versionPolicyCheck
-> v101/versionCheck

# If project is not published, no checks are performed and versionPolicyCheck and versionCheck succeed
> set v101/publish/skip := true
> v101/versionPolicyCheck
> v101/versionCheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package librarytest

trait Foo {

def bar(x: Int): Int = x

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package librarytest

trait Foo {

}

0 comments on commit 323d010

Please sign in to comment.