本文介绍了在gradle中如何使用项目外部相对路径的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将以下两个项目放置在某个文件夹中彼此相邻,我想将非渐变项目的特定来源包括到该项目中,其结构如下.
I have following 2 projects placed adjacent to each other in some folder and I want to include specific sources from a non-gradle project into this project with the structure as follows.
rootfolder/
my-gradle-project/
src/main/java
build.gradle
my-non-gradle-project/
src/main/java/com/example/utils
在build.gradle中,为什么以下操作不起作用?我有什么选择?
In build.gradle why would following not work ? What alternative do I have ?
另外,我需要包括来自非渐变项目的特定Java来源.
Additionally I need to included specific java sources from the non-gradle project.
build.gradle
sourceSets.main.java.srcDirs = [
'src/main/java',
'../my-non-gradle-project/src/main/java/com/example/util')]
推荐答案
以下内容在intelliJ中起作用:
The following worked in intelliJ:
...
group 'org.example'
version '1.0-SNAPSHOT'
sourceSets {
main {
java{
srcDirs '../my-non-gradle-project/src/main/java/com/example/util' /* include proto files from base project level */
}
}
}
sourceCompatibility = 1.11
...
这篇关于在gradle中如何使用项目外部相对路径的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!