From fe8a5fdff00678a5a2d699d2d26802daae8e4f65 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sun, 27 Apr 2025 14:54:09 +0200 Subject: [PATCH 1/4] Revert "make test resilient to scala upgrades beyond 0.14.3" This reverts commit 5d07bce55c14e2348216526b527cc8ca37a84026. --- build.sbt | 9 ++------- .../scalafix/internal/interfaces/ScalafixCoursier.java | 5 ++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/build.sbt b/build.sbt index a1455f2b1..a60e92aca 100644 --- a/build.sbt +++ b/build.sbt @@ -382,18 +382,13 @@ lazy val integration = projectMatrix ) .value, // Mimic sbt-scalafix usage of interfaces (without properties per default) - // to exercise dynamic loading of scalafix-properties artifact + // to exercise dynamic loading of latest scalafix-properties artifact Test / internalDependencyClasspath := { val prev = (Test / internalDependencyClasspath).value val propertiesClassDirectory = (properties / Compile / classDirectory).value prev.filter(_.data != propertiesClassDirectory) - }, - // Since tests may depend on new values, we use a system property to ScalafixCoursier - // to whitelist a specific SNAPSHOT version from the list of available ones - Test / javaOptions += s"-Dscalafix-properties.version=${version.value}", - Test / fork := true, - Test / baseDirectory := (ThisBuild / baseDirectory).value + } ) .defaultAxes(VirtualAxis.jvm) .jvmPlatform(CrossVersion.full, cliScalaVersions) diff --git a/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java b/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java index ba9091c4d..391048b12 100644 --- a/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java +++ b/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java @@ -63,12 +63,11 @@ public static List latestScalafixPropertiesJars( List repositories ) throws ScalafixException { Module module = Module.of("ch.epfl.scala", "scalafix-properties"); - String allowedVersion = System.getProperty("scalafix-properties.version"); String version = versions(repositories, module) .getAvailable() .stream() - // Ignore RC & SNAPSHOT versions, except if explicitly requested - .filter(v -> !v.contains("-") || v.equals(allowedVersion)) + // Ignore RC & SNAPSHOT versions + .filter(v -> v.startsWith("0.14.2+") || !v.contains("-")) .reduce((older, newer) -> newer) .orElseThrow(() -> new ScalafixException("Could not find any stable version for " + module)); From 29c1f36901bdd8bdd534ff607544512d825389d9 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sun, 27 Apr 2025 14:55:39 +0200 Subject: [PATCH 2/4] Revert "allow fetching properties from SNAPSHOTs until a stable release is cut" This reverts commit b3a2d97e7806b08c7c473f16a9f69c4f511d6758. --- .../java/scalafix/internal/interfaces/ScalafixCoursier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java b/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java index 391048b12..5d104236e 100644 --- a/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java +++ b/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java @@ -67,7 +67,7 @@ public static List latestScalafixPropertiesJars( .getAvailable() .stream() // Ignore RC & SNAPSHOT versions - .filter(v -> v.startsWith("0.14.2+") || !v.contains("-")) + .filter(v -> !v.contains("-")) .reduce((older, newer) -> newer) .orElseThrow(() -> new ScalafixException("Could not find any stable version for " + module)); From f3ddff79b3e11d2a0b7dfd2f1a5f18c8f0eb963f Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sun, 27 Apr 2025 14:55:42 +0200 Subject: [PATCH 3/4] Revert "allow usage of scalafix-interfaces without scalafix-properties" This reverts commit 677129f27dfd5e3577dd92dca044affcb032afc8. --- build.sbt | 10 +----- .../java/scalafix/interfaces/Scalafix.java | 21 ++----------- .../internal/interfaces/ScalafixCoursier.java | 31 ------------------- 3 files changed, 4 insertions(+), 58 deletions(-) diff --git a/build.sbt b/build.sbt index a60e92aca..f048136b1 100644 --- a/build.sbt +++ b/build.sbt @@ -380,15 +380,7 @@ lazy val integration = projectMatrix .collect { case p @ LocalProject(n) if n.startsWith("cli3") => p } .map(_ / publishLocalTransitive)): _* ) - .value, - // Mimic sbt-scalafix usage of interfaces (without properties per default) - // to exercise dynamic loading of latest scalafix-properties artifact - Test / internalDependencyClasspath := { - val prev = (Test / internalDependencyClasspath).value - val propertiesClassDirectory = - (properties / Compile / classDirectory).value - prev.filter(_.data != propertiesClassDirectory) - } + .value ) .defaultAxes(VirtualAxis.jvm) .jvmPlatform(CrossVersion.full, cliScalaVersions) diff --git a/scalafix-interfaces/src/main/java/scalafix/interfaces/Scalafix.java b/scalafix-interfaces/src/main/java/scalafix/interfaces/Scalafix.java index b22183855..6e915d949 100644 --- a/scalafix-interfaces/src/main/java/scalafix/interfaces/Scalafix.java +++ b/scalafix-interfaces/src/main/java/scalafix/interfaces/Scalafix.java @@ -163,26 +163,11 @@ static Scalafix fetchAndClassloadInstance(String requestedScalaVersion, List jars = ScalafixCoursier.latestScalafixPropertiesJars(repositories); - URLClassLoader classLoader = - new URLClassLoader(jars.stream().toArray(URL[]::new), null); - - InputStream stream = classLoader.getResourceAsStream(propertiesPath); - properties.load(stream); - } catch (Exception ee) { - throw new ScalafixException( - "Failed to load '" + propertiesPath + "' from local & remote artifacts", - ee); - } + } catch (IOException | NullPointerException e) { + throw new ScalafixException("Failed to load '" + propertiesPath + "' to lookup versions", e); } String scalafixVersion = properties.getProperty("scalafixVersion"); diff --git a/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java b/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java index 5d104236e..f0ed2f663 100644 --- a/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java +++ b/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java @@ -15,21 +15,6 @@ public class ScalafixCoursier { - private static VersionListing versions( - List repositories, - coursierapi.Module module - ) throws ScalafixException { - try { - return Versions.create() - .withModule(module) - .withRepositories(repositories.stream().toArray(Repository[]::new)) - .versions() - .getMergedListings(); - } catch (CoursierError e) { - throw new ScalafixException("Failed to list versions for " + module + " from " + repositories, e); - } - } - private static FetchResult fetch( List repositories, List dependencies, @@ -59,22 +44,6 @@ private static List toURLs(FetchResult result) throws ScalafixException { return urls; } - public static List latestScalafixPropertiesJars( - List repositories - ) throws ScalafixException { - Module module = Module.of("ch.epfl.scala", "scalafix-properties"); - String version = versions(repositories, module) - .getAvailable() - .stream() - // Ignore RC & SNAPSHOT versions - .filter(v -> !v.contains("-")) - .reduce((older, newer) -> newer) - .orElseThrow(() -> new ScalafixException("Could not find any stable version for " + module)); - - Dependency scalafixProperties = Dependency.of(module, version); - return toURLs(fetch(repositories, Collections.singletonList(scalafixProperties), ResolutionParams.create())); - } - public static List scalafixCliJars( List repositories, String scalafixVersion, From 0736e12b34a92338d7442919635dc22e2a989416 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sun, 27 Apr 2025 14:55:45 +0200 Subject: [PATCH 4/4] Revert "spin off properties to a separate artifact" This reverts commit 9b9c1036f9366e45f4707c73cd10fc38a6f0b2e0. --- build.sbt | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/build.sbt b/build.sbt index f048136b1..8932c294b 100644 --- a/build.sbt +++ b/build.sbt @@ -22,8 +22,8 @@ def inferJavaHome() = { Some(actualHome) } -lazy val properties = project - .in(file("scalafix-properties")) +lazy val interfaces = project + .in(file("scalafix-interfaces")) .settings( Compile / resourceGenerators += Def.task { val props = new java.util.Properties() @@ -43,16 +43,6 @@ lazy val properties = project IO.write(props, "Scalafix version constants", out) List(out) }, - moduleName := "scalafix-properties", - mimaPreviousArtifacts := Set.empty, - crossPaths := false, - autoScalaLibrary := false - ) - .disablePlugins(ScalafixPlugin) - -lazy val interfaces = project - .in(file("scalafix-interfaces")) - .settings( (Compile / javacOptions) ++= List( "-Xlint:all", "-Werror" @@ -66,7 +56,6 @@ lazy val interfaces = project autoScalaLibrary := false ) .disablePlugins(ScalafixPlugin) - .dependsOn(properties) // Scala 3 macros vendored separately (i.e. without runtime classes), to // shadow Scala 2.13 macros in the Scala 3 compiler classpath, while producing