Commit 22c4139
Fix/uberjar shadow9 3.x (#473)
* Fix java-cfenv-all uber jar broken by Shadow 9 upgrade
Fixes #470.
The Shadow 8.3.9 -> 9.6.1 upgrade changed two behaviours that the build
was not updated for, producing broken `java-cfenv-all` artifacts in
3.5.2 and 4.0.1.
Shadow 9 defaults `duplicatesStrategy` to EXCLUDE, and duplicates are
dropped before transformers run. `java-cfenv-all` ships its own
`META-INF/spring.factories`, so it won that race and every dependency's
copy was discarded before `PropertiesFileTransformer` could merge them.
The published jar therefore only registered
`CloudProfileApplicationListener`, and both
`CfDataSourceEnvironmentPostProcessor` and `CfEnvironmentPostProcessor`
were missing, so `spring.datasource.url` was never derived from
`VCAP_SERVICES`. Setting `duplicatesStrategy` to INCLUDE lets the
transformer see and merge every copy.
Shadow 9 also no longer treats empty name/version segments in the
`dependency(String)` notation as wildcards, so
`dependency('org.springframework.boot::')` matched nothing and Spring
Boot and Spring Framework were bundled into the uber jar. On Spring
Boot 3+ that causes a classloader identity conflict. Using the explicit
`:.*:.*` form restores the intended exclusion.
The resulting jar drops from 7.9M to 1.7M, contains no
`org/springframework` classes, and its `spring.factories` matches the
last good release (4.0.0) exactly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Verify the uber jar contents as part of check
The Shadow 9 breakage in #470 shipped in two releases while every unit
test passed, because nothing inspected the packaged artifact. Add a
`verifyUberJar` task, wired into `check`, that opens the uber jar and
asserts what actually has to hold:
- no bundled `org/springframework` classes
- `com.cedarsoftware.io` relocated, with the shaded classes present
- `spring.factories` contains the entries contributed by each module,
including both EnvironmentPostProcessors
- `spring.factories` does not re-register Spring Boot's own
post-processors, which happens if the factories are merged while
Spring Boot is still bundled
Reverting either half of the fix fails the task, as does reverting both
(the state that shipped in 3.5.2 and 4.0.1).
Also pin `shadowJar` to run after `jar`. Both write the same archive name
because `archiveClassifier` is empty, so which one survives on disk was
left to task scheduling; Gradle flags this as an implicit dependency once
another task reads the artifact.
Note java-util (`com.cedarsoftware.util`) is deliberately not relocated,
matching the last good releases, so the check is scoped to
`com.cedarsoftware.io`.
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 6a51977 commit 22c4139
1 file changed
Lines changed: 111 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
83 | | - | |
| 83 | + | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
88 | 197 | | |
89 | 198 | | |
90 | 199 | | |
| |||
0 commit comments