66import java .nio .file .Files ;
77import java .nio .file .Path ;
88import java .util .Iterator ;
9+ import java .util .Optional ;
910import java .util .stream .Stream ;
1011
1112import io .github .cichlidmc .cichlid_gradle .util .FileUtils ;
1213import io .github .cichlidmc .pistonmetaparser .FullVersion ;
13- import io .github .cichlidmc .pistonmetaparser .version .library .Artifact ;
14+ import io .github .cichlidmc .pistonmetaparser .version .library .Classifier ;
1415import io .github .cichlidmc .pistonmetaparser .version .library .Library ;
16+ import io .github .cichlidmc .pistonmetaparser .version .library .Natives ;
1517import org .gradle .api .logging .Logger ;
1618import 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