Ahead of time instrumentation tips
doctorpangloss opened this issue · comments
Tested on Gradle 5.0 and OpenJDK 11.
For those of you having trouble instrumenting ahead of time, these are the pieces of gradle build script you need to get it to work.
First, in your only build.gradle
or subprojects
closure (i.e., inside the curly braces of subprojects
in your top-level build.gradle
), add the appropriate dependency:
dependencies {
compile group: 'co.paralleluniverse', name: 'quasar-core', version: '0.8.0'
}
Then, add this to the build.gradle
or subprojects
closure:
compileJava.dependsOn processResources
compileJava {
doLast {
ant.taskdef(name: 'instrumentation', classname: 'co.paralleluniverse.fibers.instrument.InstrumentationTask', classpath: configurations.compile.asPath)
ant.instrumentation(verbose: 'true', check: 'true', debug: 'true', allowMonitors: 'true', allowBlocking: 'true') {
fileset(dir: sourceSets.main.output.classesDirs.asPath)
}
}
}
compileTestJava.dependsOn processTestResources
compileTestJava {
doLast {
ant.taskdef(name: 'instrumentation', classname: 'co.paralleluniverse.fibers.instrument.InstrumentationTask', classpath: configurations.testCompile.asPath)
ant.instrumentation(verbose: 'true', check: 'true', debug: 'true', allowMonitors: 'true', allowBlocking: 'true') {
fileset(dir: sourceSets.main.output.classesDirs.asPath)
fileset(dir: sourceSets.test.output.classesDirs.asPath)
}
}
}
Observe that the main differences with the documentation are additional instrumenting commands that are almost always what you want, the correct use of classesDirs.asPath
, and that the test spec includes two filesets.
That's it! That's how you install Quasar, and get AoT compilation.
Older versions of Gradle: sourceSets.main.output.classesDirs.asPath
may change. I don't have the time to try, but if anyone tries this on Gradle 2/3/4, that is what's likely going to need to change. Just make sure it's a path. It may be called output.classesDir
instead.