Add the ability to use custom mapping files.
parent
2eaae5be44
commit
673f21c506
|
@ -34,6 +34,7 @@ public class LoomGradleExtension {
|
||||||
public String fabricVersion;
|
public String fabricVersion;
|
||||||
public String pomfVersion;
|
public String pomfVersion;
|
||||||
public String refmapName;
|
public String refmapName;
|
||||||
|
public boolean localMappings = false;
|
||||||
|
|
||||||
//Not to be set in the build.gradle
|
//Not to be set in the build.gradle
|
||||||
public Project project;
|
public Project project;
|
||||||
|
@ -58,6 +59,9 @@ public class LoomGradleExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPomf(){
|
public boolean hasPomf(){
|
||||||
|
if(localMappings){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return pomfVersion != null && !pomfVersion.isEmpty();
|
return pomfVersion != null && !pomfVersion.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,27 @@ public class DownloadTask extends DefaultTask {
|
||||||
this.getLogger().lifecycle(":downloading mappings");
|
this.getLogger().lifecycle(":downloading mappings");
|
||||||
FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/pomf/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"), Constants.MAPPINGS_ZIP.get(extension));
|
FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/pomf/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"), Constants.MAPPINGS_ZIP.get(extension));
|
||||||
}
|
}
|
||||||
|
if(!extension.hasPomf()){
|
||||||
|
if(Constants.MAPPINGS_DIR_LOCAL.get(extension).exists()){
|
||||||
|
if(Constants.MAPPINGS_TINY_GZ_LOCAL.get(extension).exists() && Constants.MAPPINGS_ZIP_LOCAL.get(extension).exists()){
|
||||||
|
this.getLogger().lifecycle("Found local mapping files");
|
||||||
|
extension.localMappings = true;
|
||||||
|
extension.pomfVersion = "local"; //TODO set this to include the hash or something to so the jar name is unique?
|
||||||
|
|
||||||
|
//We delete this to make sure they are always re extracted.
|
||||||
|
deleteIfExists(Constants.MAPPINGS_ZIP.get(extension));
|
||||||
|
deleteIfExists(Constants.MAPPINGS_TINY_GZ.get(extension));
|
||||||
|
deleteIfExists(Constants.MAPPINGS_TINY.get(extension));
|
||||||
|
deleteIfExists(Constants.MAPPINGS_DIR.get(extension));
|
||||||
|
|
||||||
|
Constants.MAPPINGS_TINY_GZ = Constants.MAPPINGS_TINY_GZ_LOCAL;
|
||||||
|
Constants.MAPPINGS_ZIP = Constants.MAPPINGS_ZIP_LOCAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!Constants.MAPPINGS_TINY.get(extension).exists() && extension.hasPomf()) {
|
if (!Constants.MAPPINGS_TINY.get(extension).exists() && extension.hasPomf()) {
|
||||||
if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists()) {
|
if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists() && !extension.localMappings) {
|
||||||
getLogger().lifecycle(":downloading tiny mappings");
|
getLogger().lifecycle(":downloading tiny mappings");
|
||||||
FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/pomf/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension));
|
FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/pomf/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension));
|
||||||
}
|
}
|
||||||
|
@ -172,4 +190,19 @@ public class DownloadTask extends DefaultTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean deleteIfExists(File file){
|
||||||
|
if(file.exists()){
|
||||||
|
if(file.isDirectory()){
|
||||||
|
try {
|
||||||
|
FileUtils.deleteDirectory(file);
|
||||||
|
return file.mkdir();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return file.delete();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,16 @@ public class Constants {
|
||||||
public static final IDelayed<File> MINECRAFT_FINAL_JAR = new DelayedFile(extension -> new File(CACHE_FILES, extension.getVersionString() + "-mixed-" + extension.pomfVersion + ".jar"));
|
public static final IDelayed<File> MINECRAFT_FINAL_JAR = new DelayedFile(extension -> new File(CACHE_FILES, extension.getVersionString() + "-mixed-" + extension.pomfVersion + ".jar"));
|
||||||
|
|
||||||
public static final IDelayed<File> POMF_DIR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "pomf"));
|
public static final IDelayed<File> POMF_DIR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "pomf"));
|
||||||
public static final IDelayed<File> MAPPINGS_ZIP = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"));
|
public static IDelayed<File> MAPPINGS_ZIP = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"));
|
||||||
public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ""));
|
public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ""));
|
||||||
public static final IDelayed<File> MAPPINGS_TINY_GZ = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"));
|
public static IDelayed<File> MAPPINGS_TINY_GZ = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"));
|
||||||
public static final IDelayed<File> MAPPINGS_TINY = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion));
|
public static final IDelayed<File> MAPPINGS_TINY = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion));
|
||||||
public static final IDelayed<File> MAPPINGS_MIXIN_EXPORT = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-map-" + extension.version + "." + extension.pomfVersion + ".mappings"));
|
public static final IDelayed<File> MAPPINGS_MIXIN_EXPORT = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-map-" + extension.version + "." + extension.pomfVersion + ".mappings"));
|
||||||
|
|
||||||
|
public static final IDelayed<File> MAPPINGS_DIR_LOCAL = new DelayedFile(extension -> new File(WORKING_DIRECTORY, "mappings"));
|
||||||
|
public static final IDelayed<File> MAPPINGS_ZIP_LOCAL = new DelayedFile(extension -> new File(MAPPINGS_DIR_LOCAL.get(extension), "pomf-enigma-" + extension.version + ".zip"));
|
||||||
|
public static final IDelayed<File> MAPPINGS_TINY_GZ_LOCAL = new DelayedFile(extension -> new File(MAPPINGS_DIR_LOCAL.get(extension), "pomf-tiny-" + extension.version + ".gz"));
|
||||||
|
|
||||||
public static final IDelayed<File> REF_MAP = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-refmap.json"));
|
public static final IDelayed<File> REF_MAP = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-refmap.json"));
|
||||||
|
|
||||||
public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-libs"));
|
public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-libs"));
|
||||||
|
|
Loading…
Reference in New Issue