store mixin maps in per-project build caches, move root project build cache to build/loom-cache from .gradle/

dev/0.11
Adrian Siekierka 2019-04-21 11:18:45 +02:00
parent 988c7e483d
commit ab9d2d3fda
4 changed files with 15 additions and 9 deletions

View File

@ -51,7 +51,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer;
public class AbstractPlugin implements Plugin<Project> { public class AbstractPlugin implements Plugin<Project> {
protected Project project; protected Project project;
@ -208,7 +207,7 @@ public class AbstractPlugin implements Plugin<Project> {
}); });
project1.getRepositories().flatDir(flatDirectoryArtifactRepository -> { project1.getRepositories().flatDir(flatDirectoryArtifactRepository -> {
flatDirectoryArtifactRepository.dir(extension.getProjectCache()); flatDirectoryArtifactRepository.dir(extension.getRootProjectBuildCache());
flatDirectoryArtifactRepository.setName("UserLocalCacheFiles"); flatDirectoryArtifactRepository.setName("UserLocalCacheFiles");
}); });

View File

@ -33,7 +33,6 @@ import org.cadixdev.lorenz.MappingSet;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.UnknownDomainObjectException; import org.gradle.api.UnknownDomainObjectException;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -94,8 +93,16 @@ public class LoomGradleExtension {
return userCache; return userCache;
} }
public File getProjectCache(){ public File getRootProjectBuildCache() {
File projectCache = new File(project.getRootDir(), ".gradle/minecraft/"); File projectCache = new File(project.getRootProject().getBuildDir(), "loom-cache");
if(!projectCache.exists()){
projectCache.mkdirs();
}
return projectCache;
}
public File getProjectBuildCache() {
File projectCache = new File(project.getBuildDir(), "loom-cache");
if(!projectCache.exists()){ if(!projectCache.exists()){
projectCache.mkdirs(); projectCache.mkdirs();
} }
@ -103,7 +110,7 @@ public class LoomGradleExtension {
} }
public File getRemappedModCache() { public File getRemappedModCache() {
File remappedModCache = new File(getProjectCache(), "remapped_mods/"); File remappedModCache = new File(getRootProjectBuildCache(), "remapped_mods");
if (!remappedModCache.exists()) { if (!remappedModCache.exists()) {
remappedModCache.mkdir(); remappedModCache.mkdir();
} }
@ -111,7 +118,7 @@ public class LoomGradleExtension {
} }
public File getNestedModCache() { public File getNestedModCache() {
File nestedModCache = new File(getProjectCache(), "nested_mods/"); File nestedModCache = new File(getRootProjectBuildCache(), "nested_mods");
if (!nestedModCache.exists()) { if (!nestedModCache.exists()) {
nestedModCache.mkdir(); nestedModCache.mkdir();
} }

View File

@ -106,7 +106,7 @@ public class MappingsProvider extends DependencyProvider {
MAPPINGS_TINY_BASE = new File(MAPPINGS_DIR, mappingsName + "-tiny-" + minecraftVersion + "-" + mappingsVersion + "-base"); MAPPINGS_TINY_BASE = new File(MAPPINGS_DIR, mappingsName + "-tiny-" + minecraftVersion + "-" + mappingsVersion + "-base");
MAPPINGS_TINY = new File(MAPPINGS_DIR, mappingsName + "-tiny-" + minecraftVersion + "-" + mappingsVersion); MAPPINGS_TINY = new File(MAPPINGS_DIR, mappingsName + "-tiny-" + minecraftVersion + "-" + mappingsVersion);
MAPPINGS_MIXIN_EXPORT = new File(extension.getProjectCache(), "mixin-map-" + minecraftVersion + "-" + mappingsVersion + ".tiny"); MAPPINGS_MIXIN_EXPORT = new File(extension.getProjectBuildCache(), "mixin-map-" + minecraftVersion + "-" + mappingsVersion + ".tiny");
} }
@Override @Override

View File

@ -42,7 +42,7 @@ public class CleanLoomMappings extends DefaultLoomTask {
extension.getMinecraftMappedProvider().getIntermediaryJar().delete(); extension.getMinecraftMappedProvider().getIntermediaryJar().delete();
extension.getMinecraftMappedProvider().getMappedJar().delete(); extension.getMinecraftMappedProvider().getMappedJar().delete();
try { try {
Files.walkFileTree(extension.getProjectCache().toPath(), new DeletingFileVisitor()); Files.walkFileTree(extension.getRootProjectBuildCache().toPath(), new DeletingFileVisitor());
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }