This will require run configs to be regenerated Added cleanLoom, just a task that depends on cleanLoomBinaries and cleanLoomMappingsdev/0.11
parent
5a607963b5
commit
7bcc6b98ff
|
@ -12,7 +12,7 @@ targetCompatibility = 1.8
|
|||
|
||||
group = 'net.fabricmc'
|
||||
archivesBaseName = project.name
|
||||
version = '0.2.5-SNAPSHOT'
|
||||
version = '0.2.6-SNAPSHOT'
|
||||
|
||||
def build = "local"
|
||||
def ENV = System.getenv()
|
||||
|
|
|
@ -145,6 +145,22 @@ public class LoomGradleExtension {
|
|||
return nestedModCache;
|
||||
}
|
||||
|
||||
public File getNativesJarStore(){
|
||||
File natives = new File(getUserCache(), "natives/jars");
|
||||
if(!natives.exists()) {
|
||||
natives.mkdirs();
|
||||
}
|
||||
return natives;
|
||||
}
|
||||
|
||||
public File getNativesDirectory(){
|
||||
File natives = new File(getUserCache(), "natives/" + getMinecraftProvider().minecraftVersion);
|
||||
if(!natives.exists()) {
|
||||
natives.mkdirs();
|
||||
}
|
||||
return natives;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Dependency findDependency(Project p, Collection<Configuration> configs, BiPredicate<String, String> groupNameFilter) {
|
||||
for (Configuration config : configs) {
|
||||
|
|
|
@ -56,10 +56,16 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
|||
super.apply(target);
|
||||
|
||||
TaskContainer tasks = target.getTasks();
|
||||
|
||||
|
||||
|
||||
tasks.register("cleanLoomBinaries", CleanLoomBinaries.class);
|
||||
tasks.register("cleanLoomMappings", CleanLoomMappings.class);
|
||||
|
||||
tasks.register("cleanLoom").configure(task -> {
|
||||
task.dependsOn(tasks.getByName("cleanLoomBinaries"));
|
||||
task.dependsOn(tasks.getByName("cleanLoomMappings"));
|
||||
});
|
||||
|
||||
tasks.register("migrateMappings", MigrateMappingsTask.class, t -> {
|
||||
t.getOutputs().upToDateWhen((o) -> false);
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MinecraftLibraryProvider {
|
|||
initFiles(project, minecraftProvider);
|
||||
|
||||
for (MinecraftVersionInfo.Library library : versionInfo.libraries) {
|
||||
if (library.allowed() && library.getFile(MINECRAFT_LIBS) != null) {
|
||||
if (library.allowed() && !library.isNative() && library.getFile(MINECRAFT_LIBS) != null) {
|
||||
// TODO: Add custom library locations
|
||||
|
||||
// By default, they are all available on all sides
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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.providers;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.util.DownloadUtil;
|
||||
import net.fabricmc.loom.util.MinecraftVersionInfo;
|
||||
import org.gradle.api.Project;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public class MinecraftNativesProvider {
|
||||
|
||||
public static void provide(MinecraftProvider minecraftProvider, Project project) throws IOException {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
MinecraftVersionInfo versionInfo = minecraftProvider.versionInfo;
|
||||
|
||||
File nativesDir = extension.getNativesDirectory();
|
||||
File jarStore = extension.getNativesJarStore();
|
||||
|
||||
for (MinecraftVersionInfo.Library library : versionInfo.libraries) {
|
||||
File libJarFile = library.getFile(jarStore);
|
||||
if (library.allowed() && library.isNative() && libJarFile != null) {
|
||||
DownloadUtil.downloadIfChanged(new URL(library.getURL()), libJarFile, project.getLogger());
|
||||
|
||||
//TODO possibly find a way to prevent needing to re-extract after each run, doesnt seem too slow
|
||||
ZipUtil.unpack(libJarFile, nativesDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -25,9 +25,12 @@
|
|||
package net.fabricmc.loom.task;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class CleanLoomBinaries extends AbstractLoomTask {
|
||||
@TaskAction
|
||||
public void run() {
|
||||
|
@ -36,5 +39,11 @@ public class CleanLoomBinaries extends AbstractLoomTask {
|
|||
extension.getMinecraftProvider().getMergedJar().delete();
|
||||
extension.getMinecraftMappedProvider().getIntermediaryJar().delete();
|
||||
extension.getMinecraftMappedProvider().getMappedJar().delete();
|
||||
try {
|
||||
FileUtils.deleteDirectory(extension.getNativesDirectory());
|
||||
FileUtils.deleteDirectory(extension.getNativesJarStore());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ package net.fabricmc.loom.task;
|
|||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MinecraftAssetsProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftNativesProvider;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
|
@ -38,5 +39,6 @@ public class DownloadAssetsTask extends AbstractLoomTask {
|
|||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
|
||||
MinecraftAssetsProvider.provide(extension.getMinecraftProvider(), project);
|
||||
MinecraftNativesProvider.provide(extension.getMinecraftProvider(), project);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,6 +100,10 @@ public class MinecraftVersionInfo {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isNative(){
|
||||
return getClassifier().contains("natives");
|
||||
}
|
||||
|
||||
public boolean allowed() {
|
||||
if (this.rules == null || this.rules.length <= 0) {
|
||||
return true;
|
||||
|
|
|
@ -90,7 +90,7 @@ public class RunConfig {
|
|||
private static void populate(Project project, LoomGradleExtension extension, RunConfig runConfig, String mode) {
|
||||
runConfig.projectName = project.getName();
|
||||
runConfig.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
|
||||
runConfig.vmArgs = "-Dfabric.development=true";
|
||||
runConfig.vmArgs = "-Dfabric.development=true -Djava.library.path=" + extension.getNativesDirectory().getAbsolutePath();
|
||||
|
||||
switch (extension.getLoaderLaunchMethod()) {
|
||||
case "launchwrapper":
|
||||
|
|
|
@ -26,6 +26,7 @@ package net.fabricmc.loom.util;
|
|||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MinecraftAssetsProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftNativesProvider;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
|
@ -59,6 +60,7 @@ public class SetupIntelijRunConfigs {
|
|||
if(Boolean.parseBoolean(System.getProperty("idea.sync.active", "false"))){
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
MinecraftAssetsProvider.provide(extension.getMinecraftProvider(), project);
|
||||
MinecraftNativesProvider.provide(extension.getMinecraftProvider(), project);
|
||||
}
|
||||
|
||||
File projectDir = project.file(".idea");
|
||||
|
|
Loading…
Reference in New Issue