-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download fabric and wilderforge dependencies from the internet, as th…
…ey're no longer being shadowed.
- Loading branch information
1 parent
30ea955
commit a2fbca8
Showing
5 changed files
with
208 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.wildermods.workspace; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.MissingResourceException; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.io.IOUtils; | ||
|
||
public class LocalResource implements Resource { | ||
|
||
private final InputStream inputstream; | ||
private final String resourceLocation; | ||
private final String destPath; | ||
private final boolean useBinDir; | ||
|
||
public LocalResource(String path, boolean useBinDir) { | ||
this(path, path, useBinDir); | ||
} | ||
|
||
public LocalResource(String resourceLocation, String destPath, boolean useBinDir) { | ||
this.resourceLocation = resourceLocation; | ||
this.destPath = destPath; | ||
this.useBinDir = useBinDir; | ||
InputStream stream = LocalResource.class.getResourceAsStream(resourceLocation); | ||
if(stream == null) { //If we're being executed from a dir not a jar | ||
stream = LocalResource.class.getResourceAsStream("/" + resourceLocation); | ||
} | ||
this.inputstream = stream; | ||
if(inputstream == null) { | ||
throw new MissingResourceException("Could not find resource " + resourceLocation, LocalResource.class.getName(), resourceLocation); | ||
} | ||
} | ||
|
||
/* | ||
* Note that a resource can only be written once. | ||
*/ | ||
@SuppressWarnings("deprecation") | ||
public void write(File destDir, boolean binEnabled) throws IOException { | ||
File dest = new File(destDir.getAbsolutePath() + "/" + destPath); | ||
if(!dest.exists()) { | ||
System.out.println("writing " + dest); | ||
FileUtils.writeByteArrayToFile(dest, IOUtils.toByteArray(inputstream), false); | ||
} | ||
else { | ||
System.out.println("Resource already exists: " + dest); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/wildermods/workspace/RemoteResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.wildermods.workspace; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
public class RemoteResource implements Resource { | ||
|
||
public final String name; | ||
private final URL url; | ||
private final String destPath; | ||
private final boolean useBinDir; | ||
|
||
public RemoteResource(JsonElement resourceDefinition) throws IOException { | ||
JsonObject resourceJson = resourceDefinition.getAsJsonObject(); | ||
JsonElement nameEle = resourceJson.get("name"); | ||
JsonElement urlEle = resourceJson.get("url"); | ||
JsonElement destEle = resourceJson.get("dest"); | ||
JsonElement binEle = resourceJson.get("bin"); | ||
|
||
this.name = nameEle.getAsString(); | ||
this.url = new URL(urlEle.getAsString()); | ||
this.destPath = destEle.getAsString(); | ||
this.useBinDir = destEle.getAsBoolean(); | ||
} | ||
|
||
@Override | ||
public void write(File destDir, boolean binEnabled) throws IOException { | ||
File dest = new File(destDir, (binEnabled ? "/bin" : "") + destPath); | ||
if(!dest.exists()) { | ||
System.out.println("Downloading " + name + ":\nFrom: " + url + "\nInto: " + dest); | ||
FileUtils.copyInputStreamToFile(url.openStream(), dest); | ||
} | ||
else { | ||
System.out.println("Resource already exists: " + dest); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"dependencies": [ | ||
{ | ||
"name": "Fabric Loader", | ||
"url": "https://maven.fabricmc.net/net/fabricmc/fabric-loader/0.12.12/fabric-loader-0.12.12.jar", | ||
"dest": "/fabric-loader-0.12.12.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"Wildermyth Game Provider", | ||
"url": "https://dl.wildermods.com/?user=gamebuster19901&?project=wildermythgameprovider&?version=0.1.0.0&?artifact=provider-0.1.0.0-all.jar", | ||
"dest": "/fabric/provider-0.1.0.0-all.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"Tiny Mappings Parser", | ||
"url": "https://maven.fabricmc.net/net/fabricmc/tiny-mappings-parser/0.3.0%2Bbuild.17/tiny-mappings-parser-0.3.0%2Bbuild.17.jar", | ||
"dest": "/fabric/tiny-mappings-parser-0.3.0+build.17.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"Tiny Remapper", | ||
"url" : "https://maven.fabricmc.net/net/fabricmc/tiny-remapper/0.6.0/tiny-remapper-0.6.0.jar", | ||
"dest": "/fabric/tiny-remapper-0.6.0.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"Access Widener", | ||
"url" : "https://maven.fabricmc.net/net/fabricmc/access-widener/2.1.0/access-widener-2.1.0.jar", | ||
"dest": "/fabric/access-widener-2.1.0.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"ASM", | ||
"url": "https://repo.maven.apache.org/maven2/org/ow2/asm/asm/9.2/asm-9.2.jar", | ||
"dest": "/fabric/asm-9.2.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"ASM Analysis", | ||
"url": "https://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/9.2/asm-analysis-9.2.jar", | ||
"dest": "/fabric/asm-analysis-9.2.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"ASM Commons", | ||
"url": "https://repo.maven.apache.org/maven2/org/ow2/asm/asm-commons/9.2/asm-commons-9.2.jar", | ||
"dest": "/fabric/asm-commons-9.2.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"ASM Tree", | ||
"url": "https://repo.maven.apache.org/maven2/org/ow2/asm/asm-tree/9.2/asm-tree-9.2.jar", | ||
"dest": "/fabric/asm-tree-9.2.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"ASM Util", | ||
"url": "https://repo.maven.apache.org/maven2/org/ow2/asm/asm-util/9.2/asm-util-9.2.jar", | ||
"dest": "/fabric/asm-util-9.2.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"Spongepowered Mixin", | ||
"url":"https://repo.spongepowered.org/repository/maven-public/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar", | ||
"dest": "/fabric/mixin-0.8.5.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"Guava", | ||
"url": "https://repo.maven.apache.org/maven2/com/google/guava/guava/21.0/guava-21.0.jar", | ||
"dest": "/fabric/guava-21.0.jar", | ||
"bin":true | ||
}, | ||
{ | ||
"name":"Gson", | ||
"url": "https://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.8.7/gson-2.8.7.jar", | ||
"dest": "/fabric/gson-2.8.7.jar", | ||
"bin": true | ||
} | ||
] | ||
} |