Skip to content

Commit f3ddff7

Browse files
committed
Revert "allow usage of scalafix-interfaces without scalafix-properties"
This reverts commit 677129f.
1 parent 29c1f36 commit f3ddff7

File tree

3 files changed

+4
-58
lines changed

3 files changed

+4
-58
lines changed

build.sbt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,7 @@ lazy val integration = projectMatrix
380380
.collect { case p @ LocalProject(n) if n.startsWith("cli3") => p }
381381
.map(_ / publishLocalTransitive)): _*
382382
)
383-
.value,
384-
// Mimic sbt-scalafix usage of interfaces (without properties per default)
385-
// to exercise dynamic loading of latest scalafix-properties artifact
386-
Test / internalDependencyClasspath := {
387-
val prev = (Test / internalDependencyClasspath).value
388-
val propertiesClassDirectory =
389-
(properties / Compile / classDirectory).value
390-
prev.filter(_.data != propertiesClassDirectory)
391-
}
383+
.value
392384
)
393385
.defaultAxes(VirtualAxis.jvm)
394386
.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
@@ -163,26 +163,11 @@ static Scalafix fetchAndClassloadInstance(String requestedScalaVersion, List<Rep
163163

164164
Properties properties = new Properties();
165165
String propertiesPath = "scalafix-interfaces.properties";
166+
InputStream stream = Scalafix.class.getClassLoader().getResourceAsStream(propertiesPath);
166167
try {
167-
InputStream stream = Scalafix.class.getClassLoader().getResourceAsStream(propertiesPath);
168168
properties.load(stream);
169-
} catch (Exception e) {
170-
System.err.println(
171-
"Failed to load '" + propertiesPath + "' from local artifact, " +
172-
"falling back to fetching the latest scalafix version...");
173-
174-
try {
175-
List<URL> jars = ScalafixCoursier.latestScalafixPropertiesJars(repositories);
176-
URLClassLoader classLoader =
177-
new URLClassLoader(jars.stream().toArray(URL[]::new), null);
178-
179-
InputStream stream = classLoader.getResourceAsStream(propertiesPath);
180-
properties.load(stream);
181-
} catch (Exception ee) {
182-
throw new ScalafixException(
183-
"Failed to load '" + propertiesPath + "' from local & remote artifacts",
184-
ee);
185-
}
169+
} catch (IOException | NullPointerException e) {
170+
throw new ScalafixException("Failed to load '" + propertiesPath + "' to lookup versions", e);
186171
}
187172

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

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

Lines changed: 0 additions & 31 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,22 +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 version = versions(repositories, module)
67-
.getAvailable()
68-
.stream()
69-
// Ignore RC & SNAPSHOT versions
70-
.filter(v -> !v.contains("-"))
71-
.reduce((older, newer) -> newer)
72-
.orElseThrow(() -> new ScalafixException("Could not find any stable version for " + module));
73-
74-
Dependency scalafixProperties = Dependency.of(module, version);
75-
return toURLs(fetch(repositories, Collections.singletonList(scalafixProperties), ResolutionParams.create()));
76-
}
77-
7847
public static List<URL> scalafixCliJars(
7948
List<Repository> repositories,
8049
String scalafixVersion,

0 commit comments

Comments
 (0)