以下任务之间的循环依赖 - 替代代码?

问题描述 投票:0回答:1

我在 Intellij Idea 中的项目遇到了麻烦。我在本文末尾添加了一张图片,以澄清我需要更好的帮助,以防万一。

build.gradle 中的这一行似乎允许正确导入我的项目的一部分:

    dependencies {
    implementation project(':cachetool')
  }

但是,当我运行该应用程序时,我从该行中得到以下信息:

    Circular dependency between the following tasks:
:cachetool:classes
\--- :cachetool:compileJava
     +--- :cachetool:compileKotlin
     |    \--- :cachetool:jar
     |         +--- :cachetool:classes (*)
     |         +--- :cachetool:compileKotlin (*)
     |         \--- :cachetool:inspectClassesForKotlinIC
     |              +--- :cachetool:classes (*)
     |              \--- :cachetool:compileKotlin (*)
     \--- :cachetool:jar (*)

我该如何解决这个问题?如果没有依赖行,我无法导入项目的部分内容。这是我完整的 build.gradle:

    plugins {
  id 'java'
  id 'org.jetbrains.kotlin.jvm' version '1.6.10'
}

repositories {
  mavenCentral()
  mavenLocal()
  jcenter()
  maven { url "https://repo.maven.apache.org/maven2" }
}

sourceSets {
  main {
    java {
      srcDirs = ['src/main/java', 'cachetool']
    }
    resources {
      srcDirs = ['src/main/resources']
    }
  }
}

allprojects {
  group = 'scape-editor'
  version = '2.0.0'
}

wrapper {
  gradleVersion = '7.5'
}

subprojects {
  apply plugin: 'java'
  apply plugin: 'kotlin'

  sourceCompatibility = 1.8
  targetCompatibility = 1.8

  repositories {
    mavenCentral()
    mavenLocal()
    maven { url "https://repo.maven.apache.org/maven2" }
  }

  dependencies {
    implementation group: 'junit', name: 'junit', version: '4.12'
    testImplementation 'junit:junit:4.11'
    testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.6.10"
  }

  dependencies {
    implementation project(':cachetool')
  }
}

这是我的settings.gradle:

  rootProject.name = 'scape-editor'

include ':fs'
include ':gui'
include ':io'
include ':util'
include ':plugin'
include ':cachetool'

project(':fs').projectDir = "$rootDir/fs" as File
project(':gui').projectDir = "$rootDir/gui" as File
project(':io').projectDir = "$rootDir/io" as File
project(':util').projectDir = "$rootDir/util" as File
project(':plugin').projectDir = "$rootDir/plugin" as File
project(':cachetool').projectDir = "$rootDir/cachetool" as File

我正在做的事情还有其他选择吗?谢谢! =)

以下图片用于澄清:

enter image description here

java gradle circular-dependency
1个回答
0
投票

您已输入此代码:

dependencies {
    implementation project(':cachetool')
}

subprojects
封口内。这将尝试在每个子项目中导入
cachetool
项目,包括
cachetool
。看到圆度了吗?

此类项目仅应包含在位于需要此类依赖项的特定子项目的文件夹内的特定

build.gradle
文件中。

© www.soinside.com 2019 - 2024. All rights reserved.