From 48431d619dbe0d52c9990aca0f78ce4dfa3e765f Mon Sep 17 00:00:00 2001 From: Anna Skrodzka <56291558+anna-skrodzka@users.noreply.github.com> Date: Sat, 2 Nov 2024 05:06:48 +0100 Subject: [PATCH 1/2] Fix bugs with deps generator (#52) * Dependencies.scala file added * BUILD file for deps modified * dependencies duplication fixed * dependencies duplication fixed --------- Co-authored-by: anna-skrodzka --- 3rdparty/workspace.bzl | 1 - BUILD | 13 +++++++++++++ Dependencies.scala | 31 +++++++++++++++++++++++++++++++ deps/BUILD | 8 ++++++-- deps/scala_deps.bzl | 2 +- deps/src/Resolve.scala | 1 + 6 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 Dependencies.scala diff --git a/3rdparty/workspace.bzl b/3rdparty/workspace.bzl index afd0bb38..b88ca2f7 100644 --- a/3rdparty/workspace.bzl +++ b/3rdparty/workspace.bzl @@ -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"}, diff --git a/BUILD b/BUILD index b19e443f..f3ec54f5 100644 --- a/BUILD +++ b/BUILD @@ -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", diff --git a/Dependencies.scala b/Dependencies.scala new file mode 100644 index 00000000..54450131 --- /dev/null +++ b/Dependencies.scala @@ -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" + ) diff --git a/deps/BUILD b/deps/BUILD index 69a3c34b..d3aacda4 100644 --- a/deps/BUILD +++ b/deps/BUILD @@ -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", diff --git a/deps/scala_deps.bzl b/deps/scala_deps.bzl index a9e83354..17ce76f5 100644 --- a/deps/scala_deps.bzl +++ b/deps/scala_deps.bzl @@ -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" diff --git a/deps/src/Resolve.scala b/deps/src/Resolve.scala index 0d2f3274..96eac4e7 100644 --- a/deps/src/Resolve.scala +++ b/deps/src/Resolve.scala @@ -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) From afadd88f2541f27b6c61c964a4c1280c510a50dd Mon Sep 17 00:00:00 2001 From: timothy Date: Mon, 4 Nov 2024 09:37:49 +0700 Subject: [PATCH 2/2] chore: upgrade scala3 to 3.6.1 --- BUILD | 2 +- deps/scala_deps.bzl | 2 +- rules/scala/workspace.bzl | 2 +- scala/BUILD | 2 +- scala3/repositories.bzl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index f3ec54f5..e6953b70 100644 --- a/BUILD +++ b/BUILD @@ -30,6 +30,6 @@ configure_zinc_scala( compiler_bridge = "@scala3_sbt_bridge//jar", compiler_classpath = compiler_classpath_3, runtime_classpath = runtime_classpath_3, - version = "3.5.1-RC1", + version = "3.6.1", visibility = ["//visibility:public"], ) diff --git a/deps/scala_deps.bzl b/deps/scala_deps.bzl index 17ce76f5..69e3bd2b 100644 --- a/deps/scala_deps.bzl +++ b/deps/scala_deps.bzl @@ -5,7 +5,7 @@ def scala_deps( dependencies, src, project_root = ".", - scala_version = "3.5.2", + scala_version = "3.6.1", targets_dir_name = "jvm", targets_file_name = "BUILD"): destination = native.package_name() + "/3rdparty" diff --git a/rules/scala/workspace.bzl b/rules/scala/workspace.bzl index 2130ae3b..374d1177 100644 --- a/rules/scala/workspace.bzl +++ b/rules/scala/workspace.bzl @@ -58,7 +58,7 @@ def scala_repositories(): ) scala2 = "2.13.15" - scala3 = "3.5.2" + scala3 = "3.6.1" scalajs = "1.17.0" direct_deps = [ diff --git a/scala/BUILD b/scala/BUILD index 9da4597e..fedc2308 100644 --- a/scala/BUILD +++ b/scala/BUILD @@ -80,7 +80,7 @@ alias( visibility = ["//visibility:public"], ) -scala3 = "3.5.1-RC1" +scala3 = "3.6.1" scala3_global_scalacopts = [ "-deprecation", diff --git a/scala3/repositories.bzl b/scala3/repositories.bzl index 4035e449..d0a2504a 100644 --- a/scala3/repositories.bzl +++ b/scala3/repositories.bzl @@ -103,7 +103,7 @@ def _scala3_toolchain_repository_impl(repository_ctx): # TODO load maven deps, like `rules_scala_toolchain_deps_repositories` does. # `repository_ctx.attr.scala_version` should be used to resolve deps and # determine the full version - scala_version = "3.5.1-RC1" + scala_version = "3.6.1" compiler_bridge = repository_ctx.attr.compiler_bridge or "@scala3_sbt_bridge//jar" compiler_classpath = repository_ctx.attr.compiler_classpath or [