PaperMC/paperweight

Add a way to configure 'How old the cache is considered outdated'

TetraTheta opened this issue · 1 comments

Sorry if this is hard to understand. This doesn't happen every day, so I'm writing this from my vague memory.


I'm using paperweight-userdev for my plugin.
I don't open my IDE (IntelliJ IDEA) very often. Sometimes, I open it 4–5 days after its last launch. 

When the IDE is launched, it tries to refresh my project's dependencies. This is expected behavior, and I don't have any problem with it.  
But this process makes paperweight to download the latest 'information' about Minecraft.

Here's an example (sort of) output on it. 

// Please note that this output is taken after running 'cleanCache' task from paperweight and refreshing Gradle dependencies!
// This would not be the same output that I had, but this is similar to what I had.
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
:executing 'download minecraft manifest'
:executing 'download minecraft version manifest'
:executing 'download vanilla minecraft server jar'
:executing 'download mojang server mappings'
:executing 'extract libraries and server from downloaded jar'
:executing 'filter vanilla server jar'
:executing 'generate mappings'
:executing 'remap minecraft server jar'
:executing 'fix minecraft server jar'
:executing 'access transform minecraft server jar'
:executing 'decompile transformed minecraft server jar'
:executing 'apply patches to decompiled jar'
:executing 'apply mojang mapped paperclip patch'
:installed server artifacts to cache
:done setting up paperweight userdev workspace for minecraft 1.19.4

This process takes some time, and it stops me from writing any code for my plugin because Gradle is still working on updating the project's dependencies.

This is an 'expected behavior', because the snapshot that has been downloaded would be considered outdated after a few days.
But since this process makes me stop writing code, I want this behavior to happen less often.

What I want

I want a gradle property about 'how old the cache is considered as outdated' to be used in gradle.properties, like paperweight.experimental.sharedCaches=true which shares cache 'globally'.

Maybe something like paperweight.experimental.outdateCacheInDays. If it is set to 7 like paperweight.experimental.outdateCacheInDays=7, the cache generated more than 7 days ago will be considered as outdated, so paperweight will try to re-generate the cache. If the cache is generated less than 7 days, paperweight will not try to re-generate the cache and just re-use it.


I know that this request is a very special use case. However, every time my IDE launches, it takes too much time (in my standards) to create a new cache, which is extremely inconvenient for me.

Thank you for reading this. If you need any other information, feel free to ask about it.

This can be done with this:

dependencies {
  paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT")
}
configurations.paperweightDevelopmentBundle {
  resolutionStrategy.cacheChangingModulesFor(7, "days")
}

Thanks powercas_gamer in PaperMC Discord for this information!