Include loader's basic version parser, adds support for new yarn version separator

dev/0.11
modmuss50 2019-04-10 17:33:29 +01:00
parent 26c548195e
commit 9eb9978390
2 changed files with 64 additions and 3 deletions

View File

@ -27,6 +27,7 @@ package net.fabricmc.loom.providers;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.DependencyProvider; import net.fabricmc.loom.util.DependencyProvider;
import net.fabricmc.loom.util.Version;
import net.fabricmc.stitch.commands.CommandProposeFieldNames; import net.fabricmc.stitch.commands.CommandProposeFieldNames;
import org.gradle.api.Project; import org.gradle.api.Project;
@ -62,10 +63,10 @@ public class MappingsProvider extends DependencyProvider {
File mappingsJar = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not find dependency " + dependency)); File mappingsJar = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not find dependency " + dependency));
this.mappingsName = dependency.getDependency().getName(); this.mappingsName = dependency.getDependency().getName();
char verSep = version.contains("-") ? '-' : '.';
this.minecraftVersion = version.substring(0, version.lastIndexOf(verSep)); Version mappingsVersion = new Version(version);
this.mappingsVersion = version.substring(version.lastIndexOf(verSep) + 1); this.minecraftVersion = mappingsVersion.getMinecraftVersion();
this.mappingsVersion = mappingsVersion.getMappingsVersion();
initFiles(project); initFiles(project);

View File

@ -0,0 +1,60 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2016, 2017, 2018 FabricMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.fabricmc.loom.util;
public class Version {
private String mappingsVersion;
private String minecraftVersion;
private String version;
public Version(String version) {
this.version = version;
if(version.contains("+build.")){
this.minecraftVersion = version.substring(0, version.lastIndexOf('+'));
this.mappingsVersion = version.substring(version.lastIndexOf('.') + 1);
} else {
//TODO legacy remove when no longer needed
char verSep = version.contains("-") ? '-' : '.';
this.minecraftVersion = version.substring(0, version.lastIndexOf(verSep));
this.mappingsVersion = version.substring(version.lastIndexOf(verSep) + 1);
}
}
public String getMappingsVersion() {
return mappingsVersion;
}
public String getMinecraftVersion() {
return minecraftVersion;
}
@Override
public String toString() {
return version;
}
}