В моем проекте это требование для достижения "нулевой конфигурации". Для ПО это означает, что есть одна команда, которая настраивает весь проект, и другая команда, которая запускает весь проект. Я относительно новичок в разработке программного обеспечения, особенно с Gradle. Вот мой код, что я и сделал:
def frontendDir = "$projectDir/src/main/resources/assets/anwboard-frontend/"
task configureProject(type:Exec) {
workingDir "$frontendDir"
inputs.dir "$frontendDir"
def angularVersion = commandLine "ng", "--version"
def springbootVersion = commandLine "spring", "version"
def nodeVersion = commandLine "node", "-v"
if (nodeVersion == null) {
if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
commandLine "choco", "install", "node.jsinstall"
}else {
commandLine "brew", "install", "node"
}
}
if (angularVersion == null) {
if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
commandLine "npm", "install", "@angular/cli"
} else {
commandLine "npm", "install", "angular"
}
}
if (springbootVersion == null) {
if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
commandLine "choco", "install", "spring-boot-cli"
}else {
commandLine "brew", "tap", "pivotal/tap"
commandLine "brew", "install", "springboot"
}
}
}
task buildAngular(type:Exec) {
workingDir "$frontendDir"
inputs.dir "$frontendDir"
commandLine "ng", "serve", "-o"
}
task buildSpringboot(type:Exec){
workingDir "$projectDir"
inputs.dir "$projectDir"
commandLine "./gradlew", "bootRun"
}
Теперь роуминг сказал: «Определенно есть лучший способ решить эту проблему», но я не знаю, я искал везде, но без результата. Я попытался запустить angular и прыгнуть с помощью одной команды, но задача так и не была выполнена, поэтому он запускает только одну из них. Есть ли способ каким-либо образом установить angular, springboot и node.js с помощью команды сборки ./gradlew или каким-либо другим способом уменьшить количество необходимых команд? Любая помощь будет принята с благодарностью.