$ gradle distZip $ gradle download $ tar cvzf deps.tgz ~/.gradle/caches/modules-2/files-2.1
Created
October 23, 2018 13:32
-
-
Save mindscratch/81c4b9997d7003ce2f88cf8a82b40832 to your computer and use it in GitHub Desktop.
gradle - download dependencies
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
apply plugin: 'application' | |
mainClassName = "com.gmigdos.utils.gradle.DownloadDependencies" | |
jar { | |
baseName = 'DownloadDependencies' | |
version = '0.1.0' | |
} | |
repositories { | |
mavenCentral() | |
// Add other repositories here | |
} | |
dependencies { | |
// Add your project's dependencies here | |
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.434', ext: 'jar' | |
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.434', ext: 'pom' | |
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.434', classifier: 'sources' | |
} | |
task download { | |
inputs.files configurations.runtime | |
outputs.dir "${buildDir}/download" | |
doLast { | |
def componentIds = configurations.runtime.incoming.resolutionResult.allDependencies.collect { it.selected.id } | |
ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery() | |
.forComponents(componentIds) | |
.withArtifacts(JvmLibrary, SourcesArtifact) | |
.execute() | |
def sourceArtifacts = [] | |
result.resolvedComponents.each { ComponentArtifactsResult component -> | |
Set<ArtifactResult> sources = component.getArtifacts(SourcesArtifact) | |
println "Found ${sources.size()} sources for ${component.id}" | |
sources.each { ArtifactResult ar -> | |
if (ar instanceof ResolvedArtifactResult) { | |
sourceArtifacts << ar.file | |
} | |
} | |
} | |
copy { | |
from configurations.runtime | |
from sourceArtifacts | |
into "${buildDir}/download" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment