Converting into regular gradle
That’s not “regular gradle”, it is Groovy DSL.
“regular” I would say is Kotlin DSL as it is the default one since quite some time.
Also, by using findByName you introduce ordering constraints and additionally destroy laziness.
And also it only works for those projects where the Gradle version is new enough to support the APIs you use but will fail for all builds that are older.
If you are fine with all those problems and drawbacks it might be ok.
and it puts these files into a <subproject>/build/compile-dependency-sources directory, great!
If you execute the collectSources task, yes.
Is there a way to have these instead put alongside the jars in ~/.gradle/caches? That is where an LSP may expect to find them.
No.
Well, you can surely program it, but that will pollute the Gradle cache and you really, really should not do that.
oh, wait a minute, it is putting them in the caches directory.
Of course, different projects or working trees could need them. That is where Gradle caches the downloaded files and uses it from if possible. That they are also landing in build/compile-dependency-sources is because you have a Sync task that copies them over from their cache location to that directory.
Albeit with a uuid folder substructure.
No, checksum.
I don’t need the final compile-dependency-sources copy of it all though, so I guess I just drop the from and into
If you do that, nothing will happen, as you have a Sync task that has no inputs and thus will not do any work, neither will the sources jars be downloaded to the cache.
You can probably have some task that just has them as inputs like
p.tasks.register('collectSources') {
inputs.files(
cc.incoming.artifactView {
withVariantReselection()
attributes {
attribute Category.CATEGORY_ATTRIBUTE, p.objects.named(Category, Category.DOCUMENTATION)
attribute DocsType.DOCS_TYPE_ATTRIBUTE, p.objects.named(DocsType, DocsType.SOURCES)
attribute Bundling.BUNDLING_ATTRIBUTE, p.objects.named(Bundling, Bundling.EXTERNAL)
}
}.files
)
outputs.upToDateWhen { true }
doLast { }
}
which should trigger the files to be downloaded to the cache I think if having them there is enough for you.
(the last two lines need to stay, I think. Without the doLast line the task might be skipped for not having work without checking the inputs, without the outputs line the task can never be up-to-date.