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 as an artifact for the maven-publish plugin #11054

Closed
Adrodoc opened this issue Oct 16, 2019 · 3 comments
Closed

Unable to use a Provider as an artifact for the maven-publish plugin #11054

Adrodoc opened this issue Oct 16, 2019 · 3 comments
Assignees
Milestone

Comments

@Adrodoc
Copy link

@Adrodoc Adrodoc commented Oct 16, 2019

Using a Provider as an artifact for the maven-publish-Plugin does not work in Gradle 5.6 anymore. Using a File instance still works despite the error message (see current behaviour) suggesting otherwise.

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:
Could not determine the dependencies of task ':publishArtifactoryPublicationToMavenLocal'.
> Cannot convert C:\...\gradle-issue-11054\my-artifact.txt to a task.
  The following types/formats are supported:
    - A Task instance
    - A TaskReference instance
    - A Buildable instance
    - A TaskDependency instance
    - A Provider that represents a task output
    - A Provider instance that returns any of these types
    - A Closure instance that returns any of these types
    - A Callable instance that returns any of these types
    - An Iterable, Collection, Map or array instance that contains any of these types

Context

This works in Gradle 5.5.1 and below, but stops working in Gradle 5.6.

Steps to Reproduce

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

For reference here is the build.gradle:

apply plugin: 'maven-publish'

wrapper { gradleVersion = '5.6' }

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

publishing {
  publications {
    artifactory(MavenPublication) {
      artifactId = project.artifactId
      // Works in Gradle 5.5.1 and Gradle 5.6
//      artifact file('my-artifact.txt')

      // Works in Gradle 5.5.1 but not Gradle 5.6
      artifact provider{ file('my-artifact.txt') }
    }
  }
}

Your Environment

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

------------------------------------------------------------
Gradle 5.6
------------------------------------------------------------

Build time:   2019-08-14 21:05:25 UTC
Revision:     f0b9d60906c7b8c42cd6c61a39ae7b74767bb012

Kotlin:       1.3.41
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          1.8.0_162 (Oracle Corporation 25.162-b12)
OS:           Windows 7 6.1 amd64
@ljacomet ljacomet added in:dependency-management in:publishing-plugins labels Oct 18, 2019
@ljacomet ljacomet added this to the 6.1 RC1 milestone Nov 12, 2019
@jjohannes jjohannes removed this from the 6.1 RC1 milestone Nov 12, 2019
@jjohannes jjohannes added this to the 6.0.1 milestone Nov 12, 2019
jjohannes added a commit that referenced this issue Nov 12, 2019
This used to work in Gradle 5.5 (see #11054).

The combination of #9467 and #6775 broke this.

A builtBy dependency is added if the artifact is a TaskDependencyContainer,
which all Providers are (#9467). This dependency was silently doing
nothing in case of a plain File/String. This became an error (#6775)
because a File/String is nothing that can be resolved to a task.

We now only add a builtBy dependency, if the provider value or content is
actually produced by a task.
@jjohannes
Copy link
Contributor

@jjohannes jjohannes commented Nov 12, 2019

Thanks for reporting this @Adrodoc. This is indeed a regression caused by the combination of #9467 and #6775 I believe. Fix is in the making.

jjohannes added a commit that referenced this issue Nov 12, 2019
…11329)

This used to work in Gradle 5.5 (see #11054).

The combination of #9467 and #6775 broke this.

A builtBy dependency is added if the artifact is a TaskDependencyContainer,
which all Providers are (#9467). This dependency was silently doing
nothing in case of a plain File/String. This became an error (#6775)
because a File/String is nothing that can be resolved to a task.

We now only add a builtBy dependency, if the provider value or content is
actually produced by a task.
@jjohannes
Copy link
Contributor

@jjohannes jjohannes commented Nov 12, 2019

The fix on master for 6.1

Keeping this open in case there is a 6.0.1- pick 62cfd99

jjohannes added a commit that referenced this issue Nov 13, 2019
*Updated solution based on feedback to #11329*

This used to work in Gradle 5.5 (see #11054).

The combination of #9467 and #6775 broke this.

A builtBy dependency is added if the artifact is a TaskDependencyContainer,
which all Providers are (#9467). This dependency was silently doing
nothing in case of a plain File/String. This became an error (#6775)
because a File/String is nothing that can be resolved to a task.

We now only add a builtBy dependency, if the provider value or content is
actually produced by a task.
jjohannes added a commit that referenced this issue Nov 13, 2019
*Updated solution based on feedback to #11329*

This used to work in Gradle 5.5 (see #11054).

The combination of #9467 and #6775 broke this.

A builtBy dependency is added if the artifact is a TaskDependencyContainer,
which all Providers are (#9467). This dependency was silently doing
nothing in case of a plain File/String. This became an error (#6775)
because a File/String is nothing that can be resolved to a task.

We now only add a builtBy dependency, if the provider value or content is
actually produced by a task.
@jjohannes
Copy link
Contributor

@jjohannes jjohannes commented Nov 13, 2019

Picked to release for 6.0.1

@big-guy big-guy changed the title Using a Provider as an artifact for the maven-publish-Plugin does not work in Gradle 5.6 anymore Cannot use a Provider as an artifact for the maven-publish plugin Nov 15, 2019
@big-guy big-guy changed the title Cannot use a Provider as an artifact for the maven-publish plugin Unable to use a Provider as an artifact for the maven-publish plugin Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants