Skip to content

Commit 08bd2c0

Browse files
committed
fix: #14930 - ensure both a shadowJar and regular jar can be published for grails-cli
1 parent 4b95ad4 commit 08bd2c0

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

grails-forge/grails-cli/build.gradle

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,38 @@ ext {
3838
version = projectVersion
3939
group = 'org.apache.grails'
4040

41+
configurations {
42+
shadowCombined
43+
}
44+
4145
evaluationDependsOn(':grails-cli-shadow')
4246
dependencies {
4347
implementation platform("org.apache.grails:grails-bom:$projectVersion")
4448
implementation 'org.apache.groovy:groovy'
4549

46-
// forge & shell-cli dependencies have to be pulled via a file to ensure the transforms are applied to both dependencies and our own projects
47-
runtimeOnly files(project(':grails-cli-shadow').tasks.named('shadowJar'))
50+
// shell-cli dependencies
51+
implementation 'org.apache.grails:grails-shell-cli'
52+
implementation 'org.springframework.boot:spring-boot-cli'
53+
implementation 'org.apache.groovy:groovy'
54+
implementation 'org.apache.groovy:groovy-ant'
55+
implementation 'org.apache.groovy:groovy-templates'
56+
57+
// The commands are pulled from the shellCliDependencies in the shell project, but they are not in the shell jar file,
58+
// so they must be added here. To keep the jar file smaller, only a subset is included here
59+
implementation 'org.apache.grails:grails-core' // for ApplicationContextCommandFactory to lookup commands
60+
implementation 'org.apache.grails:grails-url-mappings' // for UrlMappingsReportCommand
61+
// profiles will add additional libraries as needed to surface commands
62+
63+
// forge dependencies
64+
implementation project(':grails-forge-cli'), {
65+
exclude group: 'org.slf4j', module: 'slf4j-nop'
66+
}
67+
68+
// for the shadow jar, configure forge & shell-cli dependencies to be pulled from a file to ensure the shadow
69+
// transforms are applied to both dependencies and our own projects
70+
shadowCombined platform("org.apache.grails:grails-bom:$projectVersion")
71+
shadowCombined 'org.apache.groovy:groovy'
72+
shadowCombined files(project(':grails-cli-shadow').tasks.named('shadowJar'))
4873
}
4974

5075
apply {
@@ -66,6 +91,9 @@ TaskProvider<Jar> shadowJarTask = tasks.named('shadowJar', ShadowJar)
6691
shadowJarTask.configure { ShadowJar it ->
6792
it.archiveClassifier.set('all')
6893

94+
// use a separate configuration path so we can still publish the cli project with a non-shadow jar
95+
it.configurations = [project.configurations.shadowCombined]
96+
6997
// services & custom grails.factories have to be merged since commands can be created from both sources
7098
it.mergeServiceFiles()
7199
it.mergeServiceFiles('META-INF/grails.factories')

0 commit comments

Comments
 (0)