Skip to content

Commit

Permalink
Merge pull request #495 from armanbilge/topic/cross-project-cross-type
Browse files Browse the repository at this point in the history
Use new sbt-crossproject settings
  • Loading branch information
armanbilge authored Apr 22, 2023
2 parents 6294e51 + 4a995ac commit fbcd01c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions mergify/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
libraryDependencies += "io.circe" %% "circe-yaml" % "0.14.2"
addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "1.3.1")
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.typelevel.sbt.mergify

import org.typelevel.sbt.gha._
import sbt._
import sbtcrossproject.CrossPlugin.autoImport._

import java.nio.file.Path

Expand Down Expand Up @@ -152,13 +153,7 @@ object MergifyPlugin extends AutoPlugin {
}

private lazy val projectLabel = Def.setting {
val path = (Compile / sourceDirectories)
.?
.value
.getOrElse(Seq.empty)
.map(_.toPath)
.foldLeft(baseDirectory.value.toPath)(commonAncestor(_, _))

val path = crossProjectBaseDirectory.?.value.getOrElse(baseDirectory.value).toPath
val label = path.getFileName.toString

def isRoot = path == (LocalRootProject / baseDirectory).value.toPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.typelevel.sbt.kernel.GitHelper
import org.typelevel.sbt.kernel.V
import sbt._
import sbtcrossproject.CrossPlugin.autoImport._
import sbtcrossproject.CrossType

import java.io.File
import java.lang.management.ManagementFactory
Expand Down Expand Up @@ -260,17 +259,18 @@ object TypelevelSettingsPlugin extends AutoPlugin {
private val perConfigSettings = Seq(
unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
if (crossProjectPlatform.?.value.isDefined)
List(CrossType.Pure, CrossType.Full).flatMap {
_.sharedSrcDir(baseDirectory.value, Defaults.nameForSrc(configuration.value.name))
crossProjectCrossType.?.value match {
case Some(crossType) =>
crossType
.sharedSrcDir(baseDirectory.value, Defaults.nameForSrc(configuration.value.name))
.toList
.map(f => file(f.getPath + suffix))
}
else
List(
baseDirectory.value / "src" / Defaults.nameForSrc(
configuration.value.name) / s"scala$suffix"
)
case None =>
List(
baseDirectory.value / "src" /
Defaults.nameForSrc(configuration.value.name) / s"scala$suffix"
)
}

CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) if y <= 12 => extraDirs("-2.12-")
Expand Down

0 comments on commit fbcd01c

Please sign in to comment.