Skip to content

Commit

Permalink
Remove usage of Jackson and go back to Jaxb
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelmarhic committed Dec 19, 2021
1 parent a762ae3 commit d2e1d5b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies {
implementation Dependencies.androidPlugin
implementation Dependencies.kotlinStandardLibrary
implementation Dependencies.kotlinPoet
implementation Dependencies.jacksonXml

// Testing
testImplementation Dependencies.jUnit5Api
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ object Dependencies {
const val androidPlugin = "com.android.tools.build:gradle:${Versions.androidPlugin}"
const val kotlinStandardLibrary = "org.jetbrains.kotlin:kotlin-stdlib"
const val kotlinPoet = "com.squareup:kotlinpoet:${Versions.kotlinPoet}"
const val jacksonXml = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${Versions.jackson}"

// Testing
const val jUnit5Api = "org.junit.jupiter:junit-jupiter-api:${Versions.jUnit5}"
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ object Versions {
// Plugin
const val androidPlugin = "3.5.0"
const val kotlinPoet = "1.4.4"
const val jackson = "2.12.3"

// Testing
const val jUnit5 = "5.3.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
package com.gaelmarhic.quadrant.helpers

import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
import com.fasterxml.jackson.dataformat.xml.XmlMapper
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector
import com.gaelmarhic.quadrant.models.manifest.Manifest
import com.gaelmarhic.quadrant.models.modules.ParsedManifest
import com.gaelmarhic.quadrant.models.modules.ParsedModule
import com.gaelmarhic.quadrant.models.modules.RawModule
import java.io.File
import javax.xml.bind.JAXBContext

class ManifestParsingHelper {

private val xmlMapper = initXmlMapper()
private val jaxbUnMarshaller = JAXBContext.newInstance(Manifest::class.java).createUnmarshaller()

fun parse(rawModules: List<RawModule>) =
rawModules
.map { it.parse() }

private fun initXmlMapper() =
XmlMapper().apply {
setAnnotationIntrospector(JaxbAnnotationIntrospector(typeFactory))
configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
}

private fun RawModule.parse() = ParsedModule(
name = name,
manifestList = manifestFiles.toManifestList()
Expand All @@ -32,8 +24,9 @@ class ManifestParsingHelper {
.map { it.toManifest() }

private fun File.toManifest() =
xmlMapper
.readValue(this, Manifest::class.java)
jaxbUnMarshaller
.unmarshal(this)
.let { it as Manifest }
.let {
ParsedManifest(
path = absolutePath,
Expand Down

0 comments on commit d2e1d5b

Please sign in to comment.