Skip to content

Commit 1452afc

Browse files
committed
support qualifiers outside of dev
1 parent 5199ca4 commit 1452afc

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/main/java/com/falsepattern/lib/FalsePatternLib.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ public static void addMavenRepo(String url) {
5252
}
5353

5454
@SuppressWarnings("ResultOfMethodCallIgnored")
55-
public static void loadLibrary(String loadingModId, String groupId, String artifactId, @NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion, String devSuffix) {
56-
libLog.info("Adding library {}:{}:{}, requested by mod {}", groupId, artifactId, preferredVersion, loadingModId);
57-
var artifact = groupId + ":" + artifactId;
55+
public static void loadLibrary(String loadingModId, String groupId, String artifactId, @NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion, String regularSuffix, String devSuffix) {
56+
val suffix = developerEnvironment ? devSuffix : regularSuffix;
57+
libLog.info("Adding library {}:{}:{}{}, requested by mod {}", groupId, artifactId, preferredVersion, suffix != null ? "-" + suffix : "", loadingModId);
58+
var artifact = groupId + ":" + artifactId + ":" + suffix;
5859
if (loadedLibraries.containsKey(artifact)) {
5960
val currentVer = loadedLibraries.get(artifact);
6061
if (currentVer.equals(preferredVersion)) return;
@@ -63,27 +64,27 @@ public static void loadLibrary(String loadingModId, String groupId, String artif
6364
for (int i = 0; i < 16; i++) {
6465
libLog.fatal("ALERT VVVVVVVVVVVV ALERT");
6566
}
66-
libLog.fatal("Library {}:{} already loaded with version {}, " +
67+
libLog.fatal("Library {}:{}{} already loaded with version {}, " +
6768
"but a version in the range {} was requested! Thing may go horribly wrong! " +
6869
"Requested by mod: {}, previously loaded by mod: {}",
69-
groupId, artifactId, currentVer,
70+
groupId, artifactId, suffix != null ? ":" + suffix : "", currentVer,
7071
rangeString,
7172
loadingModId, loadedLibraryMods.get(artifact));
7273
for (int i = 0; i < 16; i++) {
7374
libLog.fatal("ALERT ^^^^^^^^^^^^ ALERT");
7475
}
7576
} else {
76-
libLog.info("Attempted loading of library {}:{} with preferred version {}, " +
77+
libLog.info("Attempted loading of library {}:{}{} with preferred version {}, " +
7778
"but version {} was already loaded, which matched the range {}. This is not an error. " +
7879
"Requested by mod: {}, previously loaded by mod: {}",
79-
groupId, artifactId, preferredVersion,
80+
groupId, artifactId, suffix != null ? ":" + suffix : "", preferredVersion,
8081
currentVer, rangeString,
8182
loadingModId, loadedLibraryMods.get(artifact));
8283
}
8384
return;
8485
}
8586
val modsDir = new File(CoreLoadingPlugin.mcDir, "mods");
86-
val mavenJarName = String.format("%s-%s%s.jar", artifactId, preferredVersion, (developerEnvironment && devSuffix != null) ? ("-" + devSuffix) : "");
87+
val mavenJarName = String.format("%s-%s%s.jar", artifactId, preferredVersion, (suffix != null) ? ("-" + suffix) : "");
8788
val jarName = groupId + "-" + mavenJarName;
8889
val libDir = new File(modsDir, "falsepattern");
8990
if (!libDir.exists()) {
@@ -94,10 +95,10 @@ public static void loadLibrary(String loadingModId, String groupId, String artif
9495
try {
9596
addToClasspath(file);
9697
loadedLibraries.put(artifact, preferredVersion);
97-
libLog.info("Library {}:{}:{} successfully loaded from disk!", groupId, artifactId, preferredVersion);
98+
libLog.info("Library {}:{}:{}{} successfully loaded from disk!", groupId, artifactId, preferredVersion, (suffix != null) ? ":" + suffix : "");
9899
return;
99100
} catch (RuntimeException e) {
100-
libLog.warn("Failed to load library {}:{}:{} from file! Redownloading...", groupId, artifactId, preferredVersion);
101+
libLog.warn("Failed to load library {}:{}:{}{} from file! Redownloading...", groupId, artifactId, preferredVersion, (suffix != null) ? ":" + suffix : "");
101102
file.delete();
102103
}
103104
}
@@ -111,20 +112,20 @@ public static void loadLibrary(String loadingModId, String groupId, String artif
111112
connection.setReadTimeout(1500);
112113
connection.setRequestProperty("User-Agent", "FalsePatternLib Downloader");
113114
if (connection.getResponseCode() != 200) {
114-
libLog.info("Artifact {}:{}:{} was not found on repo {}", groupId, artifactId, preferredVersion, repo);
115+
libLog.info("Artifact {}:{}:{}{} was not found on repo {}", groupId, artifactId, preferredVersion, (suffix != null) ? ":" + suffix : "", repo);
115116
connection.disconnect();
116117
continue;
117118
}
118-
libLog.info("Downloading {}:{}:{} from {}", groupId, artifactId, preferredVersion, repo);
119+
libLog.info("Downloading {}:{}:{}{} from {}", groupId, artifactId, preferredVersion, (suffix != null) ? ":" + suffix : "", repo);
119120
download(connection.getInputStream(), file);
120-
libLog.info("Downloaded {}:{}:{}", groupId, artifactId, preferredVersion);
121+
libLog.info("Downloaded {}:{}:{}{}", groupId, artifactId, preferredVersion, (suffix != null) ? ":" + suffix : "");
121122
loadedLibraries.put(artifact, preferredVersion);
122123
loadedLibraryMods.put(artifact, loadingModId);
123124
addToClasspath(file);
124125
return;
125126
} catch (IOException ignored) {}
126127
}
127-
val errorMessage = "Failed to download library " + groupId + ":" + artifactId + ":" + preferredVersion + " from any repository! Requested by mod: " + loadingModId;
128+
val errorMessage = "Failed to download library " + groupId + ":" + artifactId + ":" + preferredVersion + ((suffix != null) ? ":" + suffix : "") + " from any repository! Requested by mod: " + loadingModId;
128129
libLog.fatal(errorMessage);
129130
throw new IllegalStateException(errorMessage);
130131
}

src/main/java/com/falsepattern/lib/api/DependencyLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
public class DependencyLoader {
88
@Builder
9-
public static void loadLibrary(String loadingModId, String groupId, String artifactId, @NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion, String devSuffix) {
10-
FalsePatternLib.loadLibrary(loadingModId, groupId, artifactId, minVersion, maxVersion, preferredVersion, devSuffix);
9+
public static void loadLibrary(String loadingModId, String groupId, String artifactId, @NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion, String regularSuffix, String devSuffix) {
10+
FalsePatternLib.loadLibrary(loadingModId, groupId, artifactId, minVersion, maxVersion, preferredVersion, regularSuffix, devSuffix);
1111
}
1212

1313
public static void addMavenRepo(String url) {

0 commit comments

Comments
 (0)