java:compileJava在本地项目()依赖项上的多模块项目上持续失败“错误:包x.y.z不存在”
我正在尝试创建一个多项目项目,其中1个共享(我在下面称之为Common),另外3个,我刚刚称之为B和D。我正在尝试通过Shadow插件将它们编译成“胖罐子”(或包含所有依赖项的罐子)
我还想说我对格拉德尔很陌生。 我正在使用: 英特利J理念2021 格拉德尔6.8 爪哇11
我的项目是这样安排的:
+ /
| build.gradle
| settings.gradle
+ Subproject.A
| build.gradle
+ Subproject.B
| build.gradle
+ Subproject.Common (dependency for A, B, & D)
| build.gradle
+ Subproject.D
| build.gradle
我在所有项目(公共项目除外)上遇到的错误是它没有成功运行:compileJava
在项目上运行:shadowJar或:jar命令时,它成功地完成了公共项目的任务,然后立即使项目上的:compileJava任务失败
> Task :Subproject.Common:compileJava UP-TO-DATE
> Task :Subproject.Common:processResources UP-TO-DATE
> Task :Subproject.Common:createProperties
> Task :Subproject.Common:classes
> Task :Subproject.Common:jar
> Task :Subproject.A:compileJava FAILED
Z:\IdeaProjects\Project\Subproject.A\src\main\java\subproject\a\Class.java:321: error: package subproject.common does not exist
import subproject.common.Class;
^
我不相信它是影子插件,因为它发生在:shadowJar运行之前。 我尝试过使缓存失效,以及重新导入和重做构建。gradle的档案不走运
我不确定格式化构建的最佳方式。gradle文件,但在朋友的指导下,这就是它们的样子
/build。格拉德尔
plugins {
id 'java'
id 'com.palantir.git-version' version '0.12.1'
id "com.github.johnrengelman.shadow" version "5.2.0"
}
group 'project'
version '1'
subprojects {
apply plugin: 'java'
apply plugin: 'com.palantir.git-version'
apply plugin: 'com.github.johnrengelman.shadow'
//bumping the "version" (build) number and giving a lot of versioning information
def verNumFile = new File("$projectDir/verNum.properties")
Properties verNumProp = new Properties()
if (!verNumFile.exists()) {
verNumFile.getParentFile().mkdirs()
verNumFile.createNewFile()
verNumProp['ver'] = '0'
verNumFile.withWriter { w ->
verNumProp.store w, null
}
} else {
verNumProp.load(new FileReader(verNumFile))
}
def currVerNum = Integer.parseInt(verNumProp['ver'].toString())
version = "b" + currVerNum + ".h" + gitVersion()
task createProperties(dependsOn: processResources) {
doLast {
Properties verProp = new Properties()
def verFile = new File("$buildDir/resources/main/version.properties")
if (!verFile.exists()) {
verFile.getParentFile().mkdirs()
verFile.createNewFile()
} else {
verProp.load(new FileReader(verFile))
}
currVerNum++
verNumProp['ver'] = (currVerNum).toString()
verNumFile.withWriter { w ->
verNumProp.store w, null
}
verFile.withWriter { w ->
verProp['name'] = project.name
verProp['group'] = project.group
verProp['version'] = project.version = "b" + currVerNum + " h" + gitVersion()
verProp['versionNumber'] = currVerNum.toString()
def details = versionDetails()
verProp['lastTag'] = details.lastTag
verProp['commitDistance'] = details.commitDistance.toString()
verProp['gitHash'] = details.gitHash
verProp['gitHashFull'] = details.gitHashFull
verProp['branchName'] = details.branchName
verProp['isCleanTag'] = details.isCleanTag.toString()
verProp.store w, null
}
}
}
classes {
dependsOn createProperties
}
repositories {
mavenCentral()
maven {
url 'https://papermc.io/repo/repository/maven-public/'
}
}
dependencies {
compile 'com.google.api-client:google-api-client:1.30.4'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.30.6'
compile 'com.google.apis:google-api-services-sheets:v4-rev581-1.25.0'
compile 'com.squareup.okhttp3:okhttp:4.9.0'
compile 'redis.clients:jedis:3.3.0'
compile 'org.mongodb:mongodb-driver:3.6.3'
compile 'com.google.code.gson:gson:2.8.6'
compile 'commons-io:commons-io:2.8.0'
compileOnly 'io.github.waterfallmc:waterfall-api:1.16-R0.4-SNAPSHOT'
if(!project.name.endsWith("Common"))
compile project(":Subproject.Common")
}
jar {
manifest {
attributes(
"Main-Class": "Bootstrap"
)
}
}
}
/设置。格拉德尔
rootProject.name = 'Project'
include ':Subproject.A'
include ':Subproject.B'
include ':Subproject.Common'
include ':Subproject.D'
/子项目。A/构建。gradle,子项目。通用/构建。格拉德尔&/子项目。D/构建。格拉德尔
plugins {
id 'java'
}
/子项目。B/建造。格拉德尔
plugins {
id 'java'
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.docker-java:docker-java-core:3.2.10'
compile 'com.github.docker-java:docker-java-transport-httpclient5:3.2.10'
compile 'com.github.robinbraemer:cloudflareapi:1.4.0'
}
我感谢你能给予的任何帮助/指导。 (即使这只是为了gradle的整体,因为我还在学习)
共 (0) 个答案