CORDA-3644: Add Corda-Testing tag to test artifacts' MANIFEST.MF. (#6032)

This commit is contained in:
Rick Parker 2020-03-05 17:39:55 +00:00 committed by GitHub
parent 60a74c0399
commit e5a8888232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 70 additions and 11 deletions

View File

@ -29,7 +29,13 @@ dependencies {
jar {
baseName 'corda-mock'
manifest {
attributes 'Automatic-Module-Name': 'net.corda.client.mock'
attributes(
'Automatic-Module-Name': 'net.corda.client.mock',
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
'Corda-Testing': true
)
}
}

View File

@ -13,6 +13,11 @@ dependencies {
compile project(":core")
}
jar{
jar {
baseName "testing-dbfailure-contracts"
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}

View File

@ -7,6 +7,11 @@ dependencies {
compile project(":testing:cordapps:dbfailure:dbfcontracts")
}
jar{
jar {
baseName "testing-dbfailure-workflows"
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}

View File

@ -66,6 +66,11 @@ task integrationTest(type: Test) {
jar {
baseName 'corda-node-driver'
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}
publish {

View File

@ -1,3 +1,4 @@
@file:Suppress("TooManyFunctions")
package net.corda.testing.node.internal
import co.paralleluniverse.fibers.instrument.JavaAgent
@ -112,6 +113,7 @@ import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
import java.util.concurrent.atomic.AtomicInteger
import java.util.jar.JarInputStream
import java.util.jar.Manifest
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.collections.HashSet
@ -806,6 +808,8 @@ class DriverDSLImpl(
Permissions.invokeRpc(CordaRPCOps::killFlow)
)
private const val CORDA_TESTING_ATTRIBUTE = "Corda-Testing"
private val CORDAPP_MANIFEST_ATTRIBUTES: List<String> = unmodifiableList(listOf(
CORDAPP_CONTRACT_NAME,
CORDAPP_CONTRACT_LICENCE,
@ -952,7 +956,7 @@ class DriverDSLImpl(
val cpPathEntry = Paths.get(cpEntry)
cpPathEntry.isRegularFile()
&& !isTestArtifact(cpPathEntry.fileName.toString())
&& !cpPathEntry.isCorDapp
&& !cpPathEntry.isExcludedJar
}
return ProcessUtilities.startJavaProcess(
@ -980,12 +984,21 @@ class DriverDSLImpl(
|| name.startsWith("mockito")
}
// Identify Corda's own testing framework by attribute in MANIFEST.MF.
private fun isTestArtifact(manifest: Manifest): Boolean {
return manifest[CORDA_TESTING_ATTRIBUTE] != null
}
// Identify CorDapp JARs by their attributes in MANIFEST.MF.
private val Path.isCorDapp: Boolean get() {
private fun isCordapp(manifest: Manifest): Boolean {
return CORDAPP_MANIFEST_ATTRIBUTES.any { manifest[it] != null }
|| (manifest[TARGET_PLATFORM_VERSION] != null && manifest[MIN_PLATFORM_VERSION] != null)
}
private val Path.isExcludedJar: Boolean get() {
return JarInputStream(Files.newInputStream(this).buffered()).use { jar ->
val manifest = jar.manifest ?: return false
CORDAPP_MANIFEST_ATTRIBUTES.any { manifest[it] != null }
|| (manifest[TARGET_PLATFORM_VERSION] != null && manifest[MIN_PLATFORM_VERSION] != null)
isCordapp(manifest) || isTestArtifact(manifest)
}
}

View File

@ -7,3 +7,11 @@ dependencies {
compile project(':test-common')
compile project(':client:rpc')
}
tasks.named('jar', Jar) {
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}

View File

@ -14,10 +14,12 @@ dependencies {
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junit_vintage_version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_jupiter_version}"
testRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}"
}
compileKotlin {
kotlinOptions {
languageVersion = "1.2"
tasks.named('jar', Jar) {
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}

View File

@ -25,6 +25,11 @@ dependencies {
jar {
baseName 'corda-test-common'
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}
publish {

View File

@ -16,6 +16,11 @@ dependencies {
jar {
baseName 'corda-test-db'
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}
publish {

View File

@ -36,6 +36,11 @@ dependencies {
jar {
baseName 'corda-test-utils'
manifest {
// This JAR is part of Corda's testing framework.
// Driver will not include it as part of an out-of-process node.
attributes('Corda-Testing': true)
}
}
publish {