Skip to content

Commit

Permalink
Add PomFilter to filter out "scoverage" and "silencer"
Browse files Browse the repository at this point in the history
Motivation:

- "provided" does not remove dependencies from a pom.xml
- use a snippet from #739 to exclude undesired dependencies
- apply PomFilter to exlude scoverage too.
  • Loading branch information
kubum committed Mar 22, 2020
1 parent b0e622e commit ccee7fd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 14 deletions.
20 changes: 6 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,14 @@ val commonSettings = Seq(
|limitations under the License.""".stripMargin
)
),
// For evicting Scoverage out of the generated POM
// See: https://github.com/scoverage/sbt-scoverage/issues/153
pomPostProcess := { (node: xml.Node) =>
new RuleTransformer(new RewriteRule {
override def transform(node: xml.Node): Seq[xml.Node] = node match {
case e: Elem
if e.label == "dependency" && e.child
.exists(child => child.label == "groupId" && child.text == "org.scoverage") =>
Nil
case _ => Seq(node)
}
}).transform(node).head
},
addCompilerPlugin(("org.typelevel" %% "kind-projector" % "0.11.0").cross(CrossVersion.full)),
mimaFailOnNoPrevious := false
)
) ++
// For evicting Scoverage out of the generated POM
// See: https://github.com/scoverage/sbt-scoverage/issues/153
PomFilter.filterOutDependencyFromGeneratedPomXml("groupId" -> "org\\.scoverage".r) ++
PomFilter.filterOutDependencyFromGeneratedPomXml("groupId" -> "com\\.github\\.ghik".r,
"artifactId" -> "silencer-lib".r)

val mimaSettings = Seq(
mimaPreviousArtifacts := {
Expand Down
3 changes: 3 additions & 0 deletions core/shared/src/main/scala/cats/effect/concurrent/MVar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ sealed private[concurrent] trait MVarDocumentation extends Any {}
*/
@deprecated("`MVar` is now deprecated in favour of a new generation `MVar2` with `tryRead` and `swap` support", "2.2.0")
abstract class MVar[F[_], A] extends MVarDocumentation {

/**
* Returns `true` if the `MVar` is empty and can receive a `put`, or
* `false` otherwise.
Expand Down Expand Up @@ -135,6 +136,7 @@ abstract class MVar[F[_], A] extends MVarDocumentation {
*/
@silent("deprecated")
abstract class MVar2[F[_], A] extends MVar[F, A] {

/**
* Replaces a value in MVar and returns the old value.
Expand All @@ -161,6 +163,7 @@ abstract class MVar2[F[_], A] extends MVar[F, A] {

/** Builders for [[MVar]]. */
object MVar {

/**
* Builds an [[MVar]] value for `F` data types that are [[Concurrent]].
*
Expand Down
44 changes: 44 additions & 0 deletions project/PomFilter.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import scala.util.matching.Regex
import scala.xml.Elem
import scala.xml.transform.{RewriteRule, RuleTransformer}
import sbt.Keys.pomPostProcess

object PomFilter {

/**
* Filter out dependencies from the generated `pom.xml`.
*
* E.g. to exclude Scoverage:
* {{{
* filterOutDependencyFromGeneratedPomXml("groupId" -> "org\\.scoverage".r)
* }}}
*
* Or to exclude based on both `groupId` and `artifactId`:
* {{{
* filterOutDependencyFromGeneratedPomXml("groupId" -> "io\\.estatico".r, "artifactId" -> "newtype".r)
* }}}
*/
def filterOutDependencyFromGeneratedPomXml(conditions: (String, Regex)*) = {
def shouldExclude(e: Elem) =
e.label == "dependency" && {
conditions.forall {
case (key, regex) =>
e.child.exists(child => child.label == key && regex.findFirstIn(child.text).isDefined)
}
}

if (conditions.isEmpty) Nil
else {
Seq(
pomPostProcess := { (node: xml.Node) =>
new RuleTransformer(new RewriteRule {
override def transform(node: xml.Node): Seq[xml.Node] = node match {
case e: Elem if shouldExclude(e) => Nil
case _ => Seq(node)
}
}).transform(node).head
}
)
}
}
}

0 comments on commit ccee7fd

Please sign in to comment.