Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes retrieval of ModuleComponentIdentifier #74

Merged
merged 2 commits into from
Nov 1, 2023
Merged
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 @@ -33,6 +33,7 @@ import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.ArtifactView.ViewConfiguration
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
import org.gradle.api.artifacts.result.ComponentArtifactsResult
import org.gradle.api.artifacts.result.ResolvedArtifactResult
import org.gradle.api.attributes.Attribute
Expand Down Expand Up @@ -1032,13 +1033,18 @@ class BloopConverter(parameters: BloopParameters) {
parameters.stdLibName
.map(List.apply(_))
.getOrElse(List("scala-library", "scala3-library_3"))

val artifactIds = artifacts
.map(_.getId)
.collect({ case mcai: ModuleComponentArtifactIdentifier => mcai })
val stdLibIds =
artifactIds.filter(f => stdLibNames.contains(f.getComponentIdentifier.getModule))
.map(_.getId.getComponentIdentifier())
.collect {
case mid: ModuleComponentIdentifier => mid
}

val stdLibIds = artifactIds
.filter(mid => stdLibNames.contains(mid.getModule()))

stdLibIds.headOption match {
case Some(stdLibArtifact) =>
case Some(stdLibArtifactId) =>
val scalaCompileTask = sourceSet
.map(sourceSet => {
// task name is defined on the source set
Expand All @@ -1054,8 +1060,8 @@ class BloopConverter(parameters: BloopParameters) {

scalaCompileTask match {
case Some(compileTask) =>
val scalaVersion = stdLibArtifact.getComponentIdentifier.getVersion
val scalaOrg = stdLibArtifact.getComponentIdentifier.getGroup
val scalaVersion = stdLibArtifactId.getVersion
val scalaOrg = stdLibArtifactId.getGroup
val scalaJars =
compileTask.getScalaClasspath.asScala.map(_.toPath).toList
val opts = compileTask.getScalaCompileOptions
Expand Down Expand Up @@ -1105,7 +1111,7 @@ class BloopConverter(parameters: BloopParameters) {
.mkString("\n")}"
Failure(
new GradleException(
s"Expected ${parameters.stdLibName} library in classpath of $target that defines Scala sources.$artifactNames"
s"Missing Scala standard library (${stdLibIds}) in classpath of Scala sourceset $target.$artifactNames"
)
)
}
Expand Down