无法从项目子文件夹 运行 gradlew.bat
Cannot run gradlew.bat from project sub folder
我有以下项目结构
MyProject
projA
projB
build.gradle
gradlew.bat
build.gradle
gradlew
settings.gradle
我在 MyProject/projB/build.gradle
中有以下任务
def process;
task bootRunStartDaemon() {
doFirst {
println("Starting application it profile")
ProcessBuilder builder = new ProcessBuilder("./gradlew.bat", "bootRun", "--args='--spring.profiles.active=it'")
builder.redirectErrorStream(true)
builder.directory(projectDir)
process = builder.start()
}
}
但是,当我从根目录 运行 > gradlew bootRunStartDaemon
时,出现以下错误
Caused by: org.gradle.api.UncheckedIOException: java.io.IOException: Cannot run program "./gradlew.bat" (in directory "MyProject\projB"): CreateProcess error=2, The system cannot find the file specified
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:62)
我在下面 settings.gradle
....
rootProject.name = "MyProject"
include "projA", "projB"
我通过添加如下路径设法 运行 gradlew.bat。因为gradlew.bat个脚本只存在于根文件夹下
ProcessBuilder builder = new ProcessBuilder(projectDir.toString().replace("projB","") + gradleCommand, "bootRun", "--args='--spring.profiles.active=it'")
我有以下项目结构
MyProject
projA
projB
build.gradle
gradlew.bat
build.gradle
gradlew
settings.gradle
我在 MyProject/projB/build.gradle
def process;
task bootRunStartDaemon() {
doFirst {
println("Starting application it profile")
ProcessBuilder builder = new ProcessBuilder("./gradlew.bat", "bootRun", "--args='--spring.profiles.active=it'")
builder.redirectErrorStream(true)
builder.directory(projectDir)
process = builder.start()
}
}
但是,当我从根目录 运行 > gradlew bootRunStartDaemon
时,出现以下错误
Caused by: org.gradle.api.UncheckedIOException: java.io.IOException: Cannot run program "./gradlew.bat" (in directory "MyProject\projB"): CreateProcess error=2, The system cannot find the file specified
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:62)
我在下面 settings.gradle
....
rootProject.name = "MyProject"
include "projA", "projB"
我通过添加如下路径设法 运行 gradlew.bat。因为gradlew.bat个脚本只存在于根文件夹下
ProcessBuilder builder = new ProcessBuilder(projectDir.toString().replace("projB","") + gradleCommand, "bootRun", "--args='--spring.profiles.active=it'")