Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.
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
16 changes: 10 additions & 6 deletions src/main/scala/ch/epfl/scala/GithubDependencyGraphPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,8 @@ object GithubDependencyGraphPlugin extends AutoPlugin {
val resolved =
for ((moduleReport, configRef) <- moduleReports)
yield {
val module = moduleReport.module
val moduleRef = getReference(module)
val artifacts = moduleReport.artifacts.map { case (a, _) => a }
val classifiers = artifacts.flatMap(_.classifier).filter(_ != "default")
val packaging = if (classifiers.nonEmpty) "?" + classifiers.map(c => s"packaging=$c") else ""
val packageUrl = s"pkg:maven/${module.organization}/${module.name}@${module.revision}$packaging"
val moduleRef = getReference(moduleReport.module)
val packageUrl = formatPackageUrl(moduleReport)
val dependencies = allDependenciesMap.getOrElse(moduleRef, Vector.empty)
val relationship =
if (allDirectDependenciesRefs.contains(moduleRef)) DependencyRelationship.direct
Expand All @@ -153,6 +149,14 @@ object GithubDependencyGraphPlugin extends AutoPlugin {
githubapi.Manifest(projectModuleRef, file, metadata, resolved.toMap)
}

private def formatPackageUrl(moduleReport: ModuleReport): String = {
val module = moduleReport.module
val artifacts = moduleReport.artifacts.map { case (a, _) => a }
val classifiers = artifacts.flatMap(_.classifier).filter(_ != "default")
val packaging = if (classifiers.nonEmpty) "?" + classifiers.map(c => s"packaging=$c").mkString("&") else ""
s"pkg:maven/${module.organization}/${module.name}@${module.revision}$packaging"
}

private def isRuntime(config: ConfigRef): Boolean = runtimeConfigs.contains(config)

private def githubCIEnv(name: String): String =
Expand Down
47 changes: 47 additions & 0 deletions src/sbt-test/dependency-manifest/package-urls/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import ch.epfl.scala.githubapi.DependencyRelationship
import ch.epfl.scala.githubapi.DependencyScope
import ch.epfl.scala.githubapi.Manifest
import sjsonnew.shaded.scalajson.ast.unsafe.JString

val checkManifest = taskKey[Unit]("Check the Github manifest of a project")

inThisBuild(
Seq(
organization := "ch.epfl.scala",
version := "1.2.0-SNAPSHOT",
// use Ivy because Coursier does not allow several classifier on the same dep
useCoursier := false,
scalaVersion := "2.12.15"
)
)

lazy val p1 = project
.in(file("p1"))
.settings(
libraryDependencies ++= Seq(
("com.google.inject" % "guice" % "4.0").classifier("no_aop"),
("org.lwjgl" % "lwjgl" % "3.3.1")
.classifier("natives-windows")
.classifier("natives-linux")
.classifier("natives-macos")
),
checkManifest := {
val manifest = githubDependencyManifest.value

checkDependency(manifest, "com.google.inject:guice:4.0")(
expectedPackageUrl = "pkg:maven/com.google.inject/[email protected]?packaging=no_aop"
)
checkDependency(manifest, "org.lwjgl:lwjgl:3.3.1")(
expectedPackageUrl =
"pkg:maven/org.lwjgl/[email protected]?packaging=natives-linux&packaging=natives-macos&packaging=natives-windows"
)
}
)

def checkDependency(manifest: Manifest, name: String)(expectedPackageUrl: String): Unit = {
val node = manifest.resolved(name)
assert(
node.package_url == expectedPackageUrl,
s"Wrong package_url for node $name:\nfound: ${node.package_url}\nexpected:$expectedPackageUrl"
)
}
1 change: 1 addition & 0 deletions src/sbt-test/dependency-manifest/scala3-manifest/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> p1 / checkManifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ inThisBuild(
Seq(
organization := "ch.epfl.scala",
version := "1.2.0-SNAPSHOT",
// use Ivy because Coursier does not allow several classifier on the same dep
useCoursier := false,
scalaVersion := "2.13.8"
)
)
Expand All @@ -19,6 +21,13 @@ val a = project
"2.12.16",
"2.13.8",
"3.1.3"
),
libraryDependencies ++= Seq(
// a dependency with many classifiers
("org.lwjgl" % "lwjgl" % "3.3.1")
.classifier("natives-windows")
.classifier("natives-linux")
.classifier("natives-macos")
)
)

Expand Down
3 changes: 3 additions & 0 deletions src/sbt-test/submit-snapshot/ci-submit/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
val pluginVersion = sys.props("plugin.version")

addSbtPlugin("ch.epfl.scala" % "sbt-github-dependency-graph" % pluginVersion)