Skip to content

Commit

Permalink
Feature: SBT - disable docs publish (#578)
Browse files Browse the repository at this point in the history
* Feature: SBT - disable docs publish

* fix

* fix 2.12 build
  • Loading branch information
Caparow authored Jan 22, 2025
1 parent 4469e70 commit 588f3b8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ case class SbtOptions(
enableScalaJs: Boolean,
scalaVersion: Option[String],
sbtVersion: Option[String],
enableDocs: Option[Boolean],
)

object SbtOptions {
Expand All @@ -23,6 +24,7 @@ object SbtOptions {
enableScalaJs = true,
scalaVersion = None,
sbtVersion = None,
enableDocs = None,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ sealed trait SbtDslOp

object SbtDslOp {

final case class Append[T](v: T, scope: Scope = Scope.ThisBuild) extends SbtDslOp
final case class Append[T](v: T, scope: List[Scope]) extends SbtDslOp
object Append {
def apply[T](v: T, scope: Scope = Scope.ThisBuild): Append[T] = {
new Append[T](v, List(scope))
}
}

final case class Assign[T](v: T, scope: Scope = Scope.ThisBuild) extends SbtDslOp
final case class Assign[T](v: T, scope: List[Scope]) extends SbtDslOp
object Assign {
def apply[T](v: T, scope: Scope = Scope.ThisBuild): Assign[T] = {
new Assign[T](v, List(scope))
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ class SbtRenderer {
parts.mkString(" ")
}

def renderScope(scope: Scope, key: String): String = {
scope match {
case Scope.ThisBuild =>
s"ThisBuild / $key"
case Scope.Project =>
key
def renderScope(scopes: List[Scope], key: String): String = {
if (scopes == List(Scope.Project)) {
key
} else {
(scopes ++ List(Scope.Custom(key))).map {
case Scope.ThisBuild => "ThisBuild"
case Scope.Project => "ThisProject"
case Scope.Custom(scope) => scope
}.mkString(" / ")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class ScalaLayouter(options: ScalaTranslatorOptions) extends TranslationLayouter
Seq("resolvers" -> Append(RawExpr("Opts.resolver.sonatypeReleases")))
}

val docs = Seq(
"publishArtifact" -> Assign(options.manifest.sbt.enableDocs.getOrElse(false), List(Scope.ThisBuild, Scope.Custom("packageDoc"))),
)

val metadata = Seq(
"name" -> Assign(options.manifest.common.name, Scope.Project),
"organization" -> Assign(options.manifest.common.group),
Expand All @@ -122,7 +126,7 @@ class ScalaLayouter(options: ScalaTranslatorOptions) extends TranslationLayouter
)

val renderer = new SbtRenderer()
val keys = (metadata ++ resolvers ++ deps ++ circeDerivationWorkaround).map(renderer.renderOp)
val keys = (docs ++ metadata ++ resolvers ++ deps ++ circeDerivationWorkaround).map(renderer.renderOp)

val content = keys ++ projDefs ++ Seq(bundle, agg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ object Scope {

case object Project extends Scope

case class Custom(scope: String) extends Scope
}

0 comments on commit 588f3b8

Please sign in to comment.