24
24
import lombok .RequiredArgsConstructor ;
25
25
26
26
import org .springframework .beans .factory .annotation .Autowired ;
27
+ import org .springframework .core .GenericTypeResolver ;
27
28
import org .springframework .data .release .io .CommandResult ;
28
29
import org .springframework .data .release .io .OsCommandOperations ;
29
30
import org .springframework .data .release .io .Workspace ;
@@ -84,7 +85,19 @@ public void updatePom(TrainIteration iteration, final Phase phase) throws Except
84
85
85
86
final Repository repository = new Repository (iteration .getIteration ());
86
87
final ArtifactVersion commonsVersion = iteration .getModuleVersion (COMMONS );
88
+ final ArtifactVersion nextCommonsVersion = commonsVersion .getNextDevelopmentVersion ();
87
89
final ArtifactVersion buildVersion = iteration .getModuleVersion (BUILD );
90
+ final ArtifactVersion nextBuildVersion = buildVersion .getNextDevelopmentVersion ();
91
+
92
+ // Fix version of shared resources to to-be-released version.
93
+ execute (workspace .getFile ("parent/pom.xml" , BUILD ), new PomCallback <ParentPom >() {
94
+
95
+ @ Override
96
+ public ParentPom doWith (ParentPom pom ) {
97
+ pom .setSharedResourcesVersion (phase .equals (PREPARE ) ? buildVersion : nextBuildVersion );
98
+ return pom ;
99
+ }
100
+ });
88
101
89
102
for (ModuleIteration module : iteration .getModulesExcept (BUILD )) {
90
103
@@ -95,21 +108,20 @@ public void updatePom(TrainIteration iteration, final Phase phase) throws Except
95
108
continue ;
96
109
}
97
110
98
- execute (workspace .getFile (POM_XML , project ), new PomCallback () {
111
+ execute (workspace .getFile (POM_XML , project ), new PomCallback < Pom > () {
99
112
100
113
@ Override
101
114
public Pom doWith (Pom pom ) {
102
115
103
116
if (project .dependsOn (Projects .COMMONS )) {
104
117
105
- ArtifactVersion version = CLEANUP .equals (phase ) ? commonsVersion .getNextDevelopmentVersion ()
106
- : commonsVersion ;
118
+ ArtifactVersion version = CLEANUP .equals (phase ) ? nextCommonsVersion : commonsVersion ;
107
119
logger .log (project , "Updating Spring Data Commons version dependecy to %s (setting property %s)." , version ,
108
120
COMMONS_VERSION_PROPERTY );
109
121
pom .setProperty (COMMONS_VERSION_PROPERTY , version );
110
122
}
111
123
112
- ArtifactVersion version = CLEANUP .equals (phase ) ? buildVersion . getNextDevelopmentVersion () : buildVersion ;
124
+ ArtifactVersion version = CLEANUP .equals (phase ) ? nextBuildVersion : buildVersion ;
113
125
logger .log (project , "Updating Spring Data Build Parent version to %s." , version );
114
126
pom .setParentVersion (version );
115
127
@@ -176,7 +188,7 @@ private void updateBomPom(final TrainIteration iteration, final Phase phase) thr
176
188
177
189
logger .log (BUILD , "Updating BOM pom.xml…" );
178
190
179
- execute (bomPomFile , new PomCallback () {
191
+ execute (bomPomFile , new PomCallback < Pom > () {
180
192
181
193
@ Override
182
194
public Pom doWith (Pom pom ) {
@@ -217,18 +229,20 @@ private void updateRepository(Project project, Pom pom, Repository repository, P
217
229
}
218
230
}
219
231
220
- private void execute (File file , PomCallback callback ) throws Exception {
232
+ @ SuppressWarnings ("unchecked" )
233
+ private <T extends Pom > void execute (File file , PomCallback <T > callback ) throws Exception {
221
234
222
235
XBFileIO io = projectionFactory .io ().file (file );
223
- Pom pom = io . read ( Pom .class );
236
+ Class <?> typeArgument = GenericTypeResolver . resolveTypeArgument ( callback . getClass (), PomCallback .class );
224
237
238
+ T pom = (T ) io .read (typeArgument );
225
239
pom = callback .doWith (pom );
226
240
227
241
io .write (pom );
228
242
}
229
243
230
- private interface PomCallback {
244
+ private interface PomCallback < T extends Pom > {
231
245
232
- public Pom doWith (Pom pom );
246
+ public T doWith (T pom );
233
247
}
234
248
}
0 commit comments