nuts-foundation/nuts-discovery

View on GitHub
build.gradle

Summary

Maintainability
Test Coverage
/*
 *     Nuts discovery service for bootstrapping the Nuts decentralised consent network.
 *     Copyright (C) 2019 Nuts community
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

buildscript {
    ext {
        kotlinVersion = '1.2.71'
        springBootVersion = '2.1.12.RELEASE'
        openApiPluginVersion = '3.3.4'
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
        classpath "org.openapitools:openapi-generator-gradle-plugin:$openApiPluginVersion"
    }
}

plugins {
    // Apply the Kotlin JVM plugin to add support for Kotlin on the JVM
    id 'org.jetbrains.kotlin.jvm' version '1.2.71'

    id 'io.spring.dependency-management' version '1.0.6.RELEASE'
}

ext {
    corda = '4.3'
    h2 = '1.4.200'
    generatedDir = 'src/main/generated'
}

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven {
        url "https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases/"
    }
}

apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'

sourceSets {
    main {
        kotlin {
            srcDirs += generatedDir
        }
    }
}

test.finalizedBy jacocoTestReport

// exclude unneeded libs
configurations {
    implementation {
        exclude group: 'com.github.bft-smart', module: 'library'
        exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
        exclude group: 'org.liquibase', module: 'liquibase-core'
    }

    testImplementation {
        exclude group: 'com.github.bft-smart', module: 'library'
        exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
    }
}

dependencies {
    // Use the Kotlin JDK 8 standard library
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'

    // spring boot
    implementation "org.springframework.boot:spring-boot-starter-data-rest"
    implementation "org.springframework.boot:spring-boot-starter-data-jpa"
    implementation "org.springframework.boot:spring-boot-starter-actuator"

    implementation "com.fasterxml.jackson.module:jackson-module-kotlin"

    // corda
    implementation("net.corda:corda-node:$corda") {
        exclude group: 'org.hibernate'
        exclude group: 'co.paralleluniverse'
        exclude group: 'com.github.corda.crash'
    }

    // db
    implementation("com.h2database:h2:$h2")
    implementation("org.flywaydb:flyway-core")


    // Use the Kotlin test library
    testImplementation 'org.jetbrains.kotlin:kotlin-test'

    // Use the Kotlin JUnit integration
    testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

    testImplementation("net.corda:corda-test-utils:$corda") {
        exclude group: 'com.github.corda.crash'
    }

    testImplementation("io.mockk:mockk:1.9.kotlin12")
    testImplementation("com.google.guava:guava:27.0-jre")
    testImplementation('org.springframework.boot:spring-boot-starter-test')

    annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
}

bootRun {
    environment SPRING_PROFILES_ACTIVE: environment.SPRING_PROFILES_ACTIVE ?: "default"
}

test {
    environment SPRING_PROFILES_ACTIVE: environment.SPRING_PROFILES_ACTIVE ?: "test"
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }
}

jacocoTestReport {
    sourceSets sourceSets.main
    reports {
        xml.enabled true
        html.enabled true
    }
}

apply plugin: 'org.openapi.generator'

task generateServerApiStub(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
    generatorName = "kotlin-spring"
    outputDir = "${project.rootDir}"
    inputSpec = "docs/_static/nuts-discovery.yaml"
    verbose = false
    apiPackage = "nl.nuts.discovery.api"
    modelPackage = "nl.nuts.discovery.model"
    invokerPackage = "nl.nuts.discovery"
    generateApiDocumentation = false
    generateModelDocumentation = false
    generateModelTests = false
    generateApiTests = false
    withXml = false
    configOptions = [
            dateLibrary: "java8",
            serviceInterface: true,
            exceptionHandler: true,
            gradleBuildFile: false,
            supportingFiles: [],
            sourceFolder: "src/main/generated"
    ]
    skipOverwrite = false
}