在build.gradle中加入如下任务。
task pathingJar(type: Jar) {
dependsOn configurations.runtime
appendix = 'pathing'
doFirst {
manifest {
attributes "Class-Path": configurations.runtime.files.collect {
it.toURI().toURL().toString().replaceFirst("file:/", '/')
}.join(" ")
}
}
}
bootRun {
dependsOn pathingJar
doFirst {
classpath = files(sourceSets.main.output.files, pathingJar.archivePath)
}
}