From 3af5412d40ef59270fe2551313080837f099dd61 Mon Sep 17 00:00:00 2001 From: szymonsztuka Date: Thu, 21 Jun 2018 10:32:36 +0100 Subject: [PATCH] ENT-1741 Build standalone shell JAR distribution (#3409) --- build.gradle | 1 + settings.gradle | 1 + tools/shell-cli/build.gradle | 103 ++++++++++++++++++ .../net/corda/tools/shell/StandaloneShell.kt | 0 .../tools/shell/StandaloneShellArgsParser.kt | 0 .../shell/StandaloneShellArgsParserTest.kt | 0 .../shell-cli/src/test/resources/config.conf | 29 +++++ tools/shell/build.gradle | 15 +-- 8 files changed, 138 insertions(+), 11 deletions(-) create mode 100644 tools/shell-cli/build.gradle rename tools/{shell => shell-cli}/src/main/kotlin/net/corda/tools/shell/StandaloneShell.kt (100%) rename tools/{shell => shell-cli}/src/main/kotlin/net/corda/tools/shell/StandaloneShellArgsParser.kt (100%) rename tools/{shell => shell-cli}/src/test/kotlin/net/corda/tools/shell/StandaloneShellArgsParserTest.kt (100%) create mode 100644 tools/shell-cli/src/test/resources/config.conf diff --git a/build.gradle b/build.gradle index 02f3e87385..198880a657 100644 --- a/build.gradle +++ b/build.gradle @@ -351,6 +351,7 @@ bintrayConfig { 'corda-node-driver', 'corda-confidential-identities', 'corda-shell', + 'corda-shell-cli', 'corda-serialization', 'corda-serialization-deterministic', 'corda-tools-blob-inspector', diff --git a/settings.gradle b/settings.gradle index 14684e8962..9f1701e383 100644 --- a/settings.gradle +++ b/settings.gradle @@ -43,6 +43,7 @@ include 'tools:graphs' include 'tools:bootstrapper' include 'tools:blobinspector' include 'tools:shell' +include 'tools:shell-cli' include 'tools:network-bootstrapper' include 'example-code' project(':example-code').projectDir = file("$settingsDir/docs/source/example-code") diff --git a/tools/shell-cli/build.gradle b/tools/shell-cli/build.gradle new file mode 100644 index 0000000000..c1848107ab --- /dev/null +++ b/tools/shell-cli/build.gradle @@ -0,0 +1,103 @@ +buildscript { + + repositories { + mavenLocal() + mavenCentral() + jcenter() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' + } +} + +repositories { + mavenLocal() + mavenCentral() + jcenter() +} + +apply plugin: 'kotlin' +apply plugin: 'java' +apply plugin: 'application' +apply plugin: 'net.corda.plugins.publish-utils' +apply plugin: 'com.jfrog.artifactory' +apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: 'maven-publish' + +description 'Corda Shell CLI' + +configurations { + integrationTestCompile.extendsFrom testCompile + integrationTestRuntime.extendsFrom testRuntime +} + +sourceSets { + integrationTest { + kotlin { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + srcDir file('src/integration-test/kotlin') + } + resources { + srcDir file('src/integration-test/resources') + } + } + test { + resources { + srcDir file('src/test/resources') + } + } +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + + compile project(':tools:shell') + + // Unit testing helpers. + testCompile "junit:junit:$junit_version" + testCompile "org.assertj:assertj-core:${assertj_version}" + testCompile project(':test-utils') + testCompile project(':finance') + +} + +mainClassName = 'net.corda.tools.shell.StandaloneShellKt' + +jar { + baseName 'corda-shell-cli' +} + +processResources { + from file("$rootDir/config/dev/log4j2.xml") +} + +task integrationTest(type: Test) { + testClassesDirs = sourceSets.integrationTest.output.classesDirs + classpath = sourceSets.integrationTest.runtimeClasspath +} + +publishing { + publications { + shadow(MavenPublication) { publication -> + project.shadow.component(publication) + artifactId = "corda-tools-shell-cli" + } + } +} + +shadowJar { + //transform(de.sebastianboegl.gradle.plugins.shadow.transformers.Log4j2PluginsFileTransformer) + archiveName = "corda-shell-cli-${version}.jar" + + baseName = 'corda-shell-cli' + classifier = null + mainClassName = 'net.corda.tools.shell.StandaloneShellKt' + mergeServiceFiles() +} + +task buildShellCli(dependsOn: shadowJar) diff --git a/tools/shell/src/main/kotlin/net/corda/tools/shell/StandaloneShell.kt b/tools/shell-cli/src/main/kotlin/net/corda/tools/shell/StandaloneShell.kt similarity index 100% rename from tools/shell/src/main/kotlin/net/corda/tools/shell/StandaloneShell.kt rename to tools/shell-cli/src/main/kotlin/net/corda/tools/shell/StandaloneShell.kt diff --git a/tools/shell/src/main/kotlin/net/corda/tools/shell/StandaloneShellArgsParser.kt b/tools/shell-cli/src/main/kotlin/net/corda/tools/shell/StandaloneShellArgsParser.kt similarity index 100% rename from tools/shell/src/main/kotlin/net/corda/tools/shell/StandaloneShellArgsParser.kt rename to tools/shell-cli/src/main/kotlin/net/corda/tools/shell/StandaloneShellArgsParser.kt diff --git a/tools/shell/src/test/kotlin/net/corda/tools/shell/StandaloneShellArgsParserTest.kt b/tools/shell-cli/src/test/kotlin/net/corda/tools/shell/StandaloneShellArgsParserTest.kt similarity index 100% rename from tools/shell/src/test/kotlin/net/corda/tools/shell/StandaloneShellArgsParserTest.kt rename to tools/shell-cli/src/test/kotlin/net/corda/tools/shell/StandaloneShellArgsParserTest.kt diff --git a/tools/shell-cli/src/test/resources/config.conf b/tools/shell-cli/src/test/resources/config.conf new file mode 100644 index 0000000000..e4446f1ec9 --- /dev/null +++ b/tools/shell-cli/src/test/resources/config.conf @@ -0,0 +1,29 @@ +node { + addresses { + rpc { + host : "alocalhost" + port : 1234 + } + } + user : demo + password : abcd1234 +} +extensions { + cordapps { + path : "/x/y/cordapps" + } + sshd { + enabled : "true" + port : 2223 + } + commands { + path : /x/y/commands + } +} +ssl { + truststore { + path : "/x/y/truststore.jks" + type : "JKS" + password : "pass2" + } + } \ No newline at end of file diff --git a/tools/shell/build.gradle b/tools/shell/build.gradle index a2d0303273..a17ff17380 100644 --- a/tools/shell/build.gradle +++ b/tools/shell/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'kotlin' apply plugin: 'java' -apply plugin: 'application' apply plugin: 'net.corda.plugins.quasar-utils' apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'com.jfrog.artifactory' @@ -80,21 +79,15 @@ dependencies { integrationTestCompile project(':node-driver') } -mainClassName = 'net.corda.tools.shell.StandaloneShellKt' - -jar { - baseName 'corda-shell' -} - -processResources { - from file("$rootDir/config/dev/log4j2.xml") -} - task integrationTest(type: Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } +jar { + baseName 'corda-shell' +} + publish { name jar.baseName }