Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. /**
  2. * 1) Change agpVersion
  3. * 2) Run './gradlew dumpSources'
  4. * 3) Check changeset into source control
  5. */
  6. def agpVersion = 'UPDATE_THIS'
  7.  
  8. repositories {
  9. google()
  10. jcenter()
  11. }
  12.  
  13. configurations {
  14. agp
  15. }
  16.  
  17. dependencies {
  18. agp "com.android.tools.build:gradle:${agpVersion}"
  19. }
  20.  
  21. task dumpSources {
  22. inputs.files configurations.agp
  23. outputs.dir "com.android.tools.build/$agpVersion/"
  24.  
  25. doLast {
  26. def componentIds = configurations.agp.incoming.resolutionResult.allDependencies
  27. .findAll { it.selected.id.group.startsWith('com.android.tools') }
  28. .collect { it.selected.id }
  29. .toSet()
  30. ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery()
  31. .forComponents(componentIds)
  32. .withArtifacts(JvmLibrary, SourcesArtifact)
  33. .execute()
  34. result.resolvedComponents.each { ComponentArtifactsResult component ->
  35. Set<ArtifactResult> sources = component.getArtifacts(SourcesArtifact)
  36. sources.each { ArtifactResult ar ->
  37. println "Found ${ar.file}."
  38. if (ar instanceof ResolvedArtifactResult) {
  39. def group = ar.id.componentIdentifier.group
  40. def module = ar.id.componentIdentifier.module
  41. def version = ar.id.componentIdentifier.version
  42. println "Extracting to com.android.tools.build/$agpVersion/$group/$module/$version."
  43. copy {
  44. from zipTree(ar.file)
  45. into file("com.android.tools.build/$agpVersion/$group/$module/$version")
  46. }
  47. println "Done extracting $module."
  48. }
  49. }
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement