This message was deleted.
# caching
s
This message was deleted.
v
I personally always have the version to build hard-coded. I hate dynamically calculated versions, that are then dependent on VCS being present and usable for example. This makes builds non-reproducible and sometimes even not possible e.g. if JGit is used and you are in a Git worktree, or when building from source export, or when having a shallow clone, .... 🙂 But other than that, you should check why exactly the cache cannot be used. If you for example generate the version into a properties file that you pack as resource, you might need to configure the normalization and so on. If the version just influences the jar filenames I think it should not influence cacheability, but I might remember wrongly.
j
i can confirm that the jar file names do effect the cacheability
even if contents are the same
i did a cache debug and saw it
this is in the context of running tests on modules that depend on other modules (project dependencies) in the same build
t
I like to set:
Copy code
tasks.withType<Jar>().configureEach {
    // Never include the version in the JAR filenames
    archiveVersion.set(null as String?)
}
to avoid things accumulating in build/libs, but that also helps with incremental builds.
j
oh interesting
does that effect maven publishing?
t
It shouldn't, but I can't remember if I ever actually tried 🤷‍♂️
j
Ok. Thanks for sharing ill investigate
Yeah, i think it does mess up maven publishing. it can publish, but resolution will be messed up
actually i suspect its not the file name thats the problem for caching, but the contents. b/c the jar contains the manifest file that has the version number in it
t
Ha, sounds more logical! Have a look at https://docs.gradle.org/current/userguide/build_cache_concepts.html#filter_runtime_classpath then (but that means you're explicitly configuring the Jar tasks to add the version to the manifest, right?)
j
Yeah we are
That filter thing might be just what we need. Thanks!
hmm, caching is still not working. Now i am starting the file name matters as well
nope, not the name. there was another file i needed to exclude:
Copy code
normalization {
        runtimeClasspath {
            metaInf {
                ignoreAttribute("Implementation-Version")
            }
            ignore("**/pom.xml")
        }
    }
}