IntelliJ 中的 Gradle SourceSet 依赖项

2024-04-16

我有一个带有附加源集的 Gradle 项目 -acceptance。这包含我的验收测试,而不仅仅是构建时单元和集成测试。

我在标准中还有一些辅助类test我想分享的源集,但它不属于main源集。

目前这在 Gradle 中运行良好,但 IntelliJ 不喜欢它,我不知道为什么。

My build.gradle看起来像这样:

buildscript {
  ext {
    jackson_version = "2.9.0.pr4"
    // IntelliJ needs M4
    junitJupiter_version = "5.0.0-M4"
    junitPlatform_version = "1.0.0-M4"
    kotlin_version = "1.1.3-2"
    slf4j_version = "1.7.25"
    spring_version = "4.3.10.RELEASE"
    springBoot_version = "1.5.4.RELEASE"
    springBootAdmin_version = "1.5.2"

    runAcceptance = System.properties['noAcceptance'] == null
  }

  repositories {
    mavenCentral()
    jcenter()
  }

  dependencies {
    classpath "com.github.ben-manes:gradle-versions-plugin:0.15.0"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
    classpath "org.junit.platform:junit-platform-gradle-plugin:$junitPlatform_version"
    classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBoot_version"
  }
}

plugins {
  id "com.github.ben-manes.versions" version "0.15.0"
}

apply plugin: "com.github.ben-manes.versions"
apply plugin: "kotlin"
apply plugin: "kotlin-spring"
apply plugin: "org.junit.platform.gradle.plugin"
apply plugin: "org.springframework.boot"
apply plugin: "war"

repositories {
  mavenCentral()
  maven { url "https://jitpack.io" }
}

sourceSets {
  acceptance {
    kotlin {
      compileClasspath += main.output + test.output
      runtimeClasspath += main.output + test.output
      srcDir file('src/acceptance/kotlin')
    }
    resources.srcDir file('src/acceptance/resources')
  }
}

configurations {
  acceptanceCompile.extendsFrom testCompile
  acceptanceRuntime.extendsFrom testRuntime
}

dependencies {
  compile "com.auth0:java-jwt:3.2.0"
  compile "com.graphql-java:graphql-java-tools:3.2.1"
  compile "com.graphql-java:graphql-spring-boot-starter:3.6.0"
  compile "com.zaxxer:HikariCP:2.6.3"
  compile("de.codecentric:spring-boot-admin-server:$springBootAdmin_version") {
      exclude group: "junit", module: "junit"
  }
  compile("de.codecentric:spring-boot-admin-server-ui:$springBootAdmin_version") {
      exclude group: "junit", module: "junit"
  }
  compile("de.codecentric:spring-boot-admin-starter-client:$springBootAdmin_version") {
      exclude group: "junit", module: "junit"
  }
  compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
  compile "org.slf4j:slf4j-api:$slf4j_version"
  compile "org.springframework:spring-jdbc:$spring_version"
  compile "org.springframework.boot:spring-boot-starter-web:$springBoot_version"
  compile "org.springframework.boot:spring-boot-starter-actuator:$springBoot_version"
  compile "ru.yandex.qatools.embed:postgresql-embedded:2.2"

  runtime "ch.qos.logback:logback-classic:1.2.3"
  runtime "org.jolokia:jolokia-core:1.3.7"
  runtime "org.liquibase:liquibase-core:3.5.3"
  runtime "org.postgresql:postgresql:42.1.3"
  runtime "org.slf4j:jcl-over-slf4j:$slf4j_version"
  runtime "org.slf4j:jul-to-slf4j:$slf4j_version"

  testCompile "com.github.sbrannen:spring-test-junit5:1.0.0.M4"
  testCompile "com.nhaarman:mockito-kotlin:1.5.0"
  testCompile("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") {
      exclude group: "junit", module: "junit"
  }
  testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiter_version"

  testRuntime "org.junit.jupiter:junit-jupiter-engine:$junitJupiter_version"

  acceptanceCompile "commons-jxpath:commons-jxpath:1.3"
  acceptanceCompile "org.springframework.boot:spring-boot-starter-test:$springBoot_version"
}

task acceptance(type: Test) {
  testClassesDirs = sourceSets.acceptance.output.classesDirs
  classpath = sourceSets.acceptance.runtimeClasspath
  outputs.upToDateWhen { false }
}

if (ext.runAcceptance) {
  check.dependsOn acceptance
}
acceptance.mustRunAfter test

task wrapper(type: Wrapper) {
  gradleVersion = "4.0"
}

IntelliJ 可以看到来自的依赖关系main源集在acceptance一个很好,但拒绝让我访问test一 - 即使命令行构建有效。我缺少什么?


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

IntelliJ 中的 Gradle SourceSet 依赖项 的相关文章

随机推荐