I have the following project structure:
src
|
|--main
|
|--java
| |
| |--p
| |--S.java
|
|
|--groovy
|
|--p
|--Main.groovy
the thing I want learn is how to combine java and groovy compiled classes together. Imagine that S.java
contains the following:
package p;
public class S {
public static void p() {
System.out.println("p");
}
}
and Main.groovy:
package p
public class Main {
public static void main(String[] args) {
S.p
}
}
Now, the build script I've written is the simplest and contains merely
apply plugin : 'groovy'
What I want to achieve by the command build gradle
is to get a jar
file to using with JVM. But instead I got the following error:
Cannot infer Groovy class path because no Groovy Jar was found on class path: co
nfiguration ':compile'
Could you possibly help me to fix that error?
Applying groovy
plugin gives You tasks for groovy compilation and docs etc., but does not provide dependency for groovy itself so what You're missing is:
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy:2.3.7'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With