Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,32 @@ object SubmitDependencyGraph {
// project refs that have a Scala version, filtered according to input.projects
private def getScalaProjectRefs(state: State, input: SubmitInput): Seq[ProjectRef] = {
val loadedBuild = state.setting(Keys.loadedBuild)
val allScalaProjectRefs = loadedBuild.allProjectRefs
val allProjectRefs = loadedBuild.allProjectRefs
.map(_._1)
.filter(ref => state.getSetting(ref / Keys.scalaVersion).isDefined)
val projectFilter = input.projects.toSet
if (projectFilter.isEmpty) allScalaProjectRefs
else allScalaProjectRefs.filter(ref => projectFilter.contains(ref.project))
if (input.projects.isEmpty) allProjectRefs
else {
val allProjectNames = allProjectRefs.map(_.project)
val unknownProjects = input.projects.filter(p => !allProjectNames.contains(p))
if (unknownProjects.nonEmpty)
throw new MessageOnlyException(s"Unknown projects: ${unknownProjects.mkString(", ")}")
allProjectRefs.filter(ref => input.projects.contains(ref.project))
}
}

private def getScalaVersions(state: State, input: SubmitInput, projectRefs: Seq[ProjectRef]): Seq[String] = {
val scalaVersionFilter = input.scalaVersions.toSet
val allScalaVersions = projectRefs
val allVersions = projectRefs
.flatMap(projectRef => state.setting(projectRef / Keys.crossScalaVersions))
.distinct
if (scalaVersionFilter.isEmpty) allScalaVersions
else allScalaVersions.filter(scalaVersionFilter.contains)
if (input.scalaVersions.isEmpty) allVersions
else {
val unknownVersions = input.scalaVersions.filter(v => !allVersions.contains(v))
if (unknownVersions.nonEmpty) {
val projectSelection = if (input.projects.nonEmpty) "selected projects" else "build"
state.log.warn(s"Unknown Scala versions in the $projectSelection: ${unknownVersions.mkString(", ")}")
}
input.scalaVersions
}
}

private def githubDependencySnapshot(state: State): DependencySnapshot = {
Expand Down
13 changes: 11 additions & 2 deletions sbt-plugin/src/sbt-test/submit-snapshot/ci-submit/test
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
> 'githubSubmitDependencyGraph {}'
> checkManifests 5
> 'githubSubmitDependencyGraph {"projects":[], "scalaVersions":["2.13.8"]}'

> 'githubSubmitDependencyGraph {"scalaVersions":["2.13.8"]}'
> checkManifests 3

> 'githubSubmitDependencyGraph {"projects":[], "scalaVersions":["2.12.16", "2.13.8"]}'
> checkManifests 4

> 'githubSubmitDependencyGraph {"projects":["a", "b"], "scalaVersions":[]}'
> checkManifests 4
> 'githubSubmitDependencyGraph {"projects":["a"], "scalaVersions":["2.12.16", "3.1.3"]}'

# slightly different scala versions than defined in project a
# it should still work since the binary versions are the same
> 'githubSubmitDependencyGraph {"projects":["a"], "scalaVersions":["2.12.15", "3.1.2"]}'
> checkManifests 2

# Unknown project c, it should fail
-> 'githubSubmitDependencyGraph {"projects":["b", "c"]}'