mirror of
https://github.com/corda/corda.git
synced 2024-12-21 13:57:54 +00:00
Merged in sort-of-incremental-quasarScan (pull request #154)
Sort of incremental quasarscan
This commit is contained in:
commit
f06487aa4c
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,6 +18,9 @@ tags
|
||||
/core/build
|
||||
/docs/build/doctrees
|
||||
|
||||
# gradle's buildSrc build/
|
||||
/buildSrc/build/
|
||||
|
||||
# This exists only in the internal repo
|
||||
/network-explorer/build
|
||||
|
||||
|
46
build.gradle
46
build.gradle
@ -5,6 +5,7 @@ apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'application'
|
||||
apply plugin: 'project-report'
|
||||
apply plugin: QuasarPlugin
|
||||
|
||||
allprojects {
|
||||
sourceCompatibility = 1.8
|
||||
@ -41,8 +42,6 @@ repositories {
|
||||
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
configurations {
|
||||
quasar
|
||||
|
||||
// we don't want isolated.jar in classPath, since we want to test jar being dynamically loaded as an attachment
|
||||
runtime.exclude module: 'isolated'
|
||||
}
|
||||
@ -58,32 +57,11 @@ dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
||||
compile "org.jetbrains.kotlinx:kotlinx-support-jdk8:0.1"
|
||||
|
||||
// Quasar: for the bytecode rewriting for state machines.
|
||||
quasar "co.paralleluniverse:quasar-core:${quasar_version}:jdk8@jar"
|
||||
|
||||
// Unit testing helpers.
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.assertj:assertj-core:3.4.1'
|
||||
}
|
||||
|
||||
// These lines tell Gradle to add a couple of JVM command line arguments to unit test and program runs, which set up
|
||||
// the Quasar bytecode rewriting system so fibers can be suspended. The verifyInstrumentation line makes things run
|
||||
// slower but you get a much better error message if you forget to annotate a method with @Suspendable that needs it.
|
||||
//
|
||||
// In Java 9 (hopefully) the requirement to annotate methods as @Suspendable will go away.
|
||||
|
||||
applicationDefaultJvmArgs = ["-javaagent:${configurations.quasar.singleFile}"]
|
||||
mainClassName = 'com.r3corda.demos.TraderDemoKt'
|
||||
|
||||
tasks.withType(Test) {
|
||||
jvmArgs "-javaagent:${configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
tasks.withType(JavaExec) {
|
||||
jvmArgs "-javaagent:${configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
|
||||
// Package up the demo programs.
|
||||
task getRateFixDemo(type: CreateStartScripts) {
|
||||
mainClassName = "com.r3corda.demos.RateFixDemoKt"
|
||||
@ -121,27 +99,7 @@ tasks.withType(CreateStartScripts)
|
||||
}
|
||||
}
|
||||
|
||||
// These lines tell gradle to run the Quasar suspendables scanner to look for unannotated super methods
|
||||
// that have @Suspendable sub implementations. These tend to cause NPEs and are not caught by the verifier
|
||||
// NOTE: need to make sure the output isn't on the classpath or every other run it generates empty results, so
|
||||
// we explicitly delete to avoid that happening. We also need to turn off what seems to be a spurious warning in the IDE
|
||||
//
|
||||
// TODO: Make this task incremental, as it can be quite slow.
|
||||
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
task quasarScan(dependsOn: ['classes', 'core:classes', 'contracts:classes', 'node:classes']) << {
|
||||
ant.taskdef(name:'scanSuspendables', classname:'co.paralleluniverse.fibers.instrument.SuspendablesScanner',
|
||||
classpath: "${sourceSets.main.output.classesDir}:${sourceSets.main.output.resourcesDir}:${configurations.runtime.asPath}")
|
||||
delete "$sourceSets.main.output.resourcesDir/META-INF/suspendables", "$sourceSets.main.output.resourcesDir/META-INF/suspendable-supers"
|
||||
ant.scanSuspendables(
|
||||
auto:false,
|
||||
suspendablesFile: "$sourceSets.main.output.resourcesDir/META-INF/suspendables",
|
||||
supersFile: "$sourceSets.main.output.resourcesDir/META-INF/suspendable-supers") {
|
||||
fileset(dir: sourceSets.main.output.classesDir)
|
||||
}
|
||||
}
|
||||
|
||||
jar.dependsOn quasarScan
|
||||
quasarScan.dependsOn('classes', 'core:classes', 'contracts:classes', 'node:classes')
|
||||
|
||||
applicationDistribution.into("bin") {
|
||||
from(getRateFixDemo)
|
||||
|
57
buildSrc/src/main/groovy/QuasarPlugin.groovy
Normal file
57
buildSrc/src/main/groovy/QuasarPlugin.groovy
Normal file
@ -0,0 +1,57 @@
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
|
||||
/**
|
||||
* QuasarPlugin creates a "quasar" configuration, adds quasar as a dependency and creates a "quasarScan" task that scans
|
||||
* for `@Suspendable`s in the code
|
||||
*/
|
||||
class QuasarPlugin implements Plugin<Project> {
|
||||
void apply(Project project) {
|
||||
|
||||
project.repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
project.configurations.create("quasar")
|
||||
// To add a local .jar dependency:
|
||||
// project.dependencies.add("quasar", project.files("${project.rootProject.projectDir}/lib/quasar.jar"))
|
||||
project.dependencies.add("quasar", "co.paralleluniverse:quasar-core:${project.rootProject.ext.quasar_version}:jdk8@jar")
|
||||
project.dependencies.add("compile", project.configurations.getByName("quasar"))
|
||||
|
||||
project.tasks.withType(Test) {
|
||||
jvmArgs "-javaagent:${project.configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
project.tasks.withType(JavaExec) {
|
||||
jvmArgs "-javaagent:${project.configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
|
||||
project.task("quasarScan") {
|
||||
inputs.files(project.sourceSets.main.output)
|
||||
outputs.files(
|
||||
"$project.sourceSets.main.output.resourcesDir/META-INF/suspendables",
|
||||
"$project.sourceSets.main.output.resourcesDir/META-INF/suspendable-supers"
|
||||
)
|
||||
} << {
|
||||
|
||||
// These lines tell gradle to run the Quasar suspendables scanner to look for unannotated super methods
|
||||
// that have @Suspendable sub implementations. These tend to cause NPEs and are not caught by the verifier
|
||||
// NOTE: need to make sure the output isn't on the classpath or every other run it generates empty results, so
|
||||
// we explicitly delete to avoid that happening. We also need to turn off what seems to be a spurious warning in the IDE
|
||||
ant.taskdef(name:'scanSuspendables', classname:'co.paralleluniverse.fibers.instrument.SuspendablesScanner',
|
||||
classpath: "${project.sourceSets.main.output.classesDir}:${project.sourceSets.main.output.resourcesDir}:${project.configurations.runtime.asPath}")
|
||||
project.delete "$project.sourceSets.main.output.resourcesDir/META-INF/suspendables", "$project.sourceSets.main.output.resourcesDir/META-INF/suspendable-supers"
|
||||
ant.scanSuspendables(
|
||||
auto:false,
|
||||
suspendablesFile: "$project.sourceSets.main.output.resourcesDir/META-INF/suspendables",
|
||||
supersFile: "$project.sourceSets.main.output.resourcesDir/META-INF/suspendable-supers") {
|
||||
fileset(dir: project.sourceSets.main.output.classesDir)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
project.jar.dependsOn project.quasarScan
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ version '1.0-SNAPSHOT'
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: QuasarPlugin
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@ -21,11 +22,6 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
configurations {
|
||||
quasar
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.assertj:assertj-core:3.4.1'
|
||||
@ -57,9 +53,6 @@ dependencies {
|
||||
compile "com.esotericsoftware:kryo:3.0.3"
|
||||
compile "de.javakaffee:kryo-serializers:0.37"
|
||||
|
||||
// Quasar: for the bytecode rewriting for state machines.
|
||||
compile "co.paralleluniverse:quasar-core:${quasar_version}:jdk8"
|
||||
|
||||
// Apache JEXL: An embeddable expression evaluation library.
|
||||
// This may be temporary until we experiment with other ways to do on-the-fly contract specialisation via an API.
|
||||
compile "org.apache.commons:commons-jexl3:3.0"
|
||||
@ -69,40 +62,6 @@ dependencies {
|
||||
|
||||
// Java ed25519 implementation. See https://github.com/str4d/ed25519-java/
|
||||
compile 'net.i2p.crypto:eddsa:0.1.0'
|
||||
|
||||
// Quasar: for the bytecode rewriting for state machines.
|
||||
quasar "co.paralleluniverse:quasar-core:${quasar_version}:jdk8@jar"
|
||||
}
|
||||
|
||||
|
||||
tasks.withType(Test) {
|
||||
jvmArgs "-javaagent:${configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
tasks.withType(JavaExec) {
|
||||
jvmArgs "-javaagent:${configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
|
||||
|
||||
// These lines tell gradle to run the Quasar suspendables scanner to look for unannotated super methods
|
||||
// that have @Suspendable sub implementations. These tend to cause NPEs and are not caught by the verifier
|
||||
// NOTE: need to make sure the output isn't on the classpath or every other run it generates empty results, so
|
||||
// we explicitly delete to avoid that happening. We also need to turn off what seems to be a spurious warning in the IDE
|
||||
//
|
||||
// TODO: Make this task incremental, as it can be quite slow.
|
||||
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
task quasarScan(dependsOn: ['classes']) << {
|
||||
ant.taskdef(name:'scanSuspendables', classname:'co.paralleluniverse.fibers.instrument.SuspendablesScanner',
|
||||
classpath: "${sourceSets.main.output.classesDir}:${sourceSets.main.output.resourcesDir}:${configurations.runtime.asPath}")
|
||||
delete "$sourceSets.main.output.resourcesDir/META-INF/suspendables", "$sourceSets.main.output.resourcesDir/META-INF/suspendable-supers"
|
||||
ant.scanSuspendables(
|
||||
auto:false,
|
||||
suspendablesFile: "$sourceSets.main.output.resourcesDir/META-INF/suspendables",
|
||||
supersFile: "$sourceSets.main.output.resourcesDir/META-INF/suspendable-supers") {
|
||||
fileset(dir: sourceSets.main.output.classesDir)
|
||||
}
|
||||
}
|
||||
|
||||
jar.dependsOn quasarScan
|
||||
quasarScan.dependsOn('classes')
|
||||
|
@ -3,6 +3,7 @@ version '1.0-SNAPSHOT'
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: QuasarPlugin
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
@ -16,7 +17,6 @@ repositories {
|
||||
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
configurations {
|
||||
quasar
|
||||
|
||||
// we don't want isolated.jar in classPath, since we want to test jar being dynamically loaded as an attachment
|
||||
runtime.exclude module: 'isolated'
|
||||
@ -90,43 +90,9 @@ dependencies {
|
||||
// TypeSafe Config: for simple and human friendly config files.
|
||||
compile "com.typesafe:config:1.3.0"
|
||||
|
||||
// Quasar: for the bytecode rewriting for state machines.
|
||||
quasar "co.paralleluniverse:quasar-core:${quasar_version}:jdk8@jar"
|
||||
|
||||
// Unit testing helpers.
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.assertj:assertj-core:3.4.1'
|
||||
}
|
||||
|
||||
tasks.withType(Test) {
|
||||
jvmArgs "-javaagent:${configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
tasks.withType(JavaExec) {
|
||||
jvmArgs "-javaagent:${configurations.quasar.singleFile}"
|
||||
jvmArgs "-Dco.paralleluniverse.fibers.verifyInstrumentation"
|
||||
}
|
||||
|
||||
|
||||
// These lines tell gradle to run the Quasar suspendables scanner to look for unannotated super methods
|
||||
// that have @Suspendable sub implementations. These tend to cause NPEs and are not caught by the verifier
|
||||
// NOTE: need to make sure the output isn't on the classpath or every other run it generates empty results, so
|
||||
// we explicitly delete to avoid that happening. We also need to turn off what seems to be a spurious warning in the IDE
|
||||
//
|
||||
// TODO: Make this task incremental, as it can be quite slow.
|
||||
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
task quasarScan(dependsOn: ['classes', ':core:classes', ':contracts:classes']) << {
|
||||
ant.taskdef(name:'scanSuspendables', classname:'co.paralleluniverse.fibers.instrument.SuspendablesScanner',
|
||||
classpath: "${sourceSets.main.output.classesDir}:${sourceSets.main.output.resourcesDir}:${configurations.runtime.asPath}")
|
||||
delete "$sourceSets.main.output.resourcesDir/META-INF/suspendables", "$sourceSets.main.output.resourcesDir/META-INF/suspendable-supers"
|
||||
ant.scanSuspendables(
|
||||
auto:false,
|
||||
suspendablesFile: "$sourceSets.main.output.resourcesDir/META-INF/suspendables",
|
||||
supersFile: "$sourceSets.main.output.resourcesDir/META-INF/suspendable-supers") {
|
||||
fileset(dir: sourceSets.main.output.classesDir)
|
||||
}
|
||||
}
|
||||
|
||||
jar.dependsOn quasarScan
|
||||
|
||||
quasarScan.dependsOn('classes', ':core:classes', ':contracts:classes')
|
||||
|
Loading…
Reference in New Issue
Block a user