[英]Is it possible to combine java and groovy sources in the gradle project?
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. 我想要学习的是如何将java和groovy编译的类组合在一起。 Imagine that S.java
contains the following: 想象一下, S.java
包含以下内容:
package p;
public class S {
public static void p() {
System.out.println("p");
}
}
and Main.groovy: 和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. 我想通过命令build gradle
实现的build gradle
是获取一个与JVM一起使用的jar
文件。 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: 应用groovy
插件为您提供了groovy编译和文档等的任务,但不提供groovy本身的依赖,所以你缺少的是:
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy:2.3.7'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.