-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maven-publish: generated pom misses version for compileOnlyApi dependency when it is managed with a platform #25712
Comments
…it versions for com.google.auto.service:auto-service-annotations Fixes apache#6041 See gradle/gradle#25712
Thank you for your interest in Gradle! This is the intended behavior, and there’s no plan to change it. This issue will be closed. Gradle also generates a
If maven has an issue with this kind of file, then you can instruct Gradle to publish resolved version as described here. |
@ov7a , could you please clarify why this is not going to be fixed?
It does not help. plugins {
id("java-library")
id("maven-publish")
}
repositories {
mavenCentral()
}
project(":platform") {
apply(plugin = "java-platform")
// Follows https://docs.gradle.org/current/userguide/java_platform_plugin.html#ex-recommend-versions-in-a-platform-module
dependencies {
constraints {
api("com.google.auto.service:auto-service-annotations:1.1.1")
}
}
}
dependencies {
compileOnlyApi("com.google.auto.service:auto-service-annotations")
// Follows https://docs.gradle.org/current/userguide/java_platform_plugin.html#ex-get-recommendations-from-a-platform
api(platform(project(":platform")))
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
} yields <dependencies>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
<scope>compile</scope>
</dependency>
</dependencies> In other words, |
Interestingly, the following two options result in resolved versions: usage("java-api") {
fromResolutionOf("compileClasspath")
} or usage("java-api") {
fromResolutionResult()
} So the culprit is:
It would probably be better to suggest a workable workaround in the documentation rather than something that creates invalid pom files. What do you think of versionMapping {
usage("java-api") {
fromResolutionResult()
}
usage("java-runtime") {
fromResolutionResult()
}
}
...
java {
consistentResolution {
useRuntimeClasspathVersions()
}
} |
@vlsi sounds reasonable. I'll reopen it as a documentation issue then. |
My initial thought was like "I have |
To be honest, I'm surprised |
@jvandort , However, now I would try a different approach: I keep the generated |
@ov7a , after a bit of thought, I think So the sole fix here is to avoid the sample The case for using |
@ov7a , I am closing the issue as the one with the original title is not really valid. A note for the readers: Gradle generates both "versionless dependency and dependencyManagement / import", and Maven is able to resolve that pom without issues. At the same time, I think converting the discussion into "update documentation for maven-publish" would be confusing for everybody else, so I would rather open another issue for documentation purposes. |
@vlsi ok, thank you! |
Expected Behavior
Gradle resolves
compileOnlyApi
dependency, so it should use the same version for the generatedpom.xml
.Current Behavior
Currently, Gradle produces
pom.xml
without a version which triggers issues with Maven: #25705Context (optional)
Steps to Reproduce
Test case:
./gradlew generatePomFileForMavenJavaPublication && cat build/publications/mavenJava/pom-default.xml
Actual output. The issue is that
<version>
is missing.Gradle version
8.2.1
Build scan URL (optional)
https://gradle.com/s/xvtzfxb7oy75y
Your Environment (optional)
No response
The text was updated successfully, but these errors were encountered: