Skip to content

Commit 61f9800

Browse files
authored
Merge pull request #2240 from bjaglin/revert-scalafix-properties
Revert scalafix-properties PRs
2 parents 48e91e3 + 0736e12 commit 61f9800

File tree

3 files changed

+6
-77
lines changed

3 files changed

+6
-77
lines changed

build.sbt

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def inferJavaHome() = {
2222
Some(actualHome)
2323
}
2424

25-
lazy val properties = project
26-
.in(file("scalafix-properties"))
25+
lazy val interfaces = project
26+
.in(file("scalafix-interfaces"))
2727
.settings(
2828
Compile / resourceGenerators += Def.task {
2929
val props = new java.util.Properties()
@@ -44,16 +44,6 @@ lazy val properties = project
4444
IO.write(props, "Scalafix version constants", out)
4545
List(out)
4646
},
47-
moduleName := "scalafix-properties",
48-
mimaPreviousArtifacts := Set.empty,
49-
crossPaths := false,
50-
autoScalaLibrary := false
51-
)
52-
.disablePlugins(ScalafixPlugin)
53-
54-
lazy val interfaces = project
55-
.in(file("scalafix-interfaces"))
56-
.settings(
5747
(Compile / javacOptions) ++= List(
5848
"-Xlint:all",
5949
"-Werror"
@@ -67,7 +57,6 @@ lazy val interfaces = project
6757
autoScalaLibrary := false
6858
)
6959
.disablePlugins(ScalafixPlugin)
70-
.dependsOn(properties)
7160

7261
// Scala 3 macros vendored separately (i.e. without runtime classes), to
7362
// shadow Scala 2.13 macros in the Scala 3 compiler classpath, while producing
@@ -381,20 +370,7 @@ lazy val integration = projectMatrix
381370
.collect { case p @ LocalProject(n) if n.startsWith("cli3") => p }
382371
.map(_ / publishLocalTransitive)): _*
383372
)
384-
.value,
385-
// Mimic sbt-scalafix usage of interfaces (without properties per default)
386-
// to exercise dynamic loading of scalafix-properties artifact
387-
Test / internalDependencyClasspath := {
388-
val prev = (Test / internalDependencyClasspath).value
389-
val propertiesClassDirectory =
390-
(properties / Compile / classDirectory).value
391-
prev.filter(_.data != propertiesClassDirectory)
392-
},
393-
// Since tests may depend on new values, we use a system property to ScalafixCoursier
394-
// to whitelist a specific SNAPSHOT version from the list of available ones
395-
Test / javaOptions += s"-Dscalafix-properties.version=${version.value}",
396-
Test / fork := true,
397-
Test / baseDirectory := (ThisBuild / baseDirectory).value
373+
.value
398374
)
399375
.defaultAxes(VirtualAxis.jvm)
400376
.jvmPlatform(CrossVersion.full, cliScalaVersions)

scalafix-interfaces/src/main/java/scalafix/interfaces/Scalafix.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,26 +170,11 @@ static Scalafix fetchAndClassloadInstance(String requestedScalaVersion, List<Rep
170170

171171
Properties properties = new Properties();
172172
String propertiesPath = "scalafix-interfaces.properties";
173+
InputStream stream = Scalafix.class.getClassLoader().getResourceAsStream(propertiesPath);
173174
try {
174-
InputStream stream = Scalafix.class.getClassLoader().getResourceAsStream(propertiesPath);
175175
properties.load(stream);
176-
} catch (Exception e) {
177-
System.err.println(
178-
"Failed to load '" + propertiesPath + "' from local artifact, " +
179-
"falling back to fetching the latest scalafix version...");
180-
181-
try {
182-
List<URL> jars = ScalafixCoursier.latestScalafixPropertiesJars(repositories);
183-
URLClassLoader classLoader =
184-
new URLClassLoader(jars.stream().toArray(URL[]::new), null);
185-
186-
InputStream stream = classLoader.getResourceAsStream(propertiesPath);
187-
properties.load(stream);
188-
} catch (Exception ee) {
189-
throw new ScalafixException(
190-
"Failed to load '" + propertiesPath + "' from local & remote artifacts",
191-
ee);
192-
}
176+
} catch (IOException | NullPointerException e) {
177+
throw new ScalafixException("Failed to load '" + propertiesPath + "' to lookup versions", e);
193178
}
194179

195180
String scalafixVersion = properties.getProperty("scalafixVersion");

scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,6 @@
1515

1616
public class ScalafixCoursier {
1717

18-
private static VersionListing versions(
19-
List<Repository> repositories,
20-
coursierapi.Module module
21-
) throws ScalafixException {
22-
try {
23-
return Versions.create()
24-
.withModule(module)
25-
.withRepositories(repositories.stream().toArray(Repository[]::new))
26-
.versions()
27-
.getMergedListings();
28-
} catch (CoursierError e) {
29-
throw new ScalafixException("Failed to list versions for " + module + " from " + repositories, e);
30-
}
31-
}
32-
3318
private static FetchResult fetch(
3419
List<Repository> repositories,
3520
List<Dependency> dependencies,
@@ -59,23 +44,6 @@ private static List<URL> toURLs(FetchResult result) throws ScalafixException {
5944
return urls;
6045
}
6146

62-
public static List<URL> latestScalafixPropertiesJars(
63-
List<Repository> repositories
64-
) throws ScalafixException {
65-
Module module = Module.of("ch.epfl.scala", "scalafix-properties");
66-
String allowedVersion = System.getProperty("scalafix-properties.version");
67-
String version = versions(repositories, module)
68-
.getAvailable()
69-
.stream()
70-
// Ignore RC & SNAPSHOT versions, except if explicitly requested
71-
.filter(v -> !v.contains("-") || v.equals(allowedVersion))
72-
.reduce((older, newer) -> newer)
73-
.orElseThrow(() -> new ScalafixException("Could not find any stable version for " + module));
74-
75-
Dependency scalafixProperties = Dependency.of(module, version);
76-
return toURLs(fetch(repositories, Collections.singletonList(scalafixProperties), ResolutionParams.create()));
77-
}
78-
7947
public static List<URL> scalafixCliJars(
8048
List<Repository> repositories,
8149
String scalafixVersion,

0 commit comments

Comments
 (0)