fix AP not being present on classpath

dev/0.11
asie 2018-11-05 14:57:43 +01:00
parent 1691c8c2d8
commit 8e3822dec7
7 changed files with 20 additions and 21 deletions

View File

@ -69,7 +69,6 @@ public class AbstractPlugin implements Plugin<Project> {
// Force add Mojang repository // Force add Mojang repository
addMavenRepo(target, "Mojang", "https://libraries.minecraft.net/"); addMavenRepo(target, "Mojang", "https://libraries.minecraft.net/");
Configuration compileModsConfig = project.getConfigurations().maybeCreate(Constants.COMPILE_MODS); Configuration compileModsConfig = project.getConfigurations().maybeCreate(Constants.COMPILE_MODS);
compileModsConfig.setTransitive(false); // Dont get transitive deps of mods compileModsConfig.setTransitive(false); // Dont get transitive deps of mods
Configuration minecraftConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT); Configuration minecraftConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT);
@ -89,9 +88,6 @@ public class AbstractPlugin implements Plugin<Project> {
javaCompileTask.doFirst(task1 -> { javaCompileTask.doFirst(task1 -> {
project.getLogger().lifecycle(":setting java compiler args"); project.getLogger().lifecycle(":setting java compiler args");
try { try {
//javaCompileTask.getClasspath().add(target.files(this.getClass().getProtectionDomain().getCodeSource().getLocation()));
javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFileNamedIntermediary=" + extension.getMinecraftProvider().pomfProvider.MAPPINGS_TINY.getCanonicalPath()); javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFileNamedIntermediary=" + extension.getMinecraftProvider().pomfProvider.MAPPINGS_TINY.getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFileNamedIntermediary=" + extension.getMinecraftProvider().pomfProvider.MAPPINGS_MIXIN_EXPORT.getCanonicalPath()); javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFileNamedIntermediary=" + extension.getMinecraftProvider().pomfProvider.MAPPINGS_MIXIN_EXPORT.getCanonicalPath());
if(extension.refmapName == null || extension.refmapName.isEmpty()){ if(extension.refmapName == null || extension.refmapName.isEmpty()){

View File

@ -46,10 +46,10 @@ public class MinecraftJarProvider {
public MinecraftJarProvider(Project project, MinecraftProvider minecraftProvider) throws IOException { public MinecraftJarProvider(Project project, MinecraftProvider minecraftProvider) throws IOException {
this.minecraftProvider = minecraftProvider; this.minecraftProvider = minecraftProvider;
initFiles(project, minecraftProvider); initFiles(project, minecraftProvider);
proccess(project, minecraftProvider); process(project, minecraftProvider);
} }
private void proccess(Project project, MinecraftProvider minecraftProvider) throws IOException { private void process(Project project, MinecraftProvider minecraftProvider) throws IOException {
if (!MINECRAFT_MERGED_JAR.exists()) { if (!MINECRAFT_MERGED_JAR.exists()) {
mergeJars(project); mergeJars(project);
} }
@ -67,7 +67,7 @@ public class MinecraftJarProvider {
if (!MINECRAFT_MAPPED_JAR.exists()) { if (!MINECRAFT_MAPPED_JAR.exists()) {
throw new RuntimeException("mapped jar not found"); throw new RuntimeException("mapped jar not found");
} }
minecraftProvider.addDep(MINECRAFT_MAPPED_JAR, project); minecraftProvider.addDependency(MINECRAFT_MAPPED_JAR, project);
} }
public void mergeJars(Project project) throws IOException { public void mergeJars(Project project) throws IOException {

View File

@ -24,8 +24,6 @@
package net.fabricmc.loom.providers; package net.fabricmc.loom.providers;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.gson.Gson; import com.google.gson.Gson;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Checksum; import net.fabricmc.loom.util.Checksum;
@ -44,7 +42,6 @@ import java.net.URL;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public class MinecraftLibraryProvider { public class MinecraftLibraryProvider {
@ -71,7 +68,7 @@ public class MinecraftLibraryProvider {
FileUtils.copyURLToFile(new URL(library.getURL()), library.getFile(MINECRAFT_LIBS)); FileUtils.copyURLToFile(new URL(library.getURL()), library.getFile(MINECRAFT_LIBS));
} }
libs.add(library.getFile(MINECRAFT_LIBS)); libs.add(library.getFile(MINECRAFT_LIBS));
minecraftProvider.addDep(library.getFile(MINECRAFT_LIBS), project); minecraftProvider.addDependency(library.getFile(MINECRAFT_LIBS), project);
} }
} }

View File

@ -57,7 +57,7 @@ public class MinecraftProvider extends DependencyProvider {
Gson gson = new Gson(); Gson gson = new Gson();
@Override @Override
public void provide(DependcyInfo dependency, Project project, LoomGradleExtension extension) throws Exception { public void provide(DependencyInfo dependency, Project project, LoomGradleExtension extension) throws Exception {
minecraftVersion = dependency.getDependency().getName(); minecraftVersion = dependency.getDependency().getName();
pomfVersion = dependency.getDependency().getVersion(); pomfVersion = dependency.getDependency().getVersion();
@ -66,12 +66,14 @@ public class MinecraftProvider extends DependencyProvider {
downloadMcJson(); downloadMcJson();
versionInfo = gson.fromJson(new FileReader(MINECRAFT_JSON), MinecraftVersionInfo.class); versionInfo = gson.fromJson(new FileReader(MINECRAFT_JSON), MinecraftVersionInfo.class);
// Add Loom as an annotation processor
addDependency(project.files(this.getClass().getProtectionDomain().getCodeSource().getLocation()), project, "compileOnly");
downloadJars(); downloadJars();
libraryProvider = new MinecraftLibraryProvider(); libraryProvider = new MinecraftLibraryProvider();
libraryProvider.provide(this, project); libraryProvider.provide(this, project);
//Downloads and setups up pomf
pomfProvider = new PomfProvider(pomfVersion, minecraftVersion, project); pomfProvider = new PomfProvider(pomfVersion, minecraftVersion, project);
jarProvider = new MinecraftJarProvider(project, this); jarProvider = new MinecraftJarProvider(project, this);

View File

@ -34,7 +34,7 @@ import java.io.File;
public class ModRemapperProvider extends DependencyProvider { public class ModRemapperProvider extends DependencyProvider {
@Override @Override
public void provide(DependcyInfo dependency, Project project, LoomGradleExtension extension) { public void provide(DependencyInfo dependency, Project project, LoomGradleExtension extension) {
File input = dependency.resolveFile(); File input = dependency.resolveFile();
project.getLogger().lifecycle("Providing " + dependency.getDepString()); project.getLogger().lifecycle("Providing " + dependency.getDepString());
@ -46,7 +46,7 @@ public class ModRemapperProvider extends DependencyProvider {
ModProcessor.handleMod(input, output, project); ModProcessor.handleMod(input, output, project);
addDep(output, project); addDependency(output, project);
} }
@Override @Override

View File

@ -36,15 +36,19 @@ public abstract class DependencyProvider {
private LoomDependencyManager dependencyManager; private LoomDependencyManager dependencyManager;
public abstract void provide(DependcyInfo dependency, Project project, LoomGradleExtension extension) throws Exception; public abstract void provide(DependencyInfo dependency, Project project, LoomGradleExtension extension) throws Exception;
public abstract String getTargetConfig(); public abstract String getTargetConfig();
public void addDep(Object object, Project project){ public void addDependency(Object object, Project project) {
addDependency(object, project, "compile");
}
public void addDependency(Object object, Project project, String target) {
if(object instanceof File){ if(object instanceof File){
object = project.files(object); object = project.files(object);
} }
project.getDependencies().add("compile", object); project.getDependencies().add(target, object);
} }
public void register(LoomDependencyManager dependencyManager){ public void register(LoomDependencyManager dependencyManager){
@ -55,11 +59,11 @@ public abstract class DependencyProvider {
return dependencyManager; return dependencyManager;
} }
public static class DependcyInfo { public static class DependencyInfo {
final Dependency dependency; final Dependency dependency;
final Configuration sourceConfiguration; final Configuration sourceConfiguration;
public DependcyInfo(Dependency dependency, Configuration sourceConfiguration) { public DependencyInfo(Dependency dependency, Configuration sourceConfiguration) {
this.dependency = dependency; this.dependency = dependency;
this.sourceConfiguration = sourceConfiguration; this.sourceConfiguration = sourceConfiguration;
} }

View File

@ -69,7 +69,7 @@ public class LoomDependencyManager {
configuration.getDependencies().stream().forEach(dependency -> { configuration.getDependencies().stream().forEach(dependency -> {
for(DependencyProvider provider : dependencyProviderList){ for(DependencyProvider provider : dependencyProviderList){
if(provider.getTargetConfig().equals(config)){ if(provider.getTargetConfig().equals(config)){
DependencyProvider.DependcyInfo info = new DependencyProvider.DependcyInfo(dependency, configuration); DependencyProvider.DependencyInfo info = new DependencyProvider.DependencyInfo(dependency, configuration);
try { try {
provider.provide(info, project, extension); provider.provide(info, project, extension);
} catch (Exception e) { } catch (Exception e) {