Browse Source

make jackson jars open and non-synthetic modules

terminal
Craig Raw 3 years ago
parent
commit
0c50c9cb9c
  1. 52
      build.gradle
  2. 14
      buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ExtraModuleInfoTransform.java
  3. 9
      buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ModuleInfo.java
  4. 1
      src/main/java/module-info.java

52
build.gradle

@ -239,6 +239,55 @@ task packageTarDistribution(type: Tar) {
} }
extraJavaModuleInfo { extraJavaModuleInfo {
module('jackson-core-2.10.1.jar', 'com.fasterxml.jackson.core', '2.10.1') {
exports('com.fasterxml.jackson.core')
exports('com.fasterxml.jackson.core.async')
exports('com.fasterxml.jackson.core.base')
exports('com.fasterxml.jackson.core.exc')
exports('com.fasterxml.jackson.core.filter')
exports('com.fasterxml.jackson.core.format')
exports('com.fasterxml.jackson.core.io')
exports('com.fasterxml.jackson.core.json')
exports('com.fasterxml.jackson.core.json.async')
exports('com.fasterxml.jackson.core.sym')
exports('com.fasterxml.jackson.core.type')
exports('com.fasterxml.jackson.core.util')
uses('com.fasterxml.jackson.core.ObjectCodec')
}
module('jackson-annotations-2.10.1.jar', 'com.fasterxml.jackson.annotation', '2.10.1') {
requires('com.fasterxml.jackson.core')
exports('com.fasterxml.jackson.annotation')
}
module('jackson-databind-2.10.1.jar', 'com.fasterxml.jackson.databind', '2.10.1') {
requires('java.desktop')
requires('java.logging')
requires('com.fasterxml.jackson.annotation')
requires('com.fasterxml.jackson.core')
requires('java.sql')
requires('java.xml')
exports('com.fasterxml.jackson.databind')
exports('com.fasterxml.jackson.databind.annotation')
exports('com.fasterxml.jackson.databind.cfg')
exports('com.fasterxml.jackson.databind.deser')
exports('com.fasterxml.jackson.databind.deser.impl')
exports('com.fasterxml.jackson.databind.deser.std')
exports('com.fasterxml.jackson.databind.exc')
exports('com.fasterxml.jackson.databind.ext')
exports('com.fasterxml.jackson.databind.introspect')
exports('com.fasterxml.jackson.databind.json')
exports('com.fasterxml.jackson.databind.jsonFormatVisitors')
exports('com.fasterxml.jackson.databind.jsonschema')
exports('com.fasterxml.jackson.databind.jsontype')
exports('com.fasterxml.jackson.databind.jsontype.impl')
exports('com.fasterxml.jackson.databind.module')
exports('com.fasterxml.jackson.databind.node')
exports('com.fasterxml.jackson.databind.ser')
exports('com.fasterxml.jackson.databind.ser.impl')
exports('com.fasterxml.jackson.databind.ser.std')
exports('com.fasterxml.jackson.databind.type')
exports('com.fasterxml.jackson.databind.util')
uses('com.fasterxml.jackson.databind.Module')
}
module('tornadofx-controls-1.0.4.jar', 'tornadofx.controls', '1.0.4') { module('tornadofx-controls-1.0.4.jar', 'tornadofx.controls', '1.0.4') {
exports('tornadofx.control') exports('tornadofx.control')
requires('javafx.controls') requires('javafx.controls')
@ -255,6 +304,7 @@ extraJavaModuleInfo {
exports('com.github.arteam.simplejsonrpc.client') exports('com.github.arteam.simplejsonrpc.client')
exports('com.github.arteam.simplejsonrpc.client.builder') exports('com.github.arteam.simplejsonrpc.client.builder')
exports('com.github.arteam.simplejsonrpc.client.exception') exports('com.github.arteam.simplejsonrpc.client.exception')
requires('com.fasterxml.jackson.core')
requires('com.fasterxml.jackson.databind') requires('com.fasterxml.jackson.databind')
requires('simple.json.rpc.core') requires('simple.json.rpc.core')
} }
@ -399,6 +449,8 @@ extraJavaModuleInfo {
requires('org.slf4j') requires('org.slf4j')
requires('org.bouncycastle.provider') requires('org.bouncycastle.provider')
requires('com.fasterxml.jackson.databind') requires('com.fasterxml.jackson.databind')
requires('com.fasterxml.jackson.annotation')
requires('com.fasterxml.jackson.core')
requires('logback.classic') requires('logback.classic')
requires('org.json') requires('org.json')
exports('com.samourai.http.client') exports('com.samourai.http.client')

14
buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ExtraModuleInfoTransform.java

@ -58,7 +58,8 @@ abstract public class ExtraModuleInfoTransform implements TransformAction<ExtraM
File originalJar = getInputArtifact().get().getAsFile(); File originalJar = getInputArtifact().get().getAsFile();
String originalJarName = originalJar.getName(); String originalJarName = originalJar.getName();
if (isModule(originalJar)) { //Recreate jackson jars as open, non-synthetic modules
if (isModule(originalJar) && !originalJarName.contains("jackson")) {
outputs.file(originalJar); outputs.file(originalJar);
} else if (moduleInfo.containsKey(originalJarName)) { } else if (moduleInfo.containsKey(originalJarName)) {
addModuleDescriptor(originalJar, getModuleJar(outputs, originalJar), moduleInfo.get(originalJarName)); addModuleDescriptor(originalJar, getModuleJar(outputs, originalJar), moduleInfo.get(originalJarName));
@ -140,9 +141,11 @@ abstract public class ExtraModuleInfoTransform implements TransformAction<ExtraM
private static void copyEntries(JarInputStream inputStream, JarOutputStream outputStream) throws IOException { private static void copyEntries(JarInputStream inputStream, JarOutputStream outputStream) throws IOException {
JarEntry jarEntry = inputStream.getNextJarEntry(); JarEntry jarEntry = inputStream.getNextJarEntry();
while (jarEntry != null) { while (jarEntry != null) {
outputStream.putNextEntry(jarEntry); if(!jarEntry.getName().equals("module-info.class")) {
outputStream.write(inputStream.readAllBytes()); outputStream.putNextEntry(jarEntry);
outputStream.closeEntry(); outputStream.write(inputStream.readAllBytes());
outputStream.closeEntry();
}
jarEntry = inputStream.getNextJarEntry(); jarEntry = inputStream.getNextJarEntry();
} }
} }
@ -161,6 +164,9 @@ abstract public class ExtraModuleInfoTransform implements TransformAction<ExtraM
for (String requireName : moduleInfo.getRequiresTransitive()) { for (String requireName : moduleInfo.getRequiresTransitive()) {
moduleVisitor.visitRequire(requireName, Opcodes.ACC_TRANSITIVE, null); moduleVisitor.visitRequire(requireName, Opcodes.ACC_TRANSITIVE, null);
} }
for (String usesName : moduleInfo.getUses()) {
moduleVisitor.visitUse(usesName.replace('.', '/'));
}
moduleVisitor.visitEnd(); moduleVisitor.visitEnd();
classWriter.visitEnd(); classWriter.visitEnd();
return classWriter.toByteArray(); return classWriter.toByteArray();

9
buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ModuleInfo.java

@ -13,6 +13,7 @@ public class ModuleInfo implements Serializable {
private List<String> exports = new ArrayList<>(); private List<String> exports = new ArrayList<>();
private List<String> requires = new ArrayList<>(); private List<String> requires = new ArrayList<>();
private List<String> requiresTransitive = new ArrayList<>(); private List<String> requiresTransitive = new ArrayList<>();
private List<String> uses = new ArrayList<>();
ModuleInfo(String moduleName, String moduleVersion) { ModuleInfo(String moduleName, String moduleVersion) {
this.moduleName = moduleName; this.moduleName = moduleName;
@ -31,6 +32,10 @@ public class ModuleInfo implements Serializable {
this.requiresTransitive.add(requiresTransitive); this.requiresTransitive.add(requiresTransitive);
} }
public void uses(String uses) {
this.uses.add(uses);
}
public String getModuleName() { public String getModuleName() {
return moduleName; return moduleName;
} }
@ -50,4 +55,8 @@ public class ModuleInfo implements Serializable {
protected List<String> getRequiresTransitive() { protected List<String> getRequiresTransitive() {
return requiresTransitive; return requiresTransitive;
} }
protected List<String> getUses() {
return uses;
}
} }

1
src/main/java/module-info.java

@ -18,6 +18,7 @@ open module com.sparrowwallet.sparrow {
requires simple.json.rpc.core; requires simple.json.rpc.core;
requires org.jetbrains.annotations; requires org.jetbrains.annotations;
requires com.fasterxml.jackson.databind; requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.annotation;
requires netlayer.jpms; requires netlayer.jpms;
requires org.slf4j; requires org.slf4j;
requires com.google.gson; requires com.google.gson;

Loading…
Cancel
Save