From 538d4e55a9464708ba354586a4c42cde2bc83be7 Mon Sep 17 00:00:00 2001 From: deiflaender Date: Tue, 22 Aug 2023 13:39:54 +0200 Subject: [PATCH] Native Build --- .../build.gradle.kts | 25 ++++++++++++++++--- .../META-INF/native-image/reflect-config.json | 10 ++++++++ .../src/main/resources/custom.security | 1 + .../server/graph/ViewerDocumentTest.java | 1 - 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 layoutparser-service/layoutparser-service-server/src/main/resources/META-INF/native-image/reflect-config.json create mode 100644 layoutparser-service/layoutparser-service-server/src/main/resources/custom.security diff --git a/layoutparser-service/layoutparser-service-server/build.gradle.kts b/layoutparser-service/layoutparser-service-server/build.gradle.kts index b63c6a2..dc17763 100644 --- a/layoutparser-service/layoutparser-service-server/build.gradle.kts +++ b/layoutparser-service/layoutparser-service-server/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("io.spring.dependency-management") version "1.1.3" id("org.sonarqube") version "4.3.0.3225" id("io.freefair.lombok") version "8.2.2" -// id("org.graalvm.buildtools.native") version "0.9.23" + id("org.graalvm.buildtools.native") version "0.9.24" } description = "layoutparser-service-server" @@ -15,20 +15,27 @@ description = "layoutparser-service-server" val jacksonVersion = "2.15.2" val pdfBoxVersion = "3.0.0-RC1" + + dependencies { implementation(project(":layoutparser-service-processor")) implementation(project(":layoutparser-service-internal-api")) - implementation("com.iqser.red.commons:storage-commons:2.36.0") + implementation("com.iqser.red.commons:storage-commons:azNative2") implementation("com.knecon.fforesight:tenant-commons:0.10.0") implementation("org.springframework.boot:spring-boot-starter-actuator:3.1.2") implementation("com.amazonaws:aws-java-sdk-s3:1.12.533") implementation("org.springframework.boot:spring-boot-starter-amqp:3.1.2") implementation("org.springframework.cloud:spring-cloud-starter-openfeign:4.0.4") + +// implementation("com.azure:azure-storage-blob:12.24.0-beta.1") +// implementation("com.azure.spring:azure-spring-cloud-storage:2.14.0") + // for integration testing only testImplementation(project(":layoutparser-service-internal-api")) + testImplementation("org.springframework.boot:spring-boot-starter-amqp:3.1.2") testImplementation("com.iqser.red.service:persistence-service-shared-api-v1:2.138.0") testImplementation("com.iqser.red.commons:jackson-commons:1.3.0") @@ -39,6 +46,14 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-test:3.1.2") } + +configurations { + all { + exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging") + exclude(group = "commons-logging", module = "commons-logging") + } +} + /* //TODO: implement native build using GRAALVM, currently the problem is, logback needs runtime configuration using reflections or something //kinda weird behavior, since the buildArgs below seem to have no effect at all @@ -48,6 +63,8 @@ We traced the issue to storage-commons and there to azure blob storage, this is https://github.com/Azure/azure-sdk-for-java/issues/36001 //AOT is springs ahead of time compilation, it is a code analysis which generates new code, therefore checkstyle and pmd can be disabled on them. +*/ + tasks.named("checkstyleAot") { enabled = false } @@ -60,7 +77,7 @@ tasks.named("pmdAot") { tasks.named("pmdAotTest") { enabled = false } -*/ + sonarqube { properties { @@ -71,6 +88,8 @@ sonarqube { tasks.named("bootBuildImage") { + environment.put("BP_NATIVE_IMAGE_BUILD_ARGUMENTS", "-Djava.security.properties=/workspace/BOOT-INF/classes/custom.security --initialize-at-run-time=org.slf4j,org.apache.log4,org.apache.commons.logging --trace-class-initialization=org.apache.commons.logging.LogFactory") + environment.put("BPE_DELIM_JAVA_TOOL_OPTIONS", " ") environment.put("BPE_APPEND_JAVA_TOOL_OPTIONS", "-Dfile.encoding=UTF-8") diff --git a/layoutparser-service/layoutparser-service-server/src/main/resources/META-INF/native-image/reflect-config.json b/layoutparser-service/layoutparser-service-server/src/main/resources/META-INF/native-image/reflect-config.json new file mode 100644 index 0000000..025d0e5 --- /dev/null +++ b/layoutparser-service/layoutparser-service-server/src/main/resources/META-INF/native-image/reflect-config.json @@ -0,0 +1,10 @@ +[ + { + "name": "org.apereo.cas.web.CasWebApplicationContext", + "allDeclaredConstructors": true + } +] + + + + diff --git a/layoutparser-service/layoutparser-service-server/src/main/resources/custom.security b/layoutparser-service/layoutparser-service-server/src/main/resources/custom.security new file mode 100644 index 0000000..9861c93 --- /dev/null +++ b/layoutparser-service/layoutparser-service-server/src/main/resources/custom.security @@ -0,0 +1 @@ +jdk.jar.disabledAlgorithms=MD2, MD5, RSA, DSA \ No newline at end of file diff --git a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/ViewerDocumentTest.java b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/ViewerDocumentTest.java index f150ae2..f1eb9ab 100644 --- a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/ViewerDocumentTest.java +++ b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/ViewerDocumentTest.java @@ -18,7 +18,6 @@ import lombok.SneakyThrows; public class ViewerDocumentTest extends BuildDocumentGraphTest { @Test - @Disabled @SneakyThrows public void testViewerDocument() {