Skip to content

Commit

Permalink
Fix bugs with deps generator (#52)
Browse files Browse the repository at this point in the history
* Dependencies.scala file added

* BUILD file for deps modified

* dependencies duplication fixed

* dependencies duplication fixed

---------

Co-authored-by: anna-skrodzka <annaskrod@h=gmail.com>
  • Loading branch information
anna-skrodzka and anna-skrodzka authored Nov 2, 2024
1 parent 785f03c commit 48431d6
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
1 change: 0 additions & 1 deletion 3rdparty/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def jar_artifact_callback(hash):
)
native.bind(name = hash["bind"], actual = hash["actual"])


def list_dependencies():
return [
{"artifact":"com.github.scopt:scopt_3:4.1.0","url":"https://repo1.maven.org/maven2/com/github/scopt/scopt_3/4.1.0/scopt_3-4.1.0.jar","name":"com_github_scopt_scopt_3","actual":"@com_github_scopt_scopt_3//jar","bind": "jar/com/github/scopt/scopt_3"},
Expand Down
13 changes: 13 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
load("@rules_scala3//deps:scala_deps.bzl", "scala_deps")
load("@rules_scala3//rules:scala.bzl", "configure_zinc_scala")

filegroup(
name = "dependencies",
srcs = ["Dependencies.scala"],
visibility = ["//visibility:public"],
)

scala_deps(
name = "scala_deps",
src = "//:dependencies",
dependencies = "rules_scala3.Dependencies",
)

runtime_classpath_3 = [
"@scala3_library//jar",
"@scala_library_2_13//jar",
Expand Down
31 changes: 31 additions & 0 deletions Dependencies.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package rules_scala3

import sbt.librarymanagement.syntax.*
import sbt.librarymanagement.{DependencyBuilders, ModuleID, Resolver}, DependencyBuilders.OrganizationArtifactName

object Dependencies:

private val jmhV = "1.37"

val resolvers: Seq[Resolver] = Vector(
"mavencentral".at("https://repo1.maven.org/maven2/"),
"sonatype releases".at("https://oss.sonatype.org/service/local/repositories/releases/content"),
"apache staging".at("https://repository.apache.org/content/repositories/staging"),
"apache snapshots".at("https://repository.apache.org/snapshots"),
"google".at("https://maven.google.com/"),
"jitsi-maven-repository".at("https://github.com/jitsi/jitsi-maven-repository/raw/master/releases")
)
// Replacements are not handled by `librarymanagement`. any Scala prefix in the name will be dropped.
// It also doesn't matter whether you use double `%` to get the Scala version or not.
val replacements: Map[OrganizationArtifactName, String] = Map(
"org.scala-lang" % "scala3-library" -> "@scala3_library//jar",
"org.scala-lang" % "scala-library" -> "@scala_library_2_13//jar",
"org.scala-lang" % "scala-reflect" -> "@scala_reflect_2_13//jar"
)
val dependencies: Seq[ModuleID] = Vector(
"org.openjdk.jmh" % "jmh-core" % jmhV,
"org.openjdk.jmh" % "jmh-generator-bytecode" % jmhV,
"org.openjdk.jmh" % "jmh-generator-reflection" % jmhV,
"org.openjdk.jmh" % "jmh-generator-asm" % jmhV,
"com.github.scopt" %% "scopt" % "4.1.0"
)
8 changes: 6 additions & 2 deletions deps/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ load("//rules:scala.bzl", "scala_binary")

scala_binary(
name = "deps",
srcs = ["//deps/src:deps"],
srcs = [
"//:dependencies",
"//deps/src:deps",
],
args = [
"--project-root=.",
"--scala-version=3.5.2", #TODO
"--scala-version=3.5.2",
"--dependencies=rules_scala3.Dependencies",
],
main_class = "rules_scala3.deps.src.Deps",
scala = "//scala:bootstrap_3",
Expand Down
2 changes: 1 addition & 1 deletion deps/scala_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def scala_deps(
dependencies,
src,
project_root = ".",
scala_version = "3.5.1-RC1",
scala_version = "3.5.2",
targets_dir_name = "jvm",
targets_file_name = "BUILD"):
destination = native.package_name() + "/3rdparty"
Expand Down
1 change: 1 addition & 0 deletions deps/src/Resolve.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ object Resolve:
module_deps = modules_deps.toMap.getOrElse(moduleReport.module.toCoordinates, Vector.empty).sortBy(_.toString)
)
}
.distinctBy(t => (t.coordinates, t.lang))
.sortBy(_.name)

0 comments on commit 48431d6

Please sign in to comment.