File size: 1,531 Bytes
89995d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Image build only (Dockerfile): puts the -sources.jar of the app's JitPack-hosted libraries (org.fossify:* and
// com.github.*, direct and transitive, on the foss debug and release runtime classpaths) into the Gradle cache, so
// they can be read offline the way an IDE shows a dependency's sources. Missing sources are listed, not fatal.
allprojects { p ->
    p.afterEvaluate {
        if (p.path != ':app') return
        p.tasks.register('benchCacheSources') {
            doLast {
                def ids = new TreeSet<String>()
                ['fossDebugRuntimeClasspath', 'fossReleaseRuntimeClasspath'].each { name ->
                    p.configurations.getByName(name).incoming.resolutionResult.allComponents.each { c ->
                        def id = c.moduleVersion
                        def group = id?.group ?: ''
                        if (group == 'org.fossify' || group.startsWith('com.github.')) {
                            ids << "${id.group}:${id.name}:${id.version}".toString()
                        }
                    }
                }
                ids.each { coord ->
                    def cfg = p.configurations.detachedConfiguration(p.dependencies.create("${coord}:sources@jar".toString()))
                    cfg.transitive = false
                    def files = cfg.incoming.artifactView { lenient(true) }.files.files
                    println(files ? "sources ${coord} -> ${files*.name.join(',')}" : "sources ${coord} -> none")
                }
            }
        }
    }
}