In my project it is a requirement to achieve "zero configuration". What that means for the p.o. is that there is one command which configures the whole project and another command which starts the whole project. I'm relatively new in software development, especially with gradle. Here is my code what i did:
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"
}
Now the p.o said "there is definitely a better way to solve this" but i don't know one, i looked everywhere but without a result. I tried to start angular and springboot with one command, but the task never gets finished, so it only starts one of them. Is there maybe a way to somehow install angular, springboot and node.js with the ./gradlew build command or some other way to reduce the amount of commands neccessary? Any help would be greatly appreciated.