eas*_*ter 2 runtime classpath gradle javaexec-gradle-plugin
Gradle如何在JavaExec类路径中包含runtimeOnly依赖项?例如,
子项目foo:
dependencies {
runtimeOnly files('libs/hello.jar')
}
Run Code Online (Sandbox Code Playgroud)
子项目栏:
dependencies {
compile project(':foo')
}
task execHello(type: JavaExec, dependsOn: 'compileJava') {
classpath = configurations.runtime
main 'myPackage.Hello'
}
Run Code Online (Sandbox Code Playgroud)
在libs / hello.jar中定义了主类myPackage.Hello,它是项目foo的runtimeOnly依赖项。
configuration.runtime不包含runtimeOnly依赖hello.jar。如果我在项目foo中将runtimeOnly依赖项更改为api依赖项,它将起作用。
classpath = configurations.runtime + configuration.runtimeOnly
Run Code Online (Sandbox Code Playgroud)
错误:runtimeOnly无法明确解决。如何在JavaExec类路径中添加hello.jar?
runtime和runtimeOnly用于声明依赖项。要使用依赖关系,您应该runtimeClasspath按照https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph上的文档使用配置。
| 归档时间: |
|
| 查看次数: |
8407 次 |
| 最近记录: |