我有一个使用Gradle的多模块项目。与手头问题相关的两个是manray-gradle-plugin
,这是一个Gradle插件项目,提供单个代码生成任务,而manray-core
是一个普通的Java库项目,需要前面提到的插件生成一些代码。
现在,由于某种原因,我无法再编译插件项目了。它给出了以下错误:
Could not find manray:manray-core:1.0
Searched in the following locations:
<Long list of locations here>
Required by:
project : > manray:manray-gradle-plugin:1.0
...这很奇怪,因为插件项目根本没有引用核心项目。
插件项目的build.gradle是这样的:
apply plugin: 'java-library'
apply plugin: 'maven'
dependencies {
compile gradleApi()
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup:javapoet:1.9.0'
compile 'com.github.javaparser:javaparser-core:2.5.1'
compile 'org.reflections:reflections:0.9.10'
compile 'io.github.lukehutch:fast-classpath-scanner:2.0.3'
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
核心项目的build.gradle是这样的:
apply plugin: 'java'
apply plugin: "manray-gradle-plugin"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
ext {
manrayOutputDir = file("$buildDir/generated-sources/manray/")
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = ["src/"]
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
processComponents {
generatedSourcesDirectory = manrayOutputDir
classpath = sourceSets.main.compileClasspath
}
compileJava.dependsOn processComponents
最后,整个项目的build.gradle是这样的:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'manray:manray-gradle-plugin:+'
}
}
allprojects {
apply plugin: "idea"
version = '1.0'
ext {
appName = "Manray"
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
此外,settings.gradle如下所示:
include ':manray-gradle-plugin', ':manray-core'
什么可能导致构建失败?我已经尝试清理项目,使gradle缓存无效......这里似乎没什么用。