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.

`artifactoryDeploy` uses old artifact information

See original GitHub issue

Describe the bug After changing the version of my artifact, the artifactoyDeploy task attempts to deploy to Artifactory using outdated build info.

This appears to be caused by bad caching introduced in #301. That PR introduced a new task called extractModuleInfo, which declares its output but not its input. That causes it to be considered up-to-date if the moduleInfo.json file has not changed, even if the input values have changed. So although the artifactoryPublish task correctly declares all of its inputs, the module information still ends up being outdated.

To Reproduce Using this build.gradle file:

plugins {
    id 'java'
    id 'maven-publish'
    id 'com.jfrog.artifactory' version '4.17.2'
}

task("writeSources") {
    doLast {
        file("src/main/java").mkdirs()
        file("src/main/java/TestClass.java").write("class TestClass { }")
    }
}

version = System.getenv("VERSION")
repositories { jcenter() }
tasks.compileJava { dependsOn(writeSources) }

publishing.publications.create("mavenJava", MavenPublication) {
    artifact tasks["jar"]
}

artifactory {
    publish {
        defaults {
            publications "mavenJava"
        }
    }
}
  1. VERSION=1.2.3 ./gradlew jar extractModuleInfo
  2. cat build/moduleInfo.json -> "id" : ":art:1.2.3"
  3. VERSION=7.8.9 ./gradlew jar extractModuleInfo
  4. cat build/moduleInfo.json -> "id" : ":art:1.2.3"

The moduleInfo.json file was not updated with the new version information. Note that this caching bug also affects the build-info.json file, but that is harder to demonstrate without actually performing the publish to a real Artifactory instance.

Expected behavior The publish should only use the current module info, not module info that was collected in previous builds.

Versions

  • Gradle Artifactory plugin version: 4.17.2
  • Operating system: macOS Mojave (10.14.5)
  • Artifactory Version: 7.4.3

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ghalecommented, Oct 14, 2020

It probably makes sense to just leave this task always out-of-date for now. The input for this task is the Module object, which isn’t a Gradle-specific object, so adding nested annotations wouldn’t make sense. We’d need to interrogate the Module model and then produce something that could be hashed as an input, which is basically what the json serialization does, so the only work we would save by making it up-to-date is the write itself.

Stepping back, the whole point of this task is to share the Module info across projects in a parallel-safe way that is compatible with older versions of Gradle. This is one of the use cases that build services are designed to solve, but these are only available in Gradle 6+. Perhaps once support is dropped for older versions of Gradle we could just migrate this functionality to a build service and get rid of these tasks altogether. For now, maybe we just leave these tasks non-incremental.

2reactions
davidnelson-hmscommented, Oct 1, 2020

One of Gradle’s fundamental value propositions is incremental build. It’s literally the first bullet point in the user guide article “What is Gradle?”. Needing to run clean in order for the build output to be correct violates this fundamental principle. Moreover, if clean for some reason is necessary to ensure correct behavior, it should be forced; as it stands the build can silently use the wrong version, which is a very serious bug that needs to be mitigated somehow

If a task cannot accurately predict what its inputs and outputs are, then the correct thing for it to do is to not declare any outputs. That way, it will never be cached, and will always run so it is up-to-date. Doing that might solve the current problem with extractModuleInfo.

However, as I said in the issue description, I don’t think it is the case that this task cannot be cached correctly, because the artifactoryPublish task (which was essentially doing the same work as extractModuleInfo prior to #301) declares its inputs and outputs correctly, and does not suffer from the same caching bug. Only when we update our plugin version past 4.13.0, where extractModuleInfo was introduced, do we experience this bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle Artifactory Plugin - JFrog - JFrog Documentation
The Gradle Artifactory Plugin allows you to deploy your build artifacts and build information to Artifactory and also to resolve your build ...
Read more >
Artifactory deploy issue - maven - Stack Overflow
I am deploying artifacts to jfrog artifactory in cloud which is throwing ... If you remember the previous permissions the user then you...
Read more >
Failing to publish all artifacts to Artifactory using the JFrog plugin
I have the Artifactory plugin configured for my multiproject build. It works just fine for publishing the artifacts for any individual subproject.
Read more >
4 ways to upload a JAR to a JFrog Artifactory repository
If there are problems uploading an artifact using the drag-and-drop features of the administrative console, you might want to get those ...
Read more >
Maven – Guide to uploading artifacts to the Central Repository
javadoc and sources for IDE lookup,; PGP signature,; minimum POM information: There are some requirements for the minimal information in the POMs that...
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