mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-06-28 22:44:50 +02:00
WIP: Try getting nativeImage build to work
This commit is contained in:
parent
c8c9359485
commit
f61f7bae15
|
@ -2,10 +2,25 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url "https://plugins.gradle.org/m2/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath "gradle.plugin.org.mikeneck:graalvm-native-image-plugin:0.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'application'
|
id 'application'
|
||||||
id "com.github.johnrengelman.shadow" version "6.1.0"
|
id "com.github.johnrengelman.shadow" version "6.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: "org.mikeneck.graalvm-native-image"
|
||||||
|
|
||||||
def generatedVersionDir = "${buildDir}/generated-version"
|
def generatedVersionDir = "${buildDir}/generated-version"
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@ -42,6 +57,7 @@ dependencies {
|
||||||
|
|
||||||
implementation(project(":pgpainless-sop"))
|
implementation(project(":pgpainless-sop"))
|
||||||
implementation "org.pgpainless:sop-java-picocli:$sopJavaVersion"
|
implementation "org.pgpainless:sop-java-picocli:$sopJavaVersion"
|
||||||
|
annotationProcessor "info.picocli:picocli-codegen:4.6.3"
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
|
// https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
|
||||||
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
|
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
|
||||||
|
@ -52,6 +68,23 @@ mainClassName = 'org.pgpainless.cli.PGPainlessCLI'
|
||||||
application {
|
application {
|
||||||
mainClass = mainClassName
|
mainClass = mainClassName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
generateConfig
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
//...
|
||||||
|
generateConfig 'info.picocli:picocli-codegen:4.6.3'
|
||||||
|
}
|
||||||
|
|
||||||
|
task(generateGraalReflectionConfig, dependsOn: 'classes', type: JavaExec) {
|
||||||
|
main = 'picocli.codegen.aot.graalvm.ReflectionConfigGenerator'
|
||||||
|
classpath = configurations.generateConfig + sourceSets.main.runtimeClasspath
|
||||||
|
def outputFile = "${buildDir}/resources/main/META-INF/native-image/${project.group}/${project.name}/reflect-config.json"
|
||||||
|
args = ["--output=$outputFile", 'sop.cli.picocli.SopCLI']
|
||||||
|
}
|
||||||
|
assemble.dependsOn generateGraalReflectionConfig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
jar {
|
jar {
|
||||||
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||||
|
@ -78,4 +111,26 @@ run {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tasks."jar".dependsOn(":pgpainless-core:assemble", ":pgpainless-sop:assemble")
|
nativeImage {
|
||||||
|
// dependsOn(':generateGraalReflectionConfig')
|
||||||
|
// dependsOn(':generateCompletionScript')
|
||||||
|
def graalHome = System.getenv("GRAALVM_HOME")
|
||||||
|
if (graalHome == null) {
|
||||||
|
throw new IllegalStateException("GRAALVM_HOME not set.")
|
||||||
|
}
|
||||||
|
|
||||||
|
graalVmHome = graalHome
|
||||||
|
mainClass = mainClassName
|
||||||
|
executableName = 'pgpainless-cli'
|
||||||
|
arguments(
|
||||||
|
'--no-fallback',
|
||||||
|
// '--enable-all-security-services',
|
||||||
|
// '--initialize-at-run-time=com.example.runtime',
|
||||||
|
'--enable-https',
|
||||||
|
'--enable-all-security-services',
|
||||||
|
'--allow-incomplete-classpath',
|
||||||
|
// '--report-unsupported-elements-at-runtime',
|
||||||
|
'--initialize-at-run-time=org.bouncycastle.jcajce.provider.drbg.DRBG$Default,org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
tasks."nativeImage".dependsOn('generateGraalReflectionConfig')
|
||||||
|
|
|
@ -4,6 +4,14 @@
|
||||||
|
|
||||||
package org.pgpainless.sop;
|
package org.pgpainless.sop;
|
||||||
|
|
||||||
|
import java.security.Provider;
|
||||||
|
import java.security.Security;
|
||||||
|
|
||||||
|
import com.sun.crypto.provider.SunJCE;
|
||||||
|
import org.bouncycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi;
|
||||||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import org.pgpainless.implementation.ImplementationFactory;
|
||||||
|
import org.pgpainless.implementation.JceImplementationFactory;
|
||||||
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
import sop.operation.Armor;
|
import sop.operation.Armor;
|
||||||
|
@ -11,18 +19,28 @@ import sop.operation.Dearmor;
|
||||||
import sop.operation.Decrypt;
|
import sop.operation.Decrypt;
|
||||||
import sop.operation.DetachedSign;
|
import sop.operation.DetachedSign;
|
||||||
import sop.operation.DetachedVerify;
|
import sop.operation.DetachedVerify;
|
||||||
import sop.operation.InlineDetach;
|
|
||||||
import sop.operation.Encrypt;
|
import sop.operation.Encrypt;
|
||||||
import sop.operation.ExtractCert;
|
import sop.operation.ExtractCert;
|
||||||
import sop.operation.GenerateKey;
|
import sop.operation.GenerateKey;
|
||||||
|
import sop.operation.InlineDetach;
|
||||||
import sop.operation.InlineSign;
|
import sop.operation.InlineSign;
|
||||||
import sop.operation.InlineVerify;
|
import sop.operation.InlineVerify;
|
||||||
import sop.operation.Version;
|
import sop.operation.Version;
|
||||||
|
import sun.security.ec.SunEC;
|
||||||
|
|
||||||
public class SOPImpl implements SOP {
|
public class SOPImpl implements SOP {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ArmoredOutputStreamFactory.setVersionInfo(null);
|
ArmoredOutputStreamFactory.setVersionInfo(null);
|
||||||
|
ImplementationFactory.setFactoryImplementation(new JceImplementationFactory());
|
||||||
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
Security.addProvider(new SunJCE());
|
||||||
|
Security.addProvider(new SunEC());
|
||||||
|
new KeyFactorySpi();
|
||||||
|
|
||||||
|
Provider bcProv = Security.getProvider("BC");
|
||||||
|
Security.removeProvider("BC");
|
||||||
|
Security.insertProviderAt(bcProv, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue