首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gradle api配置无法按预期工作

Gradle api配置无法按预期工作
EN

Stack Overflow用户
提问于 2020-03-24 12:38:17
回答 1查看 1.2K关注 0票数 3

我很难理解apiimplementation配置在Gradle中的区别。我知道以前有人问过这个问题,但他们的行为似乎与每个人所描述的完全相反。我有三个分级项目: consumer -> libraryA -> libraryB。libraryA有一个api依赖于libraryB,而使用者对libraryA有一个implementation依赖,但是libraryB在消费者的任何类路径上都是不可用的。当我将libraryA更改为implementation依赖于libraryB时,libraryB就可以在消费者的runtimeClasspath上使用。这似乎不符合每个人的说法。我遗漏了什么?

libraryB

代码语言:javascript
复制
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Kotlin library project to get you started.
 */

plugins {
    maven
    id("org.jetbrains.kotlin.jvm").version("1.3.31")
}

group = "libraryB"

repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // Use the Kotlin JDK 8 standard library.
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

libraryA:

代码语言:javascript
复制
/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Kotlin library project to get you started.
 */

plugins {
    maven
    id("org.jetbrains.kotlin.jvm").version("1.3.31")
}

group = "libraryA"

repositories {
    mavenLocal()
    jcenter()
}

dependencies {
    // if I change this to implementation, libraryB will be on the runtime classpath of consumer
    api("libraryB:libraryB:unspecified")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

消费者:

代码语言:javascript
复制
/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Kotlin application project to get you started.
 */

plugins {
    // Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
    id("org.jetbrains.kotlin.jvm").version("1.3.31")

    // Apply the application plugin to add support for building a CLI application.
    application
}

group = "com.consumer"

repositories {
    mavenLocal()
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    implementation("libraryA:libraryA:unspecified")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

application {
    // Define the main class for the application
    mainClassName = "com.consumer.AppKt"
}

在消费者中:gradle dependencies

代码语言:javascript
复制
> Task :dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

-api (n)
No dependencies

-runtime (n)
+--- libraryA:libraryA:unspecified (n)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (n)

annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies

api - API dependencies for compilation 'main' (target  (jvm)). (n)
No dependencies

apiDependenciesMetadata
No dependencies

apiElements - API elements for main. (n)
No dependencies

archives - Configuration for archive artifacts.
No dependencies

compileClasspath - Compile classpath for compilation 'main' (target  (jvm)).
+--- libraryA:libraryA:unspecified
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     |    \--- org.jetbrains:annotations:13.0
     \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
          \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)

compileOnly - Compile only dependencies for compilation 'main' (target  (jvm)). (n)
No dependencies

compileOnlyDependenciesMetadata
No dependencies

default - Configuration for default artifacts.
+--- libraryA:libraryA:unspecified
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|         |    \--- org.jetbrains:annotations:13.0
|         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|              \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)

implementation - Implementation only dependencies for compilation 'main' (target  (jvm)). (n)
+--- libraryA:libraryA:unspecified (n)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (n)

implementationDependenciesMetadata
+--- libraryA:libraryA:unspecified
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     |    \--- org.jetbrains:annotations:13.0
     \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
          \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)

kotlinCompilerClasspath
\--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.31
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     |    \--- org.jetbrains:annotations:13.0
     +--- org.jetbrains.kotlin:kotlin-script-runtime:1.3.31
     +--- org.jetbrains.kotlin:kotlin-reflect:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
     \--- org.jetbrains.intellij.deps:trove4j:1.0.20181211

kotlinCompilerPluginClasspath
\--- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.31

kotlinNativeCompilerPluginClasspath
No dependencies

kotlinScriptDef - Script filename extensions discovery classpath configuration
No dependencies

kotlinScriptDefExtensions
No dependencies

runtimeClasspath - Runtime classpath of compilation 'main' (target  (jvm)).
+--- libraryA:libraryA:unspecified
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|         |    \--- org.jetbrains:annotations:13.0
|         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|              \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)

runtimeElements - Elements of runtime for main. (n)
No dependencies

runtimeOnly - Runtime only dependencies for compilation 'main' (target  (jvm)). (n)
No dependencies

runtimeOnlyDependenciesMetadata
No dependencies

sourceArtifacts (n)
No dependencies

testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies

testApi - API dependencies for compilation 'test' (target  (jvm)). (n)
No dependencies

testApiDependenciesMetadata
No dependencies

testCompileClasspath - Compile classpath for compilation 'test' (target  (jvm)).
+--- libraryA:libraryA:unspecified
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-test-common:1.3.31
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test:1.3.31 (*)
     \--- junit:junit:4.12
          \--- org.hamcrest:hamcrest-core:1.3

testCompileOnly - Compile only dependencies for compilation 'test' (target  (jvm)). (n)
No dependencies

testCompileOnlyDependenciesMetadata
No dependencies

testImplementation - Implementation only dependencies for compilation 'test' (target  (jvm)). (n)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31 (n)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31 (n)

testImplementationDependenciesMetadata
+--- libraryA:libraryA:unspecified
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-test-common:1.3.31
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test:1.3.31 (*)
     \--- junit:junit:4.12
          \--- org.hamcrest:hamcrest-core:1.3

testKotlinScriptDef - Script filename extensions discovery classpath configuration
No dependencies

testKotlinScriptDefExtensions
No dependencies

testRuntimeClasspath - Runtime classpath of compilation 'test' (target  (jvm)).
+--- libraryA:libraryA:unspecified
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|         |    \--- org.jetbrains:annotations:13.0
|         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|              \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-test-common:1.3.31
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test:1.3.31 (*)
     \--- junit:junit:4.12
          \--- org.hamcrest:hamcrest-core:1.3

testRuntimeOnly - Runtime only dependencies for compilation 'test' (target  (jvm)). (n)
No dependencies

testRuntimeOnlyDependenciesMetadata
No dependencies

(*) - dependencies omitted (listed previously)

(n) - Not resolved (configuration is not meant to be resolved)

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 604ms
1 actionable task: 1 executed

现在libraryA有一个implementation依赖于libraryB

代码语言:javascript
复制
> Task :dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

-api (n)
No dependencies

-runtime (n)
+--- libraryA:libraryA:unspecified (n)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (n)

annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies

api - API dependencies for compilation 'main' (target  (jvm)). (n)
No dependencies

apiDependenciesMetadata
No dependencies

apiElements - API elements for main. (n)
No dependencies

archives - Configuration for archive artifacts.
No dependencies

compileClasspath - Compile classpath for compilation 'main' (target  (jvm)).
+--- libraryA:libraryA:unspecified
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     |    \--- org.jetbrains:annotations:13.0
     \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
          \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)

compileOnly - Compile only dependencies for compilation 'main' (target  (jvm)). (n)
No dependencies

compileOnlyDependenciesMetadata
No dependencies

default - Configuration for default artifacts.
+--- libraryA:libraryA:unspecified
|    +--- libraryB:libraryB:unspecified
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    |         |    \--- org.jetbrains:annotations:13.0
|    |         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|    |              \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)

implementation - Implementation only dependencies for compilation 'main' (target  (jvm)). (n)
+--- libraryA:libraryA:unspecified (n)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (n)

implementationDependenciesMetadata
+--- libraryA:libraryA:unspecified
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     |    \--- org.jetbrains:annotations:13.0
     \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
          \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)

kotlinCompilerClasspath
\--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.31
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     |    \--- org.jetbrains:annotations:13.0
     +--- org.jetbrains.kotlin:kotlin-script-runtime:1.3.31
     +--- org.jetbrains.kotlin:kotlin-reflect:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
     \--- org.jetbrains.intellij.deps:trove4j:1.0.20181211

kotlinCompilerPluginClasspath
\--- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.31

kotlinNativeCompilerPluginClasspath
No dependencies

kotlinScriptDef - Script filename extensions discovery classpath configuration
No dependencies

kotlinScriptDefExtensions
No dependencies

runtimeClasspath - Runtime classpath of compilation 'main' (target  (jvm)).
+--- libraryA:libraryA:unspecified
|    +--- libraryB:libraryB:unspecified
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    |         |    \--- org.jetbrains:annotations:13.0
|    |         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|    |              \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)

runtimeElements - Elements of runtime for main. (n)
No dependencies

runtimeOnly - Runtime only dependencies for compilation 'main' (target  (jvm)). (n)
No dependencies

runtimeOnlyDependenciesMetadata
No dependencies

sourceArtifacts (n)
No dependencies

testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies

testApi - API dependencies for compilation 'test' (target  (jvm)). (n)
No dependencies

testApiDependenciesMetadata
No dependencies

testCompileClasspath - Compile classpath for compilation 'test' (target  (jvm)).
+--- libraryA:libraryA:unspecified
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-test-common:1.3.31
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test:1.3.31 (*)
     \--- junit:junit:4.12
          \--- org.hamcrest:hamcrest-core:1.3

testCompileOnly - Compile only dependencies for compilation 'test' (target  (jvm)). (n)
No dependencies

testCompileOnlyDependenciesMetadata
No dependencies

testImplementation - Implementation only dependencies for compilation 'test' (target  (jvm)). (n)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31 (n)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31 (n)

testImplementationDependenciesMetadata
+--- libraryA:libraryA:unspecified
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-test-common:1.3.31
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test:1.3.31 (*)
     \--- junit:junit:4.12
          \--- org.hamcrest:hamcrest-core:1.3

testKotlinScriptDef - Script filename extensions discovery classpath configuration
No dependencies

testKotlinScriptDefExtensions
No dependencies

testRuntimeClasspath - Runtime classpath of compilation 'test' (target  (jvm)).
+--- libraryA:libraryA:unspecified
|    +--- libraryB:libraryB:unspecified
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
|    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
|    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    |         |    \--- org.jetbrains:annotations:13.0
|    |         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31
|    |              \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31 (*)
+--- org.jetbrains.kotlin:kotlin-test:1.3.31
|    +--- org.jetbrains.kotlin:kotlin-test-common:1.3.31
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 (*)
\--- org.jetbrains.kotlin:kotlin-test-junit:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.31
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
     +--- org.jetbrains.kotlin:kotlin-test:1.3.31 (*)
     \--- junit:junit:4.12
          \--- org.hamcrest:hamcrest-core:1.3

testRuntimeOnly - Runtime only dependencies for compilation 'test' (target  (jvm)). (n)
No dependencies

testRuntimeOnlyDependenciesMetadata
No dependencies

(*) - dependencies omitted (listed previously)

(n) - Not resolved (configuration is not meant to be resolved)

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 564ms
1 actionable task: 1 executed

Note I正在使用6.2.2版本

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-25 01:26:34

所以我的问题是我没有启用java-library插件。一旦我将它添加到libraryA中,libraryB就成功地出现在了消费者的compileClasspath上。

因此,正确的build.gradle.kts用于libraryA是:

代码语言:javascript
复制
/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Kotlin library project to get you started.
 */

plugins {
    maven
    `java-library`
    id("org.jetbrains.kotlin.jvm").version("1.3.31")
}

group = "libraryA"

repositories {
    mavenLocal()
    jcenter()
}

dependencies {
    api("libraryB:libraryB:unspecified")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60831210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档