I recently found out that Gradle’s artifact transf...
# community-support
s
I recently found out that Gradle’s artifact transforms are unusable for the purposes of caching transformed artifacts and saving space (as evidenced by https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1601 and https://github.com/gradle/gradle/issues/30968). Is there perhaps some existing framework/plugin/library to implement such a cache that I could use in my plugin? I need to download a zip, unzip it to some shared location (user or project-specific), possibly with the use of native zip program (to handle symlinks and permissions) and ideally automatically remove old downloads after some time. And of course only download and unzip if there’s no existing cached entry. Does anybody know of any library to do that?
a
nope :( IJPGP uses a localhost server to intercept the requests and transforms them there - if I had to do it, I'd use it as inspiration https://github.com/JetBrains/intellij-platform-gradle-plugin/blob/v2.0.1/src/main/kotlin/org/jetbrains/intellij/platform/gradle/services/ShimManagerService.kt
🤯 1
s
I think this is not the functionality I need. In my case I can download zips from a Maven repository just fine but I need to cache the unzipped artifacts. This shim stuff in IJPGP is only for downloading AFAICT.
v
As long as the inputs (including classpath) for the artifact transform does not change, it should do exactly what you intend. If any input changes, output could of course be different, so the previous result can of course not be reused. Cleanup of artifact results should hopefully also be done by Gradle periodically like for the other caches.
s
Well the classpath is important because it's not the classpath of the transform but of the build script. So sharing transform outputs between projects doesn't happen.
Any time you make a change to the build script dependencies, like updating the version of a totally unrelated plugin, you get a new classpath and a new cache key.
a
hmm possibly you could use a regular Task instead. Use a specific Configuration for the to-be-transformed dependencies, the task transforms them, and then forward the transformed dependencies. However, it's hard to coordinate with a cache that is shared between subprojects.
KGP has the same problem. There are lots of tools required for KMP development (NodeJS, kotlin-native-prebuilt, Wasm runtimes). And there's no good 'toolchain manager' solution.
this issue is relevant, and links a proposal that uses some Gradle internals https://github.com/gradle/gradle/issues/32225
s
Thanks, I’ll have a look
It is used by a number of plugins to bootstrap external tools such as node, terraform, opentofu, doxygen, andwebdrivers for selenium. It can also be used to download nearly any ZIP file and unpack it. What it will not do is delete old distributions by version, but it will share the same download between projects as it caches everything inside
~/.gradle.
s
@ysb33r just a heads up, I tried to use the library but the docs seem to be incorrect about grolifant5-api, it's not available on Maven Central. https://repo.maven.apache.org/maven2/org/ysb33r/gradle/grolifant5-api/5.8.1/grolifant5-api-5.8.1.pom gives 404. Docs here: https://grolifant.ysb33r.org/grolifant-plugin-development/5.8.1/bootstrap.html
y
Thanks. I'll have a look as it should be there.
s
I used this dependency instead in my plugin:
Copy code
implementation("org.ysb33r.gradle:grolifant5-core:5.8.1")
y
🤦 the docs are wrong. Will get it fixed.
👍 1