Skip to content

Commit

Permalink
Merge pull request #74 from jvican/jorge/fix-module-artifact-id
Browse files Browse the repository at this point in the history
Fixes retrieval of `ModuleComponentIdentifier`
  • Loading branch information
adpi2 committed Nov 1, 2023
2 parents 854669d + 6e3f971 commit c5aa3b8
Showing 1 changed file with 14 additions and 8 deletions.
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 @@ -1030,13 +1031,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 @@ -1052,8 +1058,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 @@ -1103,7 +1109,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

0 comments on commit c5aa3b8

Please sign in to comment.