尝试在 Eclipse 中构建 Java gwt Gradle 多项目 但无法将项目2的引用引用到项目3中 任何建议都非常感激。
构建3个项目
项目 1 TmsRoot(主项目)
项目 2 CommonGWT(GWT 代码)
项目 3 Common(非 Gwt)依赖于 CommonGWT
TmsRoot项目中的settings.gradle文件
rootProject.name = "TmsRoot"
include ":ConmonGWT", ":Common"
TmsRoot build.gradle
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
dependencies {
}
version = '1.0'
jar {
manifest.attributes provider: ' Technologies'
}
}
CommonGWT build.gradle
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'gwt'
apply plugin: 'eclipse'
apply plugin: 'jetty'
dependencies {
compile 'org.slf4j:slf4j-api:1.7.12'
testCompile 'junit:junit:4.12'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0'
buildscript {
repositories {
jcenter() //repository where to fetch gwt gradle plugin
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
}
}
repositories {
mavenCentral()
}
compileJava{
//enable incremental compilation
options.incremental = true
}
gwt {
gwtVersion='2.7.0'
modules 'com.stratebo.gwt.common'
sourceSets {
main {
java {
srcDir 'src'
}
}
}
logLevel = 'ERROR'
minHeapSize = "512M";
maxHeapSize = "1024M";
superDev {
noPrecompile=true
}
eclipse{
addGwtContainer=false // Default set to true
}
jettyRunWar.httpPort = 8089
}
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
task jettyDraftWar(type: JettyRunWar) {
dependsOn draftWar
dependsOn.remove('war')
webApp=draftWar.archivePath
}
最后是 Common build.graddle
apply plugin: 'java'
apply plugin: 'eclipse'
dependencies {
compile project(':CommonGWT')
}
如果我点击 gradle 刷新依赖项 我得到以下结果 失败:构建失败并出现异常。
地点: 构建文件“C:\Files\Data\Devel6\Common\build.gradle”行:8
出了什么问题: 评估根项目“Common”时出现问题。 在根项目“Common”中找不到路径为“:CommonGWT”的项目。
尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
构建失败
最佳答案
在我看来,你的所有 3 个项目目录都在同一级别。我的意思是,根项目目录不包含在子项目的目录中,如下所示:
.
├── TMsRoot
│ ├── build.gradle
│ └── settings.gradle
├── CommonGWT
│ └── build.gradle
└── Common
└── build.gradle
在这种情况下,则settings.gradle文件不在子项目的根目录下,它必须包含不是include
,而是includeFlat
,以指定子项目。
关于java - 未找到 Gradle 项目依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33619904/