Skip to content

Commit

Permalink
Merge branch 'release/5.2' into merge-release/5.1-release/5.2-2023-11…
Browse files Browse the repository at this point in the history
…-13-1
  • Loading branch information
ronanbrowne authored Nov 13, 2023
2 parents 2c4728c + cacb7c1 commit d092eb8
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 16 deletions.
9 changes: 4 additions & 5 deletions .ci/JenkinsfileMergeAutomation
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! groovy
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

/**
* Forward merge any changes in current branch to the branch with following version.
Expand All @@ -14,19 +14,18 @@
* the branch name of origin branch, it should match the current branch
* and it acts as a fail-safe inside {@code forwardMerger} pipeline
*/
String originBranch = 'release/5.1'
String originBranch = 'release/5.2'

/**
* the branch name of target branch, it should be the branch with the next version
* after the one in current branch.
*/
String targetBranch = 'release/5.2'
String targetBranch = 'release/5.3'

/**
* Forward merge any changes between {@code originBranch} and {@code targetBranch}
*/
forwardMerger(
targetBranch: targetBranch,
originBranch: originBranch,
slackChannel: '#c5-forward-merge-bot-notifications'
)
slackChannel: '#c5-forward-merge-bot-notifications')
2 changes: 1 addition & 1 deletion .ci/JenkinsfileSnykDelta
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

snykDelta(
snykOrgId: 'corda5-snyk-org-id',
Expand Down
5 changes: 2 additions & 3 deletions .ci/nightly/JenkinsfileNightly
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaPipelineKubernetesAgent(
runIntegrationTests: false,
dailyBuildCron: 'H 02 * * *',
publishOSGiImage: true,
gradleAdditionalArgs: '-Dscan.tag.Nightly-Build',
generateSbom: true,
javaVersion: '17',
workerBaseImageTag: '17.0.4.1-17.36.17'
javaVersion: '17'
)
2 changes: 1 addition & 1 deletion .ci/nightly/JenkinsfileSnykScan
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaSnykScanPipeline (
snykTokenId: 'r3-snyk-corda5',
Expand Down
2 changes: 1 addition & 1 deletion .ci/nightly/JenkinsfileWindowsCompatibility
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

windowsCompatibility(
runIntegrationTests: false,
Expand Down
8 changes: 7 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
* @driessamyn @jasonbyrner3 @dimosr @ronanbrowne @rick-r3 @simon-johnson-r3 @blsemo @Omar-awad @aditisdesai @vinir3 @vkolomeyko @thiagoviana @Sakpal
* @corda/rest
# Build scripts should be audited by BLT
*.gradle @corda/blt
gradle.properties @corda/corda5-team-leads
Jenkinsfile @corda/blt
.ci/* @corda/blt
gradle/* @corda/blt
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaPipelineKubernetesAgent(
runIntegrationTests: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.corda.cli.api

import picocli.CommandLine.IVersionProvider
import java.util.jar.Manifest

/**
* An abstract class that will read version information out of the plugin manifest.
*
* Builds version information using these attributes:
* - Plugin-Name
* - Plugin-Version
* - Plugin-Provider
* - Plugin-Git-Commit
*
* To apply, inherit from this class:
*
* class VersionProvider : AbstractCordaCliVersionProvider()
*
* Then add to your command annotation:
*
* versionProvider = VersionProvider::class
*/
abstract class AbstractCordaCliVersionProvider : IVersionProvider {
override fun getVersion(): Array<String> = this.javaClass
.getResourceAsStream("/META-INF/MANIFEST.MF")
?.use {
Manifest(it).mainAttributes.run {
arrayOf(
"${getValue("Plugin-Name")} ${getValue("Plugin-Version")}",
"Provider: ${getValue("Plugin-Provider")}",
"Commit ID: ${getValue("Plugin-Git-Commit")}"
)
}
} ?: emptyArray()
}
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ def cordaCLi = tasks.named('jar', Jar) {
}
from(mergeLog4j2Plugins)

var cliHostCommitId = com.gradle.Utils.execAndGetStdOut "git", "rev-parse", "--verify", "HEAD"

manifest {
attributes["Main-Class"] = appMainClass
attributes["Multi-Release"] = true
attributes["Plugin-Name"] = "Corda CLI"
attributes["Plugin-Version"] = "${project.version}"
attributes["Plugin-Provider"] = "R3"
attributes["Plugin-Git-Commit"] = "$cliHostCommitId"
}

archiveBaseName = 'corda-cli'
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/kotlin/net/corda/cli/application/Boot.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.corda.cli.application

import net.corda.cli.api.CordaCliPlugin
import net.corda.cli.api.AbstractCordaCliVersionProvider
import net.corda.cli.application.logger.LoggerStream
import org.pf4j.CompoundPluginDescriptorFinder
import org.pf4j.DefaultPluginManager
Expand All @@ -14,13 +15,19 @@ fun main(vararg args: String) {
Boot.run(*args)
}

class VersionProvider : AbstractCordaCliVersionProvider()

@CommandLine.Command(
name = "corda-cli"
name = "corda-cli",
versionProvider = VersionProvider::class
)
class App {
@CommandLine.Option(names = ["-h", "--help", "-?", "-help"], usageHelp = true, description = ["Display help and exit."])
@Suppress("unused")
var help = false

@CommandLine.Option(names = ["-V", "--version"], versionHelp = true, description = ["Display version and exit"])
var showVersion = false
}

/**
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.stdlib.default.dependency=false

# The version of cli-host we will publish
cliHostVersion=5.1.0
cliHostVersion=5.2.0

# PF4J
pf4jVersion=3.10.0
Expand Down
4 changes: 4 additions & 0 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ subprojects { subProject ->

archiveBaseName = "plugin-${subProject.pluginId}"

var commitId = com.gradle.Utils.execAndGetStdOut "git", "rev-parse", "--verify", "HEAD"

manifest {
attributes['Plugin-Class'] = subProject.pluginClass
attributes["Plugin-Name"] = subProject.pluginId
attributes['Plugin-Id'] = subProject.pluginId
attributes['Plugin-Version'] = archiveVersion
attributes['Plugin-Provider'] = subProject.pluginProvider
attributes['Plugin-Description'] = subProject.pluginDescription
attributes["Plugin-Git-Commit"] = "$commitId"
}

from sourceSets.main.output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.corda.cli.plugins.examples
import org.pf4j.Extension
import org.pf4j.Plugin
import net.corda.cli.api.CordaCliPlugin
import net.corda.cli.api.AbstractCordaCliVersionProvider
import picocli.CommandLine

/**
Expand All @@ -16,12 +17,15 @@ class ExamplePlugin : Plugin() {
override fun stop() {
}

class VersionProvider : AbstractCordaCliVersionProvider()

@Extension
@CommandLine.Command(
name = "example-plugin",
subcommands = [SubCommandOne::class],
description = ["Example plugin using class based subcommands"],
mixinStandardHelpOptions = true
mixinStandardHelpOptions = true,
versionProvider = VersionProvider::class
)
class ExamplePluginEntry : CordaCliPlugin
}
8 changes: 8 additions & 0 deletions plugins/example/src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Main-Class: net.corda.cli.application.BootKt
Multi-Release: true
Plugin-Name: Corda CLI
Plugin-Version: 5.1.0-TEST
Plugin-Provider: R3
Plugin-Git-Commit: TEST

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.corda.cli.plugins.examples

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import picocli.CommandLine
import java.io.ByteArrayOutputStream
Expand Down Expand Up @@ -61,6 +63,18 @@ class ExamplePluginTest {
) { outText }
}

@Test
fun testVersionOption() {

val app = ExamplePlugin.ExamplePluginEntry()

val outText = tapSystemOut {
CommandLine(app).execute("--version")
}

assertEquals("Corda CLI 5.1.0-TEST\nProvider: R3\nCommit ID: TEST\n", outText)
}

@Test
fun testSubCommand() {

Expand Down

0 comments on commit d092eb8

Please sign in to comment.