I'm trying to extract a part of my Kotlin Gradle project to a separate repository. It's a Kotlin multiplatform project (https://github.com/krzema12/fsynth) and I want to extract whatever sits in 'plotassert' package.
I followed https://kotlinlang.org/docs/tutorials/multiplatform-library.html. To test it locally, I published the newly extracted project to the local Maven repository by executing publishToMavenLocal
Gradle's task, and then put mavenLocal()
in the main project's repositories
section (here, as the first item). In core
project's dependencies (here) I put
compile "it.krzeminski.plotassert:PlotAssert:0.0.1"
The problem is that IntelliJ/Gradle don't see this dependency, also when trying to use some class from the code:
If I deliberately use some wrong dependency name, Gradle notices it:
so it means that it somehow sees that the dependency exists in the local repo. I also see in ~/.m2/repository
that the local publication produced some files:
:~/.m2/repository$ tree
.
└── it
└── krzeminski
└── plotassert
├── PlotAssert
│ ├── 0.0.1
│ │ ├── PlotAssert-0.0.1.module
│ │ └── PlotAssert-0.0.1.pom
│ └── maven-metadata-local.xml
├── PlotAssert-js
│ ├── 0.0.1
│ │ ├── PlotAssert-js-0.0.1.jar
│ │ ├── PlotAssert-js-0.0.1.module
│ │ ├── PlotAssert-js-0.0.1.pom
│ │ └── PlotAssert-js-0.0.1-sources.jar
│ └── maven-metadata-local.xml
├── PlotAssert-jvm
│ ├── 0.0.1
│ │ ├── PlotAssert-jvm-0.0.1.jar
│ │ ├── PlotAssert-jvm-0.0.1.module
│ │ ├── PlotAssert-jvm-0.0.1.pom
│ │ └── PlotAssert-jvm-0.0.1-sources.jar
│ └── maven-metadata-local.xml
├── PlotAssert-linux
│ ├── 0.0.1
│ │ ├── PlotAssert-linux-0.0.1.klib
│ │ ├── PlotAssert-linux-0.0.1.module
│ │ ├── PlotAssert-linux-0.0.1.pom
│ │ └── PlotAssert-linux-0.0.1-sources.jar
│ └── maven-metadata-local.xml
└── PlotAssert-metadata
├── 0.0.1
│ ├── PlotAssert-metadata-0.0.1.jar
│ ├── PlotAssert-metadata-0.0.1.module
│ ├── PlotAssert-metadata-0.0.1.pom
│ └── PlotAssert-metadata-0.0.1-sources.jar
└── maven-metadata-local.xml
Isn't this behavior of Gradle or IntelliJ incorrect? My understanding is that it should list this dependency under "Source Sets", like it did in case of the incorrect name.
I haven't tried yet to publish the newly extracted project to some online repo because I'd like to have a chance to iterate locally instead of publishing each change.
Could you give me a pointer what I'm missing here?
It turned out that I had
enableFeaturePreview('GRADLE_METADATA')
in the library project, but didn't have it in the consumer project. Adding it and bumping Gradle wrapper version to 4.9 solved the issue.