Created
September 24, 2014 10:55
-
-
Save stackmagic/6d2bfb876209bb1e3eb3 to your computer and use it in GitHub Desktop.
JavaExec bootstrapClasspath issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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