Skip to content

Commit

Permalink
chore: bump libs and small clean up (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk authored Sep 11, 2024
1 parent 963775b commit b6fb20b
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ src/generated
# Project specific
*.pdf
/data/

# Kotlin 2.0
.kotlin/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY build/libs/app-*.jar app.jar
COPY fonts fonts
COPY templates templates
COPY resources resources
ENV JDK_JAVA_OPTIONS="-Dlogback.configurationFile=logback-remote.xml"
ENV JDK_JAVA_OPTIONS="-Dlogback.configurationFile=logback.xml"
ENV DISABLE_PDF_GET="true"
ENV ENABLE_HTML_ENDPOINT="false"

Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ mkdir {templates,data}/your_teamname # your_teamname can be anything, but it'll
## Developing pdfgen

### Build and run tests
`./gradlew shadowJar`
```shell script
./gradlew shadowJar
```
or on windows
```shell script
gradlew.bat shadowJar
```


Running the application locally enables a GET endpoint at `/api/v1/genpdf/<application>/<template>`
which looks for test data at `data/<application>/<template>.json` and outputs a PDF to your browser.
Expand Down Expand Up @@ -116,7 +123,7 @@ or the command line:
```

### Release
We use default github release,
We use default GitHub release,
This project uses [semantic versioning](https://semver.org/) and does NOT prefix tags or release titles with `v` i.e. use `1.2.3` instead of `v1.2.3`

see guide about how to relese:[creating release github](
Expand All @@ -126,7 +133,9 @@ https://docs.github.com/en/repositories/releasing-projects-on-github/managing-re
### Upgrading the gradle wrapper
Find the newest version of gradle here: https://gradle.org/releases/ Then run this command:

```./gradlew wrapper --gradle-version $gradleVersjon```
```shell script
./gradlew wrapper --gradle-version $gradleVersjon
```


## pdfgen 2.0
Expand Down
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ val junitJupiterVersion = "5.11.0"
val verapdfVersion = "1.26.1"
val ktfmtVersion = "0.44"
val testcontainersVersion= "1.20.1"
val pdfgencoreVersion = "1.1.24"
val pdfgencoreVersion = "1.1.25"
val commonsCompressVersion = "1.27.1"

val javaVersion = JvmTarget.JVM_21


plugins {
id("application")
kotlin("jvm") version "2.0.20"
id("com.diffplug.spotless") version "6.25.0"
id("com.gradleup.shadow") version "8.3.0"
id("com.gradleup.shadow") version "8.3.1"
id("com.github.ben-manes.versions") version "0.51.0"
}

Expand All @@ -48,6 +49,8 @@ tasks {
testLogging {
events("passed", "skipped", "failed")
showStandardStreams = true
showStackTraces = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
16 changes: 0 additions & 16 deletions src/main/resources/logback-test.xml

This file was deleted.

File renamed without changes.
35 changes: 23 additions & 12 deletions src/test/kotlin/no/nav/pdfgen/PdfGenITest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal class PdfGenITest {
?: "{}"

val response =
runBlocking<HttpResponse> {
runBlocking {
client.post(
"http://localhost:$applicationPort/api/v1/genpdf/$applicationName/$templateName"
) {
Expand Down Expand Up @@ -120,19 +120,30 @@ internal class PdfGenITest {
assertEquals(true, document.pages.count > 0)
println(document.documentInformation.title)
document.close()

/* openhtmltopdf seems to strip any input that causes non-conforming PDF/A, so i can't get this test to work :(
it("Should return non OK status code when rendering templates that result in non-conformant PDF/A") {
val response = runBlocking<HttpResponse> {
client.post("http://localhost:$applicationPort/api/v1/genpdf/html/integration-test") {
body = TextContent(testTemplateInvalidFonts, contentType = ContentType.Application.Json)
}
}
response.status.isSuccess() shouldBeEqualTo false
}
*/
}

/* openhtmltopdf seems to strip any input that causes non-conforming PDF/A, so i can't get this test to work :(
@Test
internal fun `Using the HTML convert endpoint should render a invalid document using default HTML`() {
application.start()
val response = runBlocking {
client.post("http://localhost:$applicationPort/api/v1/genpdf/html/integration-test") {
setBody(testTemplateInvalidFonts)
}
}
assertEquals(false, response.status.isSuccess())
val bytes = runBlocking { response.readBytes() }
assertNotEquals(null, bytes)
Files.write(Paths.get("build", "html.pdf"), bytes)
// Load the document in pdfbox to ensure its valid
val document = Loader.loadPDF(bytes)
assertNotEquals(null, document)
assertEquals(true, document.pages.count > 0)
println(document.documentInformation.title)
document.close()
}
*/

@Test
internal fun `Using the image convert endpoint Should render a document using input image`() {
application.start()
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/no/nav/pdfgen/RenderingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal class RenderingTest {
}

@Test
internal fun `All pdfs should create a PDFA compliant file eenders a HTML payload to a PDFA compliant document`() {
internal fun `All pdfs should create a PDFA compliant file renders a HTML payload to a PDFA compliant document`() {
val pdfaFlavour = PDFAFlavour.PDFA_2_U
val validator = Foundries.defaultInstance().createValidator(pdfaFlavour, false)
val doc = testTemplateIncludedFonts
Expand Down

0 comments on commit b6fb20b

Please sign in to comment.