Gradle 6.0 breaks source set dependency

不羁的心 提交于 2020-04-07 07:59:27

问题


I have a collection of lessons for students here: https://github.com/emign/engineEmi_Lektionen/tree/master

The dependant lib for this project gets injected via a gradle plugin here: https://github.com/emign/engineEmi_GradlePlugin/blob/98a70b6a54c21c730a9d1cb6e4fee9ac369b8fc6/src/main/kotlin/me/emig/engineEmi/gradle/EngineEmiGradlePlugin.kt#L43

It all works great up until gradle 5.6.4. But when I upgrade the wrapper, it breaks and loses the Source Set of the above mentioned library. Can anyone help me with that?

Steps to reproduce:

  1. Clone repo
  2. Use gradle wrapper version 5.6.4 -> Example works. (Source set dependency engineEmi is integrated)
  3. Use gradle wrapper version 6.0 or above -> Example breaks (Source set dependency engineEmi is missing)

EDIT Forgot the error message:

 > Task :compileKotlinJvm FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.2/userguide/command_line_interface.html#sec:command_line_warnings
1 actionable task: 1 executed
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (1, 8): Unresolved reference: me
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (16, 9): Unresolved reference: engine
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (21, 13): Unresolved reference: init
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (28, 13): Unresolved reference: viewWillLoad
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (35, 13): Unresolved reference: viewDidLoad
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (39, 13): Unresolved reference: start

It just doestnt find the library (package). Switching back to 5.6.4 lets it find the lib again


回答1:


Finally I was able to fix it.

The problem was a combination of two things as I could reproduce:

1. Kotlin Multiplatform publishing

You do NOT need to create the publications manually with kotlin multipatform: Compared to publishing a plain Kotlin/JVM or Java project, there is no need to create publications manually via the publishing { ... } (see here: 1)

The kotlin {} block does almost anything for you. You only have to add the repository you publish to in the publishing {} block. For example::

publishing {
    publications {
        val kotlinMultiplatform by getting {
            repositories {
                maven {
                    credentials {
                        username = "USERNAME"
                        password = System.getenv("bintrayApiKey")
                    }
                    url = uri(
                        "https://api.bintray.com/maven/ORG/REPO/ARTIFACT/"

                    )
                }
            }
        }
    }
}

2. gradle tasks for publishing

Somehow, the task publishAllPublicationsToMavenRepository did not work for me. You really need to use the publish task



来源:https://stackoverflow.com/questions/60595853/gradle-6-0-breaks-source-set-dependency

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!