Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ahead of time instrumentation tips #320

Open
doctorpangloss opened this issue Dec 6, 2018 · 0 comments
Open

Ahead of time instrumentation tips #320

doctorpangloss opened this issue Dec 6, 2018 · 0 comments

Comments

@doctorpangloss
Copy link

doctorpangloss commented Dec 6, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant