Skip to content

Instantly share code, notes, and snippets.

@stackmagic
Created September 24, 2014 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stackmagic/6d2bfb876209bb1e3eb3 to your computer and use it in GitHub Desktop.
Save stackmagic/6d2bfb876209bb1e3eb3 to your computer and use it in GitHub Desktop.
JavaExec bootstrapClasspath issue
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
}
configurations {
bootClassPath
}
dependencies {
bootClassPath "org.mortbay.jetty.npn:npn-boot:1.1.7.v20140316"
}
task runOk(type: JavaExec) {
// this will actually *append* to the boot classpath
jvmArgs "-Xbootclasspath/a:${configurations.bootClassPath.asPath}"
classpath = sourceSets.main.runtimeClasspath
// just calling Keytool from rt.jar
main = 'sun.security.tools.KeyTool'
args '-h'
doFirst {
println "COMMAND_LINE >>> ${commandLine}"
}
}
task runFail(type: JavaExec) {
// this *sets* the boot classpath instead of *appending* to it as the docs say
// http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.JavaExec.html#org.gradle.api.tasks.JavaExec:bootstrapClasspath(java.lang.Object[])
// the printed commandline shows the argument generated as
// being '-Xbootclasspath:' instead of '-Xbootclasspath/a:'
// the error message will be
// Error occurred during initialization of VM
// java/lang/NoClassDefFoundError: java/lang/Object
bootstrapClasspath(configurations.bootClassPath.asPath)
classpath = sourceSets.main.runtimeClasspath
// just calling Keytool from rt.jar
main = 'sun.security.tools.KeyTool'
args '-h'
doFirst {
println "COMMAND_LINE >>> ${commandLine}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment