Realized Reflections pulls in some pretty heavy dependencies, so manual registration it is, after all.
This commit is contained in:
79
build.gradle
79
build.gradle
@@ -63,7 +63,6 @@ dependencies {
|
||||
embed 'li.cil.ceres:ceres:0.0.2+'
|
||||
embed 'li.cil.sedna:sedna:0.0.1+'
|
||||
embed 'li.cil.sedna:sedna-buildroot:0.0.1+'
|
||||
embed 'org.reflections:reflections:0.9.12' // TODO Need to figure out how to make embed recursive.
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
|
||||
@@ -144,72 +143,43 @@ task copyData(type: Copy) {
|
||||
exclude '.cache'
|
||||
}
|
||||
|
||||
task generateMetaFiles {
|
||||
ext.embeddedFiles = []
|
||||
doLast {
|
||||
file("${buildDir}/dependencyMeta/").deleteDir()
|
||||
configurations.embed.resolvedConfiguration.resolvedArtifacts.each {
|
||||
// Don't embed anything Minecraft provides anyway.
|
||||
if (configurations.minecraft.resolvedConfiguration.resolvedArtifacts.contains(it)) {
|
||||
return
|
||||
}
|
||||
|
||||
ext.embeddedFiles.add(it.file)
|
||||
|
||||
def metaFile = file("${buildDir}/dependencyMeta/${it.file.name}.meta")
|
||||
metaFile.parentFile.mkdirs()
|
||||
def artifactRef = it.moduleVersion.toString()
|
||||
if (it.classifier != null) {
|
||||
artifactRef += ":${it.classifier}"
|
||||
}
|
||||
metaFile.text = "Maven-Artifact: $artifactRef"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task embedFilesInJar {
|
||||
dependsOn generateMetaFiles
|
||||
doLast {
|
||||
jar {
|
||||
into('/') {
|
||||
from generateMetaFiles.embeddedFiles
|
||||
from "${buildDir}/dependencyMeta/"
|
||||
}
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title" : "oc2",
|
||||
"Specification-Vendor" : "Sangar",
|
||||
"Specification-Version" : "1",
|
||||
"Implementation-Title" : project.name,
|
||||
"Implementation-Version" : "${semver}",
|
||||
"Implementation-Vendor" : "Sangar",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
'ContainedDeps' : generateMetaFiles.embeddedFiles.collect { it.name }.join(' ')
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
task deobfJar(type: Jar) {
|
||||
from sourceSets.main.output
|
||||
classifier = 'deobf'
|
||||
}
|
||||
|
||||
jar {
|
||||
dependsOn embedFilesInJar
|
||||
dependsOn deobfJar
|
||||
finalizedBy 'reobfJar'
|
||||
|
||||
configurations.embed.each {
|
||||
from(project.zipTree(it)) {
|
||||
exclude 'META-INF', 'META-INF/**'
|
||||
}
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title" : "oc2",
|
||||
"Specification-Vendor" : "Sangar",
|
||||
"Specification-Version" : "1",
|
||||
"Implementation-Title" : project.name,
|
||||
"Implementation-Version" : "${semver}",
|
||||
"Implementation-Vendor" : "Sangar",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
task apiJar(type: Jar) {
|
||||
classifier = 'api'
|
||||
from sourceSets.main.allSource
|
||||
from sourceSets.main.output
|
||||
classifier = 'api'
|
||||
include 'li/cil/oc2/api/**'
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
from javadoc.destinationDir
|
||||
classifier 'javadoc'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives javadocJar
|
||||
archives deobfJar
|
||||
archives apiJar
|
||||
}
|
||||
|
||||
@@ -217,7 +187,6 @@ publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact jar
|
||||
artifact javadocJar
|
||||
artifact apiJar
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,24 +10,19 @@ import li.cil.oc2.common.bus.device.data.Firmwares;
|
||||
import li.cil.oc2.common.bus.device.provider.Providers;
|
||||
import li.cil.oc2.common.container.Containers;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import li.cil.oc2.common.serialization.serializers.Serializers;
|
||||
import li.cil.oc2.common.tileentity.TileEntities;
|
||||
import li.cil.sedna.devicetree.DeviceTreeRegistry;
|
||||
import li.cil.sedna.Sedna;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@Mod(API.MOD_ID)
|
||||
public final class OpenComputers {
|
||||
public OpenComputers() {
|
||||
// Do class lookup in a separate thread to avoid blocking for too long.
|
||||
// Specifically, this is to run detection of annotated types via the Reflections
|
||||
// library in the serialization library and the device tree registry.
|
||||
new Thread(() -> {
|
||||
Ceres.initialize();
|
||||
DeviceTreeRegistry.initialize();
|
||||
}).start();
|
||||
|
||||
Ceres.initialize();
|
||||
Sedna.initialize();
|
||||
Serializers.initialize();
|
||||
Config.initialize();
|
||||
|
||||
Items.initialize();
|
||||
Blocks.initialize();
|
||||
TileEntities.initialize();
|
||||
|
||||
@@ -2,11 +2,13 @@ package li.cil.oc2.common.serialization.serializers;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParser;
|
||||
import li.cil.ceres.api.*;
|
||||
import li.cil.ceres.api.DeserializationVisitor;
|
||||
import li.cil.ceres.api.SerializationException;
|
||||
import li.cil.ceres.api.SerializationVisitor;
|
||||
import li.cil.ceres.api.Serializer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@RegisterSerializer
|
||||
public final class JsonArraySerializer implements Serializer<JsonArray> {
|
||||
@Override
|
||||
public void serialize(final SerializationVisitor visitor, final Class<JsonArray> type, final Object value) throws SerializationException {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package li.cil.oc2.common.serialization.serializers;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import li.cil.ceres.Ceres;
|
||||
|
||||
public final class Serializers {
|
||||
private static boolean isInitialized = false;
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
if (isInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
isInitialized = true;
|
||||
|
||||
Ceres.putSerializer(JsonArray.class, new JsonArraySerializer());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user