corda/samples/irs-demo/web/build.gradle
Stefano Franz a842740c9e
WIP Kubenetes parallel build (#5396)
* Split integration tests

* add simple example of printing all methods annotated with @Test

* add docker plugin to root project
remove docker plugin from child projects
add Dockerfile for image to use when testing
add task to build testing image to root project

* add comment describing proposed testing workflow

* simple attempt at running tests in docker container

* add my first k8s interaction script

* add fabric8 as dependnency to buildSrc

* before adding classpath

* collect reports from containers and run through testReports

* re-enable kubes backed testing

* for each project
1. add a list tests task
2. use this list tests task to modify the included tests
3. add a parallel version of the test task

* tweak logic for downloading test report XML files

* use output of parallel testing tasks in report tasks to determine build resultCode

* prepare for jenkins test

* prepare for jenkins test

* make docker reg password system property

* add logging to print out docker reg creds

* enable docker build

* fix gradle build file

* gather xml files into root project

* change log level for gradle modification

* stop printing gradle docker push passwd

* tidy up report generation

* fix compilation errors

* split signature constraints test into two

* change Sig constraint tests type hierarchy

* tidy up build.gradle

* try method based test includes

* add unit test for test listing

* fix  bug with test slicing

* stop filtering ignored tests to make the numbers match existing runs

* change log level to ensure print out

* move all plugin logic to buildSrc files

* tidy up test modification
add comments to explain what DistributedTesting plugin does

* move new plugins into properly named packages

* tidy up runConfigs

* fix compile errors due to merge with slow-integration-test work

* add system parameter to enable / disable build modification

* add -Dkubenetise to build command

* address review comments

* type safe declaration of parameters in KubesTest
2019-09-03 15:40:08 +00:00

173 lines
5.3 KiB
Groovy

import java.nio.charset.StandardCharsets
import java.nio.file.Files
import org.yaml.snakeyaml.DumperOptions
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.yaml:snakeyaml:1.24"
}
}
plugins {
id 'io.spring.dependency-management'
id 'com.craigburke.client-dependencies' version '1.4.0'
}
group = "${parent.group}.irs-demo"
dependencyManagement {
dependencies {
dependency "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
dependency "org.apache.logging.log4j:log4j-core:$log4j_version"
dependency "org.apache.logging.log4j:log4j-api:$log4j_version"
}
}
clientDependencies {
registry 'realBower', type:'bower', url:'https://registry.bower.io'
realBower {
"angular"("1.5.8")
"jquery"("^3.0.0")
"angular-route"("1.5.8")
"lodash"("^4.13.1")
"angular-fcsa-number"("^1.5.3")
"jquery.maskedinput"("^1.4.1")
"requirejs"("^2.2.0")
"semantic-ui"("^2.2.2", into: "semantic")
}
// put the JS dependencies into src directory so it can easily be referenced
// from HTML files in webapp frontend, useful for testing/development
// Note that this dir is added to .gitignore
installDir = 'src/main/resources/static/js/bower_components'
}
// Spring Boot plugin adds a numerous hardcoded dependencies in the version much lower then Corda expects
// causing the problems in runtime. Those can be changed by manipulating above properties
// See https://github.com/spring-gradle-plugins/dependency-management-plugin/blob/master/README.md#changing-the-value-of-a-version-property
ext['artemis.version'] = artemis_version
ext['hibernate.version'] = hibernate_version
ext['jackson.version'] = jackson_version
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'project-report'
apply plugin: 'application'
configurations {
demoArtifacts.extendsFrom testRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web') {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile('org.springframework.boot:spring-boot-starter-log4j2')
runtimeOnly("org.apache.logging.log4j:log4j-web:$log4j_version")
compile("com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version")
compile project(":client:rpc")
compile project(":client:jackson")
compile project(":finance:workflows")
// TODO In the future remove -irs bit from the directory name. Currently it clashes with :finance:workflows (same for contracts).
compile project(":samples:irs-demo:cordapp:workflows-irs")
testCompile project(":test-utils")
testCompile project(path: ":samples:irs-demo:cordapp:workflows-irs", configuration: "demoArtifacts")
// JOpt: for command line flags.
compile "net.sf.jopt-simple:jopt-simple:$jopt_simple_version"
testCompile('org.springframework.boot:spring-boot-starter-test') {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
}
jar {
from sourceSets.main.output
dependsOn clientInstall
}
def docker_dir = file("$project.buildDir/docker")
task deployWebapps(type: Copy, dependsOn: ['jar', 'bootRepackage']) {
ext.webappDir = file("build/webapps")
from(jar.outputs)
from("src/test/resources/scripts/") {
filter { it
.replace('#JAR_PATH#', jar.archiveName)
.replace('#DIR#', ext.webappDir.getAbsolutePath())
}
}
into ext.webappDir
}
task demoJar(type: Jar) {
classifier "test"
from sourceSets.test.output
}
artifacts {
demoArtifacts demoJar
}
task createDockerfile(type: com.bmuschko.gradle.docker.tasks.image.Dockerfile, dependsOn: [bootRepackage]) {
destFile = file("$docker_dir/Dockerfile")
from 'azul/zulu-openjdk-alpine:8u152'
copyFile jar.archiveName, "/opt/irs/web/"
workingDir "/opt/irs/web/"
defaultCommand "sh", "-c", "java -Dcorda.host=\$CORDA_HOST -jar ${jar.archiveName}"
}
task prepareDockerDir(type: Copy, dependsOn: [bootRepackage, createDockerfile]) {
from jar
into docker_dir
}
task generateDockerCompose(dependsOn: [prepareDockerDir]) {
def outFile = new File(project.buildDir, "docker-compose.yml")
ext['dockerComposePath'] = outFile
doLast {
def dockerComposeObject = [
"version": "3",
"services": [
"web-a": [
"build": "$docker_dir".toString(),
"environment": [
"CORDA_HOST": "bank-a:10003"
],
"ports": ["8080"]
],
"web-b": [
"build": "$docker_dir".toString(),
"environment": [
"CORDA_HOST": "bank-b:10003"
],
"ports": ["8080"]
]
]
]
def options = new org.yaml.snakeyaml.DumperOptions()
options.indent = 2
options.defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
def dockerComposeContent = new org.yaml.snakeyaml.Yaml(options).dump(dockerComposeObject)
Files.write(outFile.toPath(), dockerComposeContent.getBytes(StandardCharsets.UTF_8))
}
outputs.file(outFile)
}