Skip to content
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

Unable to use a Provider<java.nio.file.Path> as an artifact for the maven-publish plugin #15711

Closed
Adrodoc opened this issue Jan 7, 2021 · 3 comments · Fixed by #18715
Closed
Labels
a:bug @core Issue owned by GBT Core in:publishing-plugins ivy-publish maven-publish

Comments

@Adrodoc
Copy link

Adrodoc commented Jan 7, 2021

Using a Provider<java.nio.file.Path> as an artifact for the maven-publish-Plugin does not work in Gradle 6.6 anymore. Using a Path (sun.nio.fs.WindowsPath) instance directly still works.

Expected Behavior

The file my-artifact.txt should be published into the local maven repository.

Current Behavior

You get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generatePomFileForArtifactoryPublication'.
> Cannot convert provided value (my-artifact.txt) to a file.

Context

This works in Gradle 6.5.1 and below, but stops working in Gradle 6.6. I also tested all newer versions up to 6.7.1, they are all affected.

May be related to #11054.

Steps to Reproduce

Execute gradlew publishToMavenLocal in this project: gradle-issue-15711.zip

For reference here is the build.gradle:

apply plugin: 'maven-publish'

wrapper { gradleVersion = '6.6' }

group = 'org.gradle'
ext.artifactId = 'issue-15711'
version = '1.0.0'

publishing {
  publications {
    artifactory(MavenPublication) {
      artifactId = project.artifactId
      // Works in Gradle 6.5.1 and Gradle 6.6
//      artifact java.nio.file.Path.of('my-artifact.txt')

      // Works in Gradle 6.5.1 but not Gradle 6.6
      artifact provider { java.nio.file.Path.of('my-artifact.txt') }
    }
  }
}

Your Environment

Build scan URL: https://gradle.com/s/qxutkwm5vnfdq

user@PC MINGW64 /c/.../gradle-issue-15711
$ ./gradlew -v

------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------

Build time:   2020-08-10 22:06:19 UTC
Revision:     d119144684a0c301aea027b79857815659e431b9

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          1.8.0_162 (Oracle Corporation 25.162-b12)
OS:           Windows 7 6.1 amd64
@jjohannes jjohannes added in:publishing-plugins ivy-publish maven-publish @core Issue owned by GBT Core a:bug and removed a:regression This used to work labels Mar 23, 2021
@jjohannes jjohannes added this to the 7.1 RC1 milestone Mar 29, 2021
@ljacomet ljacomet removed this from the 7.1 RC1 milestone May 3, 2021
@Adrodoc
Copy link
Author

Adrodoc commented Aug 10, 2021

Is there any update on this? Why was it removed from the Milestone?

@Adrodoc
Copy link
Author

Adrodoc commented Aug 10, 2021

A workaround is to use a Closure:

artifact { java.nio.file.Path.of('my-artifact.txt') }

Or wrap the provider in a Closure:

artifact { provider { java.nio.file.Path.of('my-artifact.txt') } }

@Adrodoc
Copy link
Author

Adrodoc commented Sep 14, 2021

This bug is quite annoying for me as it prevents a straight forward update to Gradle's Lazy Configuration, which would be a big improvement. I don't want to tell all my users that they now have to add a workaround for this bug.
I would be very grateful if this gets fixed and it seems like it can't be that difficult. It would at least be helpful to know why this was removed from the milestone 7.1 RC1.

octylFractal added a commit that referenced this issue Oct 20, 2021
This gives us many of these conversions for free, reducing duplicated
code. This also fixes #15711.
octylFractal added a commit that referenced this issue Oct 26, 2021
This gives us many of these conversions for free, reducing duplicated
code. This also fixes #15711.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug @core Issue owned by GBT Core in:publishing-plugins ivy-publish maven-publish
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants