Skip to content

Commit e5bbec7

Browse files
committed
Add Gradle task for building zip with dependencies
Some Spring Framework users and teams cannot use transitive dependency management tools like Maven, Gradle and Ivy. For them, a `distZip` task has been added to allow for creating a Spring Framework distribution from source that includes all optional and required runtime dependencies for all modules of the framework. This 'dist-with-deps' zip is not published to the SpringSource repository nor to the SpringSource community download page. It is strictly an optional task introduced as a convenience to the users mentioned above. Detailed instructions for building this zip locally have been added to the wiki and the README has been updated with a link to that new doc. Issue: SPR-6575
1 parent 726655a commit e5bbec7

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ The framework also serves as the foundation for
1515
[Python](https://github.com/SpringSource/spring-python) variants are available as well.
1616

1717
## Downloading artifacts
18-
Instructions on
19-
[downloading Spring artifacts](https://github.com/SpringSource/spring-framework/wiki/Downloading-Spring-artifacts)
20-
via Maven and other build systems are available via the project wiki.
18+
See [downloading Spring artifacts](https://github.com/SpringSource/spring-framework/wiki/Downloading-Spring-artifacts)
19+
for Maven repository information. Unable to use Maven or other transitive dependency management tools?
20+
See [building a distribution with dependencies](https://github.com/SpringSource/spring-framework/wiki/Building-a-distribution-with-dependencies).
2121

2222
## Documentation
2323
See the current [Javadoc](http://static.springsource.org/spring-framework/docs/current/api)

build.gradle

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ configure(rootProject) {
640640
description = "Builds -${classifier} archive, containing all jars and docs, " +
641641
"suitable for community download page."
642642

643-
def baseDir = "${project.name}-${project.version}";
643+
ext.baseDir = "${project.name}-${project.version}";
644644

645645
from('src/dist') {
646646
include 'readme.txt'
@@ -671,6 +671,36 @@ configure(rootProject) {
671671
}
672672
}
673673

674+
// Create an distribution that contains all dependencies (required and optional).
675+
// Not published by default; only for use when building from source.
676+
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
677+
group = 'Distribution'
678+
classifier = 'dist-with-deps'
679+
description = "Builds -${classifier} archive, containing everything " +
680+
"in the -${distZip.classifier} archive plus all runtime dependencies."
681+
682+
from zipTree(distZip.archivePath)
683+
684+
gradle.taskGraph.whenReady { taskGraph ->
685+
if (taskGraph.hasTask(":${zipTask.name}")) {
686+
def projectNames = rootProject.subprojects*.name
687+
def artifacts = new HashSet()
688+
subprojects.each { subproject ->
689+
subproject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
690+
def dependency = artifact.moduleVersion.id
691+
if (!projectNames.contains(dependency.name)) {
692+
artifacts << artifact.file
693+
}
694+
}
695+
}
696+
697+
zipTask.from(artifacts) {
698+
into "${distZip.baseDir}/deps"
699+
}
700+
}
701+
}
702+
}
703+
674704
artifacts {
675705
archives docsZip
676706
archives schemaZip

0 commit comments

Comments
 (0)