corda/node-schemas/build.gradle

72 lines
2.1 KiB
Groovy
Raw Normal View History

apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: 'net.corda.plugins.publish-utils'
description 'Corda node database schemas'
repositories {
mavenLocal()
mavenCentral()
maven {
url 'http://oss.sonatype.org/content/repositories/snapshots'
}
jcenter()
maven {
url 'https://dl.bintray.com/kotlin/exposed'
}
}
// Kapt plugin is hardcoded in output directory and sourcesets. Use a separate sourceset to keep the generated
// files in git and outside of the build directory (to avoid cleaning issues)
sourceSets {
main {
kotlin {
srcDir "${buildDir}/generated/source/kapt/main/"
}
}
generated {
java {
srcDir "${projectDir}/generated/source/kapt/main/"
}
}
}
dependencies {
compile project(':core')
// Requery: SQL based query & persistence for Kotlin
kapt "io.requery:requery-processor:$requery_version"
// For H2 database support in persistence
testCompile "com.h2database:h2:1.4.193"
}
// Generated files will be removed by gradle clean. Since we aren't running kapt every time we must preserve these files
// Note: The lines that actually invoke kapt are those in the project.afterEvaluate block.
task buildKapt(type: Copy) {
from "${buildDir}/generated"
into "${projectDir}/generated"
}
// Kapt hijacks anything named "compile"
task buildGenerated(type: JavaCompile) {
source = sourceSets.generated.allJava
classpath = sourceSets.generated.compileClasspath + sourceSets.main.compileClasspath + sourceSets.main.output
destinationDir = file("$buildDir/classes/generated")
}
// Remove the dependency on compile in kapt to avoid automatic kapt running - run :node-schemas:kaptKotlin explicitly.
project.afterEvaluate {
jar.dependsOn.each { jar.dependsOn.remove it }
buildGenerated.dependsOn.each { buildGenerated.dependsOn.remove it }
jar.dependsOn buildGenerated
buildGenerated.dependsOn classes
compileKotlin.dependsOn.remove kaptKotlin
buildKapt.dependsOn kaptKotlin
buildKapt.mustRunAfter kaptKotlin
}
jar {
from sourceSets.generated.output
}