This message was deleted.
# community-support
s
This message was deleted.
1
w
I think the simplest solution to your problem would be to split your transform into two: One that extracts and the second one that selects the files from the extracted directory. BTW, I am not sure if it is a good idea to mark this extract/select transform cacheable, since it will be doing mostly IO anyway.
v
Do you actually need the extracted directory somewhere except as intermediate step? I guess no, then it might be better to either extract to a temporary directory instead of
outputs.dir
and then copy from that temporary directory to the
outputs.file
return value. Or alternatively do not extract at all, but directly just pull the embedded jars out using a
JarInputStream
or similar, directly just writing the intended output files unless
findSpecificJars
need to look inside the files to find the correct ones.
j
@wolfs That’s interesting idea — and probably will solve another case of mine in the future. But how to properly play with attributes now? As for now I have https://gradle-community.slack.com/archives/CAHSN3LDN/p1692288331275559 About caching — isn’t it fine to cache the unarchive operation? It takes a bit of time and resources to extract ~1GB zip archive. @Vampire Actually I need the whole directory also for other purposes. IJ SDK brings not only jars used for development, but also bundles JBR used for running guest IDE — so I have to keep everything as it is.
v
Then maybe do as Stefan suggested and split it in two transformations. You will have two transformations registered. E.g. one that transforms zipped->extracted and one that transforms extracted->individual-jars. If you then request somewhere extracted, you get the extracted directory, if you request somewhere individual-jars, you will get the individual jars. The transformer logic will then automatically chain those transformations to get the intended end-result.
About caching, the end-result of a cachable action (task or transform) will be packed into a zip and the zip put to the cache. And on cache-reuse, that ZIP with the output will be extracted. That's also the reason why for example archive tasks are not declared cacheable as you do not really gain anything caching them, but just add some overhead for the caching.
👌 1
j
Awesome, works as intended! Thank you both! PS. it’s not cacheable anymore. 🙂
👌 1
I wonder if transformers could be used for instrumentation. 🤔
v
Of course
Isn't that even the example in the docs?
Ah, no, that was in the variant-aware sharing between projects example
1
j
As for now, we have a problem that, when debugging, IDE leads to compiled&instrumented classes instead of attached sources — because of some mismatches. Maybe that will help us somehow.
Geez, that’d make my life way easier. Instrumentation is a nightmare on so many levels.
v
Iirc you will have a problem when navigating to sources though, as the sources will either be not found or give the non-instrumented ones without way to adapt the sources too.
I think this is the relevant issue: https://github.com/gradle/gradle/issues/19207