My team uses a set of extension functions for JSON-Java that originated in one project, and has now been copy/pasted in to various new projects that benefit from the same extended API.
I'm trying to clean this up for the sake of maintainability, and publish a Kotlin library of these extension functions to our company's Artifactory instance.
So far everything is going as planned. The library is successfully built on Jenkins, and published to Artifactory using the Artifactory Jenkins plugin.
The issue I'm running in to is that consumers of the dependency also have to include implementation org.json:json:<version>
in their build file.
Gradle is smart enough to resolve transitive dependencies, so I suspect I'm not declaring them correctly.
I decided to start by trying Gradle Module Metadata rather than a POM file since I'm not doing anything Maven-centric.
Here's what that file looks like:
{
"formatVersion": "1.1",
"component": {
"group": "com.example.extensions",
"module": "ext-org-json",
"version": "0.0.1"
},
"createdBy": {
"author": "[email protected]",
"gradle": {
"version": "6.7"
}
},
"variants": [
{
"name": "api",
"attributes": {
"org.gradle.usage": "java-api",
"org.gradle.category": "library",
"org.gradle.libraryelements": "jar"
},
"dependencies": [
{
"group": "org.json",
"module": "json",
"version": "20201115",
"reason": "This module exists to extend its API."
},
{
"group": "org.jetbrains.kotlin",
"module": "kotlin-stdlib",
"version": "1.4.21"
}
]
}
]
}
Unfortunately, this does not seem to help. Consumers still don't get the benefit of Gradle fetching the org.json
dependency for them.
Could someone point me in the right direction to do this properly? Gradle Metadata, POM file, or otherwise, any help is appreciated!
question from:
https://stackoverflow.com/questions/65836572/publsihing-kotlin-library-so-that-gradle-resolves-transitive-dependencies 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…