question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProjectsEvaluatedBuildListener creates/configures the artifactoryPublish task too early

See original GitHub issue

The ProjectsEvaluatedBuildListener has an afterEvaluate hook which configures the artifactoryPublish task. This is a problem for Gradle Plugin developers who apply the com.jfrog.artifactory plugin as part of their library which is then used by other projects.

Our library itself does its artifactory configuration within an afterEvaluate block because it needs to read project build information before it can correctly configure the publications needed. The problem I’m having after version 4.4.9 of the plugin is that I have no control over the ordering of afterEvaluate blocks, so the ProjectsEvaluatedBuildListener block is executing before mine, so when the artifactoryPublish task runs there are publications there but the generatePomFileFor... task isn’t there as a task dependency, so the consuming application’s build fails when running artifactoryPublish.

My code:

project.afterEvaluate { proj ->
  // Artifactory has already been configured on the root project by the com.mycompany.base plugin
  // Just need to add the main publication
  def configurationsForPom = getConfigurationsForMavenPom()
  def bootJarTask = proj.tasks.findByName 'bootJar'  // Spring boot 2 disables the jar task & instead has its own bootJar task. This is 1 reason why this is in an afterEvaluate block so that the full build file can be evaluated before creating the publication
  def jarTask = bootJarTask?.enabled ? bootJarTask : proj.tasks['jar']

  proj.configure(proj.publishing) {
    publications {
      mainJava(MavenPublication) {
        artifactId "${ -> proj.myExtension.artifactId}"
        // Change due to https://github.com/gradle/gradle/issues/1061
        // from proj.components.java
        artifact jarTask
	artifact proj.tasks[SOURCESJAR_TASK_NAME]
	artifact proj.tasks[JAVADOCJAR_TASK_NAME]

        pom.withXml {
          // Another reason this needs to be in an afterEvaluate block
          PluginHelper.fixMavenPomDependencySection(proj, asNode(), *configurationsForPom)
	}
      }
    }
  }

  // And then configure the artifactoryPublish task to publish the main publication
  proj.configure(proj.tasks['artifactoryPublish']) {
    publications 'mainJava'
  }
}

This is what I’m seeing when my application applies my plugin and then runs artifactoryPublish:

:artifactoryPublish
:artifactoryDeploy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':artifactoryDeploy'.
> File '/jenkins_home/03/d3445737/workspace/folder/project 2.1/project/subproject/target/publications/mainJava/pom-default.xml' does not exist, and need to be published from publication mainJava

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oehmecommented, May 10, 2018

Note that this issue is unrelated to the problem described in https://github.com/gradle/gradle/issues/4783. Let’s focus on that one first and then continue with this one.

1reaction
edeandreacommented, May 10, 2018

Thanks @AlexeiVainshtein for the update. I’ll wait and see what comes from this. Until there is some resolution we are stuck on version 4.4.9 of the plugin.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[GAP-289] ProjectsEvaluatedBuildListener creates ... - JFrog
task isn't there as a task dependency, so the consuming application's build fails when running artifactoryPublish. project.afterEvaluate { proj ...
Read more >
Gradle Artifactory Plug-in - Issues - Jira - Atlassian
ProjectsEvaluatedBuildListener creates/configures the artifactoryPublish task too early. Alexei Vainshtein. Eric Deandrea. 4 - Normal. Resolved.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found