Skip to content

Commit 6643a15

Browse files
committed
Added download of dependency sources
1 parent 4660b72 commit 6643a15

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

build.gradle

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ def downloadContainerName = getProjectVersionAsBetaOrRelease(false)
2828
def sscPluginVersion = getProjectVersionAsPlainVersionNumber()
2929

3030
repositories {
31-
mavenLocal()
31+
mavenCentral()
3232
// repository with fortify artifacts
3333
maven { url "http://dl.bintray.com/fortify/maven-public" }
3434
// repository with fortify-ps releases
35+
mavenLocal()
3536
maven { url "https://dl.bintray.com/fortify-ps/maven" }
3637
// repository with fortify-ps snapshots
3738
maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" }
38-
mavenCentral()
3939
}
4040

4141
configurations {
@@ -111,11 +111,47 @@ bintray {
111111
}
112112

113113
task packageLicenseReport(type: Zip) {
114+
dependsOn generateLicenseReport
114115
archiveFileName = "${rootProject.name}-${project.version}-licenseReport.zip"
115116
destinationDirectory = file("$buildDir/dist")
116117

117118
from licenseReport.outputDir
118119
}
119-
generateLicenseReport.finalizedBy packageLicenseReport
120+
121+
task downloadDependencySources {
122+
inputs.files configurations.compileExport
123+
outputs.dir "${buildDir}/dependencySources"
124+
doLast {
125+
def componentIds = configurations.runtime.incoming.resolutionResult.allDependencies.collect { it.selected.id }
126+
ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery()
127+
.forComponents(componentIds)
128+
.withArtifacts(JvmLibrary, SourcesArtifact)
129+
.execute()
130+
def sourceArtifacts = []
131+
result.resolvedComponents.each { ComponentArtifactsResult component ->
132+
Set<ArtifactResult> sources = component.getArtifacts(SourcesArtifact)
133+
println "Found ${sources.size()} sources for ${component.id}"
134+
sources.each { ArtifactResult ar ->
135+
if (ar instanceof ResolvedArtifactResult) {
136+
sourceArtifacts << ar.file
137+
}
138+
}
139+
}
140+
141+
copy {
142+
from configurations.runtime
143+
from sourceArtifacts
144+
into "${buildDir}/dependencySources"
145+
}
146+
}
147+
}
148+
149+
task packageDependencySources(type: Zip) {
150+
dependsOn downloadDependencySources
151+
archiveFileName = "${rootProject.name}-${project.version}-dependencySources.zip"
152+
destinationDirectory = file("$buildDir/dist")
153+
154+
from "${buildDir}/dependencySources"
155+
}
120156

121157

0 commit comments

Comments
 (0)