Skip to content

Commit 08617b1

Browse files
committed
Don't include unused jars in the Shell CLI binary
Closes gh-1296
1 parent c714723 commit 08617b1

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

gradle/assemble.gradle

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
apply plugin: org.grails.gradle.GrailsBuildPlugin
1+
// Gradle assemble tasks
22

33
def libsConfigurations = []
44
subprojects { subproject ->
5-
if(subproject.name == 'grace-dependencies') return
6-
if(subproject.name == 'grace-bom') return
7-
if(subproject.name == 'grace-shell') {
8-
5+
if (subproject.name == 'grace-dependencies') return
6+
if (subproject.name == 'grace-bom') return
7+
if (subproject.name == 'grace-shell') {
98
configurations {
109
libsConfigurations << libs {
1110
extendsFrom runtimeClasspath
@@ -18,34 +17,30 @@ subprojects { subproject ->
1817
}
1918
}
2019

21-
task configurePopulateDependencies {
22-
ext {
23-
baseCachesDir = "$gradle.gradleUserHomeDir/caches"
24-
cacheDir = "$baseCachesDir/modules-2"
25-
metadata = "$cacheDir/metadata-2.1/descriptors"
26-
}
20+
task configurePopulateDependencies(dependsOn: 'publishToDist') {
2721
doLast {
2822
def projectNames = rootProject.subprojects*.name
2923

3024
def seen = []
3125
libsConfigurations.each { configuration ->
32-
def pomArtifacts = pomFor(configuration).resolvedConfiguration.lenientConfiguration.getArtifacts().groupBy {
33-
it.moduleVersion.id
34-
}
35-
3626
for (artifact in configuration.resolvedConfiguration.resolvedArtifacts) {
3727
if (artifact in seen) continue
3828
seen << artifact
3929
def dependency = artifact.moduleVersion.id
4030
if (!projectNames.contains(dependency.name)) {
41-
populateDependencies.into("$dependency.group/$dependency.name/jars") {
42-
from artifact.file // this will trigger the actual download if necessary
31+
if (dependency.group == 'org.graceframework') {
32+
populateDependencies.into('org.graceframework') {
33+
from artifact.file // this will trigger the actual download if necessary
34+
}
35+
} else {
36+
populateDependencies.into("$dependency.group/$dependency.name/jars") {
37+
from artifact.file // this will trigger the actual download if necessary
38+
}
4339
}
44-
45-
populateDependencies.into("$dependency.group/$dependency.name") {
46-
def pomFile = pomArtifacts[dependency]
47-
if (pomFile) {
48-
from pomFile.file
40+
} else {
41+
populateDependencies.into('org.graceframework') {
42+
from(homeDistDir) {
43+
include artifact.file.name
4944
}
5045
}
5146
}
@@ -93,7 +88,7 @@ class GrailsCreateStartScripts extends org.gradle.api.tasks.application.CreateSt
9388
generator.classpath = projectArtifacts + getClasspath().resolvedConfiguration.resolvedArtifacts.collect { artifact ->
9489
def dependency = artifact.moduleVersion.id
9590
String installedFile = "lib/$dependency.group/$dependency.name/jars/$artifact.file.name"
96-
if(dependency.group=='org.graceframework' && !project.file(installedFile).exists()) {
91+
if (dependency.group == 'org.graceframework') {
9792
installedFile = "dist/$artifact.file.name"
9893
}
9994
installedFile
@@ -123,24 +118,27 @@ task publishToDist { task ->
123118
}
124119
}
125120

126-
task binZip(type: Zip, dependsOn: [publishToDist, grailsCreateStartScripts]) {
121+
task binZip(type: Zip, dependsOn: [publishToDist, populateDependencies, grailsCreateStartScripts]) {
127122
destinationDirectory = "${buildDir}/distributions" as File
128123
archiveBaseName = 'grace'
129124
archiveAppendix = grailsVersion
130125
archiveClassifier = 'bin'
131126

132-
exclude "**/CVS/**"
133-
134127
into("grace-$grailsVersion") {
135128
from(projectDir) {
136-
include 'bin/grace', 'bin/grace.bat', 'lib/', 'samples/', 'scripts/', 'LICENSE.txt', 'INSTALL.txt'
137-
exclude 'ant/bin', 'src/grace', 'src/war'
129+
include 'bin/grace', 'bin/grace.bat', 'LICENSE.txt', 'INSTALL.txt'
138130
}
139-
from("conf") {
140-
into "conf"
131+
from("lib") {
132+
into "lib"
133+
exclude "org.graceframework/**"
134+
}
135+
from("lib/org.graceframework") {
136+
into "dist"
137+
include '**/*.jar'
141138
}
142139
from(homeDistDir) {
143140
into "dist"
141+
include "grace-shell-*.jar"
144142
exclude "*.zip*"
145143
exclude "*.tar*"
146144
exclude '*-javadoc.jar*', '*-sources.jar*', 'ivy-*', '*.jar.sha*'

0 commit comments

Comments
 (0)