Skip to content

Commit 9c1ce45

Browse files
committed
Added functionality to fix the static resources Zip version in the parent pom.xml.
1 parent a04ee8f commit 9c1ce45

File tree

2 files changed

+52
-9
lines changed

2 files changed

+52
-9
lines changed

src/main/java/org/springframework/data/release/maven/MavenOperations.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import lombok.RequiredArgsConstructor;
2525

2626
import org.springframework.beans.factory.annotation.Autowired;
27+
import org.springframework.core.GenericTypeResolver;
2728
import org.springframework.data.release.io.CommandResult;
2829
import org.springframework.data.release.io.OsCommandOperations;
2930
import org.springframework.data.release.io.Workspace;
@@ -84,7 +85,19 @@ public void updatePom(TrainIteration iteration, final Phase phase) throws Except
8485

8586
final Repository repository = new Repository(iteration.getIteration());
8687
final ArtifactVersion commonsVersion = iteration.getModuleVersion(COMMONS);
88+
final ArtifactVersion nextCommonsVersion = commonsVersion.getNextDevelopmentVersion();
8789
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+
});
88101

89102
for (ModuleIteration module : iteration.getModulesExcept(BUILD)) {
90103

@@ -95,21 +108,20 @@ public void updatePom(TrainIteration iteration, final Phase phase) throws Except
95108
continue;
96109
}
97110

98-
execute(workspace.getFile(POM_XML, project), new PomCallback() {
111+
execute(workspace.getFile(POM_XML, project), new PomCallback<Pom>() {
99112

100113
@Override
101114
public Pom doWith(Pom pom) {
102115

103116
if (project.dependsOn(Projects.COMMONS)) {
104117

105-
ArtifactVersion version = CLEANUP.equals(phase) ? commonsVersion.getNextDevelopmentVersion()
106-
: commonsVersion;
118+
ArtifactVersion version = CLEANUP.equals(phase) ? nextCommonsVersion : commonsVersion;
107119
logger.log(project, "Updating Spring Data Commons version dependecy to %s (setting property %s).", version,
108120
COMMONS_VERSION_PROPERTY);
109121
pom.setProperty(COMMONS_VERSION_PROPERTY, version);
110122
}
111123

112-
ArtifactVersion version = CLEANUP.equals(phase) ? buildVersion.getNextDevelopmentVersion() : buildVersion;
124+
ArtifactVersion version = CLEANUP.equals(phase) ? nextBuildVersion : buildVersion;
113125
logger.log(project, "Updating Spring Data Build Parent version to %s.", version);
114126
pom.setParentVersion(version);
115127

@@ -176,7 +188,7 @@ private void updateBomPom(final TrainIteration iteration, final Phase phase) thr
176188

177189
logger.log(BUILD, "Updating BOM pom.xml…");
178190

179-
execute(bomPomFile, new PomCallback() {
191+
execute(bomPomFile, new PomCallback<Pom>() {
180192

181193
@Override
182194
public Pom doWith(Pom pom) {
@@ -217,18 +229,20 @@ private void updateRepository(Project project, Pom pom, Repository repository, P
217229
}
218230
}
219231

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 {
221234

222235
XBFileIO io = projectionFactory.io().file(file);
223-
Pom pom = io.read(Pom.class);
236+
Class<?> typeArgument = GenericTypeResolver.resolveTypeArgument(callback.getClass(), PomCallback.class);
224237

238+
T pom = (T) io.read(typeArgument);
225239
pom = callback.doWith(pom);
226240

227241
io.write(pom);
228242
}
229243

230-
private interface PomCallback {
244+
private interface PomCallback<T extends Pom> {
231245

232-
public Pom doWith(Pom pom);
246+
public T doWith(T pom);
233247
}
234248
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.release.maven;
17+
18+
import org.springframework.data.release.model.ArtifactVersion;
19+
import org.xmlbeam.annotation.XBValue;
20+
import org.xmlbeam.annotation.XBWrite;
21+
22+
/**
23+
* @author Oliver Gierke
24+
*/
25+
public interface ParentPom extends Pom {
26+
27+
@XBWrite("/project/profiles/profile[id=''distribute'']/dependencies/dependency/version")
28+
void setSharedResourcesVersion(@XBValue ArtifactVersion value);
29+
}

0 commit comments

Comments
 (0)