Skip to content

Commit 91d7b68

Browse files
committed
re-enable natives extraction
1 parent 9e45e19 commit 91d7b68

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

plugin/src/main/java/io/github/cichlidmc/cichlid_gradle/cache/NativesStorage.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
import java.nio.file.Files;
77
import java.nio.file.Path;
88
import java.util.Iterator;
9+
import java.util.Optional;
910
import java.util.stream.Stream;
1011

1112
import io.github.cichlidmc.cichlid_gradle.util.FileUtils;
1213
import io.github.cichlidmc.pistonmetaparser.FullVersion;
13-
import io.github.cichlidmc.pistonmetaparser.version.library.Artifact;
14+
import io.github.cichlidmc.pistonmetaparser.version.library.Classifier;
1415
import io.github.cichlidmc.pistonmetaparser.version.library.Library;
16+
import io.github.cichlidmc.pistonmetaparser.version.library.Natives;
1517
import org.gradle.api.logging.Logger;
1618
import org.gradle.api.logging.Logging;
1719

@@ -30,24 +32,26 @@ void extractNatives(FullVersion version) throws IOException {
3032
Path dir = this.root.resolve(version.id);
3133

3234
for (Library library : version.libraries) {
33-
34-
// library.natives.flatMap(Natives::choose).ifPresent(artifact -> {
35-
// logger.quiet("Extracting natives for library {}", library.name);
36-
// this.downloadAndExtract(artifact, dir);
37-
// });
35+
Optional<Classifier> maybeClassifier = library.natives.flatMap(Natives::choose);
36+
if (maybeClassifier.isPresent()) {
37+
Classifier classifier = maybeClassifier.get();
38+
logger.quiet("Extracting natives for library {}: classifier {}", library.name, classifier.name);
39+
this.downloadAndExtract(classifier, dir);
40+
}
3841
}
3942
}
4043

41-
private void downloadAndExtract(Artifact artifact, Path dir) throws IOException {
44+
private void downloadAndExtract(Classifier classifier, Path dir) throws IOException {
4245
Path tempJar = dir.resolve(TEMP_JAR);
43-
FileUtils.downloadSilently(artifact, tempJar);
46+
FileUtils.downloadSilently(classifier.artifact, tempJar);
4447

4548
try (FileSystem fs = FileSystems.newFileSystem(tempJar)) {
4649
// jar should have 1 root
4750
Path root = fs.getRootDirectories().iterator().next();
4851
try (Stream<Path> stream = Files.list(root)) {
4952
// the version manifest specifies files that should be excluded from extraction,
50-
// but it's undocumented and a pain to handle, and it doesn't even matter in the end.
53+
// but it's undocumented and a pain to handle, and it doesn't even matter in the end
54+
// as far as I know.
5155
for (Iterator<Path> itr = stream.iterator(); itr.hasNext();) {
5256
Path file = itr.next();
5357
Path dest = dir.resolve(file.getFileName().toString());

0 commit comments

Comments
 (0)