From f273d894efe369335b43612c23de329fb58a107a Mon Sep 17 00:00:00 2001 From: fowlerrr Date: Thu, 23 May 2019 18:22:56 +0100 Subject: [PATCH] Extract jackson dependency from finance-workflows (#5163) Extract jackson dependency from finance-workflows and move it to IRS Demo where it is actually needed --- docs/source/changelog.rst | 8 ++++++++ .../net/corda/finance/contracts/FinanceTypesTest.kt | 2 +- finance/workflows/build.gradle | 3 --- .../finance/workflows/utils/FinanceWorkflowsUtils.kt | 4 +++- .../src/test/kotlin/net/corda/irs/contract/IRSTests.kt | 2 +- samples/irs-demo/cordapp/workflows-irs/build.gradle | 2 ++ .../main/kotlin/net.corda.irs/api/NodeInterestRates.kt | 2 +- .../net.corda.irs/flows}/plugin/FinanceJSONSupport.kt | 6 +++--- .../integration-test/kotlin/net/corda/irs/IRSDemoTest.kt | 2 +- .../kotlin/net/corda/irs/web/IrsDemoWebApplication.kt | 2 +- .../main/kotlin/net/corda/vega/webplugin/SimmPlugin.kt | 3 --- 11 files changed, 21 insertions(+), 15 deletions(-) rename {finance/workflows/src/main/kotlin/net/corda/finance/workflows => samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/flows}/plugin/FinanceJSONSupport.kt (94%) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index bb05dc192c..0a66c76efe 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -4,6 +4,14 @@ Changelog Here's a summary of what's changed in each Corda release. For guidance on how to upgrade code from the previous release, see :doc:`app-upgrade-notes`. +.. _changelog_v5.0: + +Version 5.0 +----------- + +* Removed ``finance-workflows`` dependency on jackson library. The functions that used jackson (e.g. ``FinanceJSONSupport``) have been moved + into IRS Demo. + .. _changelog_v4.2: Version 4.2 diff --git a/finance/contracts/src/test/kotlin/net/corda/finance/contracts/FinanceTypesTest.kt b/finance/contracts/src/test/kotlin/net/corda/finance/contracts/FinanceTypesTest.kt index da2f1b1912..2b88126ec0 100644 --- a/finance/contracts/src/test/kotlin/net/corda/finance/contracts/FinanceTypesTest.kt +++ b/finance/contracts/src/test/kotlin/net/corda/finance/contracts/FinanceTypesTest.kt @@ -1,6 +1,6 @@ package net.corda.finance.contracts -import loadTestCalendar +import net.corda.finance.workflows.utils.loadTestCalendar import org.junit.Test import java.time.LocalDate import kotlin.test.assertEquals diff --git a/finance/workflows/build.gradle b/finance/workflows/build.gradle index 4ccd18a4f8..c2126546f7 100644 --- a/finance/workflows/build.gradle +++ b/finance/workflows/build.gradle @@ -37,9 +37,6 @@ dependencies { cordapp project(':finance:contracts') - // For JSON - compile "com.fasterxml.jackson.core:jackson-databind:${jackson_version}" - testCompile project(':test-utils') testCompile project(path: ':core', configuration: 'testArtifacts') diff --git a/finance/workflows/src/main/kotlin/net/corda/finance/workflows/utils/FinanceWorkflowsUtils.kt b/finance/workflows/src/main/kotlin/net/corda/finance/workflows/utils/FinanceWorkflowsUtils.kt index c39097f6de..67ab537dc8 100644 --- a/finance/workflows/src/main/kotlin/net/corda/finance/workflows/utils/FinanceWorkflowsUtils.kt +++ b/finance/workflows/src/main/kotlin/net/corda/finance/workflows/utils/FinanceWorkflowsUtils.kt @@ -1,3 +1,5 @@ +package net.corda.finance.workflows.utils + import net.corda.core.flows.FlowException import net.corda.core.serialization.CordaSerializable import net.corda.finance.contracts.BusinessCalendar @@ -5,7 +7,7 @@ import net.corda.finance.contracts.BusinessCalendar val TEST_CALENDAR_NAMES = listOf("London", "NewYork") fun loadTestCalendar(name: String): BusinessCalendar { - val stream = UnknownCalendar::class.java.getResourceAsStream("net/corda/finance/workflows/utils/${name}HolidayCalendar.txt") ?: throw UnknownCalendar(name) + val stream = UnknownCalendar::class.java.getResourceAsStream("/net/corda/finance/workflows/utils/${name}HolidayCalendar.txt") ?: throw UnknownCalendar(name) return stream.use { BusinessCalendar(stream.reader().readText().split(",").map { BusinessCalendar.parseDateFromString(it) }.toSortedSet()) } diff --git a/samples/irs-demo/cordapp/contracts-irs/src/test/kotlin/net/corda/irs/contract/IRSTests.kt b/samples/irs-demo/cordapp/contracts-irs/src/test/kotlin/net/corda/irs/contract/IRSTests.kt index e3cf3dd58e..8cc8b0f576 100644 --- a/samples/irs-demo/cordapp/contracts-irs/src/test/kotlin/net/corda/irs/contract/IRSTests.kt +++ b/samples/irs-demo/cordapp/contracts-irs/src/test/kotlin/net/corda/irs/contract/IRSTests.kt @@ -3,7 +3,6 @@ package net.corda.irs.contract import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.mock import com.nhaarman.mockito_kotlin.whenever -import loadTestCalendar import net.corda.core.contracts.Amount import net.corda.core.contracts.UniqueIdentifier import net.corda.core.crypto.generateKeyPair @@ -15,6 +14,7 @@ import net.corda.core.utilities.seconds import net.corda.finance.DOLLARS import net.corda.finance.EUR import net.corda.finance.contracts.* +import net.corda.finance.workflows.utils.loadTestCalendar import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.common.internal.addNotary import net.corda.testing.common.internal.testNetworkParameters diff --git a/samples/irs-demo/cordapp/workflows-irs/build.gradle b/samples/irs-demo/cordapp/workflows-irs/build.gradle index f140c3d4e1..46c493f132 100644 --- a/samples/irs-demo/cordapp/workflows-irs/build.gradle +++ b/samples/irs-demo/cordapp/workflows-irs/build.gradle @@ -14,6 +14,8 @@ dependencies { // Corda integration dependencies cordaCompile project(':core') + + compile("com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version") // only included to control the `DemoClock` as part of the demo application // normally `:node` should not be depended on in any CorDapps diff --git a/samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/api/NodeInterestRates.kt b/samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/api/NodeInterestRates.kt index b1a7e500b3..494f49662c 100644 --- a/samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/api/NodeInterestRates.kt +++ b/samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/api/NodeInterestRates.kt @@ -1,7 +1,6 @@ package net.corda.irs.api import co.paralleluniverse.fibers.Suspendable -import loadTestCalendar import net.corda.core.contracts.Command import net.corda.core.crypto.TransactionSignature import net.corda.core.flows.* @@ -16,6 +15,7 @@ import net.corda.finance.contracts.BusinessCalendar import net.corda.finance.contracts.Fix import net.corda.finance.contracts.FixOf import net.corda.finance.contracts.Tenor +import net.corda.finance.workflows.utils.loadTestCalendar import net.corda.irs.flows.RatesFixFlow import net.corda.irs.math.CubicSplineInterpolator import net.corda.irs.math.Interpolator diff --git a/finance/workflows/src/main/kotlin/net/corda/finance/workflows/plugin/FinanceJSONSupport.kt b/samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/flows/plugin/FinanceJSONSupport.kt similarity index 94% rename from finance/workflows/src/main/kotlin/net/corda/finance/workflows/plugin/FinanceJSONSupport.kt rename to samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/flows/plugin/FinanceJSONSupport.kt index c077b50bb1..78daf61170 100644 --- a/finance/workflows/src/main/kotlin/net/corda/finance/workflows/plugin/FinanceJSONSupport.kt +++ b/samples/irs-demo/cordapp/workflows-irs/src/main/kotlin/net.corda.irs/flows/plugin/FinanceJSONSupport.kt @@ -1,17 +1,17 @@ @file:JvmName("FinanceJSONSupport") -package net.corda.finance.workflows.plugin +package net.corda.irs.flows.plugin -import TEST_CALENDAR_NAMES import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.JsonParseException import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.* import com.fasterxml.jackson.databind.deser.std.StringArrayDeserializer import com.fasterxml.jackson.databind.module.SimpleModule -import loadTestCalendar import net.corda.finance.contracts.BusinessCalendar import net.corda.finance.contracts.Expression +import net.corda.finance.workflows.utils.TEST_CALENDAR_NAMES +import net.corda.finance.workflows.utils.loadTestCalendar import java.time.LocalDate import java.util.* diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt index 32dd408ef6..5d0b5c7748 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt @@ -19,7 +19,7 @@ import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.contextLogger import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.seconds -import net.corda.finance.workflows.plugin.registerFinanceJSONMappers +import net.corda.irs.flows.plugin.registerFinanceJSONMappers import net.corda.irs.contract.InterestRateSwap import net.corda.irs.web.IrsDemoWebApplication import net.corda.test.spring.springDriver diff --git a/samples/irs-demo/web/src/main/kotlin/net/corda/irs/web/IrsDemoWebApplication.kt b/samples/irs-demo/web/src/main/kotlin/net/corda/irs/web/IrsDemoWebApplication.kt index 9e93b0bbe6..40ec768f76 100644 --- a/samples/irs-demo/web/src/main/kotlin/net/corda/irs/web/IrsDemoWebApplication.kt +++ b/samples/irs-demo/web/src/main/kotlin/net/corda/irs/web/IrsDemoWebApplication.kt @@ -6,7 +6,7 @@ import net.corda.client.rpc.CordaRPCClient import net.corda.client.rpc.RPCException import net.corda.core.messaging.CordaRPCOps import net.corda.core.utilities.NetworkHostAndPort -import net.corda.finance.workflows.plugin.registerFinanceJSONMappers +import net.corda.irs.flows.plugin.registerFinanceJSONMappers import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/webplugin/SimmPlugin.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/webplugin/SimmPlugin.kt index 9c235b303b..c98cad2742 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/webplugin/SimmPlugin.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/webplugin/SimmPlugin.kt @@ -1,8 +1,6 @@ package net.corda.vega.webplugin -import com.fasterxml.jackson.databind.ObjectMapper import net.corda.core.serialization.SerializationWhitelist -import net.corda.finance.workflows.plugin.registerFinanceJSONMappers import net.corda.vega.api.PortfolioApi import net.corda.webserver.services.WebServerPluginRegistry import java.util.function.Function @@ -16,5 +14,4 @@ import java.util.function.Function class SimmPlugin : WebServerPluginRegistry { override val webApis = listOf(Function(::PortfolioApi)) override val staticServeDirs: Map = emptyMap() - override fun customizeJSONSerialization(om: ObjectMapper): Unit = registerFinanceJSONMappers(om) }