Load project deps from within gradle, should allow moduals to be built
This commit is contained in:
parent
ee4708e486
commit
c89344527b
20 changed files with 103 additions and 59 deletions
|
@ -22,13 +22,18 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom;
|
||||
package net.fabricmc.loom;
|
||||
|
||||
import net.fabric.loom.util.Constants;
|
||||
import com.google.gson.Gson;
|
||||
import net.fabricmc.loom.task.DownloadTask;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.fabricmc.loom.util.Version;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.repositories.FlatDirectoryArtifactRepository;
|
||||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
|
@ -37,6 +42,10 @@ import org.gradle.api.tasks.javadoc.Javadoc;
|
|||
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AbstractPlugin implements Plugin<Project> {
|
||||
protected Project project;
|
||||
|
||||
|
@ -138,5 +147,34 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
|
||||
Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);
|
||||
javadoc.setClasspath(main.getOutput().plus(main.getCompileClasspath()));
|
||||
|
||||
project.afterEvaluate(project1 -> {
|
||||
LoomGradleExtension extension = project1.getExtensions().getByType(LoomGradleExtension.class);
|
||||
project1.getRepositories().flatDir(flatDirectoryArtifactRepository -> {
|
||||
flatDirectoryArtifactRepository.dir(Constants.CACHE_FILES);
|
||||
flatDirectoryArtifactRepository.setName("LoomCacheFiles");
|
||||
});
|
||||
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
DownloadTask.downloadMcJson(extension, project1.getLogger());
|
||||
Version version = gson.fromJson(new FileReader(Constants.MINECRAFT_JSON.get(extension)), Version.class);
|
||||
for (Version.Library library : version.libraries) {
|
||||
if (library.allowed() && library.getFile() != null) {
|
||||
String configName = Constants.CONFIG_MC_DEPENDENCIES;
|
||||
if (library.name.contains("java3d") || library.name.contains("paulscode") || library.name.contains("lwjgl") || library.name.contains("twitch") || library.name.contains("jinput")) {
|
||||
configName = Constants.CONFIG_MC_DEPENDENCIES_CLIENT;
|
||||
}
|
||||
project1.getDependencies().add(configName, library.getArtifactName());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:" + Constants.MINECRAFT_CLIENT_MAPPED_JAR.get(extension).getName().replace(".jar", ""));
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom;
|
||||
package net.fabricmc.loom;
|
||||
|
||||
public class LoomGradleExtension {
|
||||
public String version;
|
|
@ -22,12 +22,12 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom;
|
||||
package net.fabricmc.loom;
|
||||
|
||||
import net.fabric.loom.task.DownloadTask;
|
||||
import net.fabric.loom.task.ExtractNativesTask;
|
||||
import net.fabric.loom.task.GenIdeaProjectTask;
|
||||
import net.fabric.loom.task.MapJarsTask;
|
||||
import net.fabricmc.loom.task.DownloadTask;
|
||||
import net.fabricmc.loom.task.ExtractNativesTask;
|
||||
import net.fabricmc.loom.task.GenIdeaProjectTask;
|
||||
import net.fabricmc.loom.task.MapJarsTask;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
|
|
@ -22,10 +22,10 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.task;
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import net.fabric.loom.util.Constants;
|
||||
import net.fabric.loom.util.progress.ProgressLogger;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.progress.ProgressLogger;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.OutputFile;
|
|
@ -22,27 +22,29 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.task;
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import net.fabric.loom.util.Constants;
|
||||
import net.fabric.loom.util.Version;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.Version;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.util.Checksum;
|
||||
import net.fabricmc.loom.util.ManifestVersion;
|
||||
import net.fabricmc.loom.util.assets.AssetIndex;
|
||||
import net.fabricmc.loom.util.assets.AssetObject;
|
||||
import net.fabricmc.loom.util.progress.ProgressLogger;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler;
|
||||
import org.gradle.api.logging.Logger;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import net.fabric.loom.LoomGradleExtension;
|
||||
import net.fabric.loom.util.Checksum;
|
||||
import net.fabric.loom.util.ManifestVersion;
|
||||
import net.fabric.loom.util.assets.AssetIndex;
|
||||
import net.fabric.loom.util.assets.AssetObject;
|
||||
import net.fabric.loom.util.progress.ProgressLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
@ -53,19 +55,7 @@ public class DownloadTask extends DefaultTask {
|
|||
try {
|
||||
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
|
||||
|
||||
if (!Constants.MINECRAFT_JSON.get(extension).exists()) {
|
||||
this.getLogger().lifecycle(":downloading minecraft json");
|
||||
FileUtils.copyURLToFile(new URL("https://launchermeta.mojang.com/mc/game/version_manifest.json"), Constants.VERSION_MANIFEST);
|
||||
ManifestVersion mcManifest = new GsonBuilder().create().fromJson(FileUtils.readFileToString(Constants.VERSION_MANIFEST), ManifestVersion.class);
|
||||
|
||||
Optional<ManifestVersion.Versions> optionalVersion = mcManifest.versions.stream().filter(versions -> versions.id.equalsIgnoreCase(extension.version)).findFirst();
|
||||
if (optionalVersion.isPresent()) {
|
||||
FileUtils.copyURLToFile(new URL(optionalVersion.get().url), Constants.MINECRAFT_JSON.get(extension));
|
||||
} else {
|
||||
this.getLogger().info(":failed downloading minecraft json");
|
||||
throw new RuntimeException("Failed downloading Minecraft json");
|
||||
}
|
||||
}
|
||||
downloadMcJson(extension, getLogger());
|
||||
|
||||
Gson gson = new Gson();
|
||||
Version version = gson.fromJson(new FileReader(Constants.MINECRAFT_JSON.get(extension)), Version.class);
|
||||
|
@ -145,4 +135,20 @@ public class DownloadTask extends DefaultTask {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void downloadMcJson(LoomGradleExtension extension, Logger logger) throws IOException {
|
||||
if (!Constants.MINECRAFT_JSON.get(extension).exists()) {
|
||||
logger.lifecycle(":downloading minecraft json");
|
||||
FileUtils.copyURLToFile(new URL("https://launchermeta.mojang.com/mc/game/version_manifest.json"), Constants.VERSION_MANIFEST);
|
||||
ManifestVersion mcManifest = new GsonBuilder().create().fromJson(FileUtils.readFileToString(Constants.VERSION_MANIFEST), ManifestVersion.class);
|
||||
|
||||
Optional<ManifestVersion.Versions> optionalVersion = mcManifest.versions.stream().filter(versions -> versions.id.equalsIgnoreCase(extension.version)).findFirst();
|
||||
if (optionalVersion.isPresent()) {
|
||||
FileUtils.copyURLToFile(new URL(optionalVersion.get().url), Constants.MINECRAFT_JSON.get(extension));
|
||||
} else {
|
||||
logger.info(":failed downloading minecraft json");
|
||||
throw new RuntimeException("Failed downloading Minecraft json");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,9 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.task;
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import net.fabric.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
|
@ -22,12 +22,12 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.task;
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import net.fabric.loom.LoomGradleExtension;
|
||||
import net.fabric.loom.util.Constants;
|
||||
import net.fabric.loom.util.IdeaRunConfig;
|
||||
import net.fabric.loom.util.Version;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.IdeaRunConfig;
|
||||
import net.fabricmc.loom.util.Version;
|
||||
import com.google.gson.Gson;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.TaskAction;
|
|
@ -22,13 +22,13 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.task;
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import cuchaz.enigma.Deobfuscator;
|
||||
import cuchaz.enigma.mapping.MappingsEnigmaReader;
|
||||
import cuchaz.enigma.throwables.MappingParseException;
|
||||
import net.fabric.loom.LoomGradleExtension;
|
||||
import net.fabric.loom.util.Constants;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.TaskAction;
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util;
|
||||
package net.fabricmc.loom.util;
|
||||
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.common.hash.Hashing;
|
|
@ -22,10 +22,10 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util;
|
||||
package net.fabricmc.loom.util;
|
||||
|
||||
import net.fabric.loom.util.delayed.IDelayed;
|
||||
import net.fabric.loom.util.delayed.DelayedFile;
|
||||
import net.fabricmc.loom.util.delayed.IDelayed;
|
||||
import net.fabricmc.loom.util.delayed.DelayedFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util;
|
||||
package net.fabricmc.loom.util;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util;
|
||||
package net.fabricmc.loom.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util;
|
||||
package net.fabricmc.loom.util;
|
||||
|
||||
public class OperatingSystem {
|
||||
public static String getOS() {
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util;
|
||||
package net.fabricmc.loom.util;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util.assets;
|
||||
package net.fabricmc.loom.util.assets;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util.assets;
|
||||
package net.fabricmc.loom.util.assets;
|
||||
|
||||
public class AssetObject {
|
||||
private String hash;
|
|
@ -22,9 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util.delayed;
|
||||
package net.fabricmc.loom.util.delayed;
|
||||
|
||||
import net.fabric.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Function;
|
|
@ -22,9 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util.delayed;
|
||||
package net.fabricmc.loom.util.delayed;
|
||||
|
||||
import net.fabric.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
|
||||
public interface IDelayed<T> {
|
||||
T get(LoomGradleExtension extension);
|
|
@ -22,7 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabric.loom.util.progress;
|
||||
package net.fabricmc.loom.util.progress;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
|
|
@ -1 +1 @@
|
|||
implementation-class=net.fabric.loom.LoomGradlePlugin
|
||||
implementation-class=net.fabricmc.loom.LoomGradlePlugin
|
Loading…
Reference in a new issue