Reputation: 1
Im trying to integrate groovy in java with build tools as gradle, There are several examples with maven build, but with gradle its still missing.
I tried of adding plugin of groovy, but for compiler plugin like gmavenplus. I try to add it as dependency but not sure how i can add it in gradle
Upvotes: 0
Views: 194
Reputation: 527
You can mix Java classes into a Groovy project.
gradle init
.source/main/groovy
folder.source/main/java
folder (but see the comment, below, from Jeff Scott Brown)src/test
foldersrc
└───main
├───resources
├───groovy
│ └───mixedbuildtest
│ App.groovy
│
├───java
│ └───mixedbuildtest
│ JavaApp.java
package mixedbuildtest
class App {
String getGreeting() {
return 'Hello from Groovy!'
}
static void main(String[] args) {
println new App().greeting
println new JavaApp().greeting
}
}
package mixedbuildtest;
class JavaApp {
String getGreeting() {
return "Hello from Java!";
}
}
F:\projects\sx\MixedBuild>gradle run
> Task :app:run
Hello from Groovy!
Hello from Java!
BUILD SUCCESSFUL in 4s
3 actionable tasks: 3 executed
F:\projects\sx\MixedBuild>
Upvotes: 0