Created
September 7, 2019 21:29
-
-
Save jrodbx/eaa1fed6d958fc6eb23f10a75fe3f125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1) Change agpVersion | |
* 2) Run './gradlew dumpSources' | |
* 3) Check changeset into source control | |
*/ | |
def agpVersion = 'UPDATE_THIS' | |
repositories { | |
google() | |
jcenter() | |
} | |
configurations { | |
agp | |
} | |
dependencies { | |
agp "com.android.tools.build:gradle:${agpVersion}" | |
} | |
task dumpSources { | |
inputs.files configurations.agp | |
outputs.dir "com.android.tools.build/$agpVersion/" | |
doLast { | |
def componentIds = configurations.agp.incoming.resolutionResult.allDependencies | |
.findAll { it.selected.id.group.startsWith('com.android.tools') } | |
.collect { it.selected.id } | |
.toSet() | |
ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery() | |
.forComponents(componentIds) | |
.withArtifacts(JvmLibrary, SourcesArtifact) | |
.execute() | |
result.resolvedComponents.each { ComponentArtifactsResult component -> | |
Set<ArtifactResult> sources = component.getArtifacts(SourcesArtifact) | |
sources.each { ArtifactResult ar -> | |
println "Found ${ar.file}." | |
if (ar instanceof ResolvedArtifactResult) { | |
def group = ar.id.componentIdentifier.group | |
def module = ar.id.componentIdentifier.module | |
def version = ar.id.componentIdentifier.version | |
println "Extracting to com.android.tools.build/$agpVersion/$group/$module/$version." | |
copy { | |
from zipTree(ar.file) | |
into file("com.android.tools.build/$agpVersion/$group/$module/$version") | |
} | |
println "Done extracting $module." | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment