I am trying to run a class from root build.gradle file with project.javaexec { } method, the class can be found in buildSrc/src/main/groovy. So the project structure looks like:
├── build.gradle
└── buildSrc
└── src
└── main
└── groovy
└── Main.groovy
The build file content:
task debug << {
project.javaexec {
main = "Main"
}
}
And the buildSrc Main class content:
class Main {
public static void main(String[] args) {
println 'Hello from buildSrc!'
}
}
When I call the debug task, then this error message came up: Could not find or load main class class Main
But if I call the Main.main() method on the same place (without javaexec method call), then the method is executed and the project can see the Main class…
task debug << {
Main.main()
}
Hello from buildSrc!
Can you tell me please what is the possible solution? I would like to run this Main class with javaexec method…