我正在尝试为我正在研究的kotlin项目设置多项目/复合gradle构建,并且遇到一些错误。我的settings.gradle文件中有此文件:
def projects = [
'shared-library'
]
for (String relativeProject : projects) {
File file = new File(settingsDir, "../$relativeProject")
if (file.exists()) {
include(relativeProject)
project(":$relativeProject").projectDir = new File(settingsDir, "../$relativeProject")
}
}
项目建立时出现此错误:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':shared-library'.
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Build file '/home/stormblessed/Soft/ApiGateway/build.gradle' line: 3
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.3.21']
Caused by: org.gradle.api.GradleException: Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.3.21']
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:256)
... 135 more
Caused by: org.gradle.plugin.management.internal.InvalidPluginRequestException: Plugin request for plugin already on the classpath must not include a version
奇怪的是,我为Java项目设置了完全相同的设置,并且Java插件没有与之关联的版本,因此可能与Java项目没有失败有关。
我读到一个github问题,描述了我的相同问题,解决方案建议我使用includeBuild
而不是include
,并且可以解决,但现在我得到一个新错误:
org.gradle.api.GradleScriptException: A problem occurred evaluating settings 'api-gateway'.
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
Caused by: org.gradle.api.UnknownProjectException: Project with path ':shared-library' could not be found.
at jdk.internal.reflect.GeneratedMethodAccessor426.invoke(Unknown Source)
at settings_eft3sns2cik3i85f9zhag0eho.run(/home/stormblessed/Soft/Personal/api-gateway/settings.gradle:13)
我不确定在保持项目独立性的同时如何将它们组合在一起以共享依赖项和编译。我该如何解决这个问题?