Skip to content

Commit 499dc6c

Browse files
committed
Merge branch 'main' into tm-transformation
2 parents bb0af68 + 6628731 commit 499dc6c

File tree

76 files changed

+3545
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3545
-451
lines changed

README.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ Please refer to the link:CONTRIBUTING.adoc[] for more details.
7171
== License
7272

7373
https://www.apache.org/licenses/LICENSE-2.0[Apache License v2.0]
74+

applications/spring-shell/src/main/java/org/springframework/sbm/shell/ApplyCommandRenderer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ public class ApplyCommandRenderer {
6565
@Setter
6666
private int delay = 250;
6767

68-
public AttributedString render(Recipe recipe) {
68+
public AttributedString render(String recipeName, List<Action> actions) {
6969
AttributedStringBuilder builder = new AttributedStringBuilder();
7070
builder.append("\n");
7171
builder.style(AttributedStyle.DEFAULT.italicDefault());
72-
builder.append(recipe.getName());
72+
builder.append(recipeName);
7373
builder.append(" successfully applied the following actions:\n")
74-
.append(recipe.getActions().stream()
74+
.append(actions.stream()
7575
.map(a -> " (x) " + getDescriptionWithIndent(a))
7676
.collect(Collectors.joining("\n")))
7777
.append("\n");

applications/spring-shell/src/main/java/org/springframework/sbm/shell/ApplyShellCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.springframework.sbm.engine.commands.ApplyCommand;
2121
import org.springframework.sbm.engine.context.ProjectContext;
2222
import org.springframework.sbm.engine.context.ProjectContextHolder;
23+
import org.springframework.sbm.engine.recipe.Action;
2324
import org.springframework.sbm.engine.recipe.Recipe;
2425
import lombok.RequiredArgsConstructor;
2526
import org.jetbrains.annotations.NotNull;
@@ -57,8 +58,8 @@ public AttributedString apply(@ShellOption(arity = 1, valueProvider = ApplyRecip
5758
System.out.println(header.toAnsi());
5859

5960
ProjectContext projectContext = projectContextHolder.getProjectContext();
60-
Recipe recipe = applyCommand.execute(projectContext, recipeName);
61-
AttributedString applyCommandOutput = applyCommandRenderer.render(recipe);
61+
List<Action> appliedActions = applyCommand.execute(projectContext, recipeName);
62+
AttributedString applyCommandOutput = applyCommandRenderer.render(recipeName, appliedActions);
6263

6364
List<Recipe> applicableRecipes = applicableRecipeListCommand.execute(projectContext);
6465
AttributedString applicableRecipesOutput = applicableRecipeListRenderer.render(applicableRecipes);

applications/spring-shell/src/test/java/org/springframework/sbm/BootUpgrade_27_30_IntegrationTest.java

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,44 @@ void migrateSimpleApplication() {
4545

4646
applyRecipe("boot-2.7-3.0-dependency-version-update");
4747

48+
buildProject();
4849
verifyParentPomVersion();
49-
verifyMicrometerPackageUpdate();
5050
verifyYamlConfigurationUpdate();
5151
verifyPropertyConfigurationUpdate();
5252
verifyConstructorBindingRemoval();
5353
verifyCrudRepoAddition();
5454
verifyAutoConfigurationIsRefactored();
5555
verifyEhCacheVersionIsUpgraded();
56+
verifyJohnzonCoreDependencyIsUpgraded();
57+
}
58+
private void buildProject() {
59+
executeMavenGoals(getTestDir(), "clean", "verify");
5660
}
5761

58-
private void verifyEhCacheVersionIsUpgraded() {
59-
String pomContent = loadFile(Path.of("pom.xml"));
62+
private void verifyJohnzonCoreDependencyIsUpgraded() {
63+
Optional<Dependency> johnzonResult = getDependencyByArtifactId("johnzon-core");
6064

61-
Xml.Document mavenAsXMLDocument = parsePom(pomContent);
65+
assertThat(johnzonResult.isPresent()).isTrue();
6266

63-
List<Dependency> dependencies = mavenAsXMLDocument
64-
.getMarkers()
65-
.findFirst(MavenResolutionResult.class)
66-
.get()
67-
.getPom()
68-
.getRequestedDependencies();
67+
Dependency johnzonDependency = johnzonResult.get();
68+
69+
assertThat(johnzonDependency.getClassifier()).isEqualTo("jakarta");
70+
assertThat(johnzonDependency.getArtifactId()).isEqualTo("johnzon-core");
71+
assertThat(johnzonDependency.getVersion()).isEqualTo("1.2.18");
72+
}
6973

70-
Optional<Dependency> ehcacheResult = dependencies
74+
@NotNull
75+
private Optional<Dependency> getDependencyByArtifactId(String artifactId) {
76+
Xml.Document mavenAsXMLDocument = getRootBuildFile();
77+
List<Dependency> dependencies = getDependencies(mavenAsXMLDocument);
78+
return dependencies
7179
.stream()
72-
.filter(dependency -> dependency.getArtifactId().equals("ehcache"))
80+
.filter(dependency -> dependency.getArtifactId().equals(artifactId))
7381
.findFirst();
82+
}
83+
84+
private void verifyEhCacheVersionIsUpgraded() {
85+
Optional<Dependency> ehcacheResult = getDependencyByArtifactId("ehcache");
7486

7587
assertThat(ehcacheResult).isPresent();
7688

@@ -82,6 +94,22 @@ private void verifyEhCacheVersionIsUpgraded() {
8294
assertThat(ehcacheDependency.getClassifier()).isEqualTo("jakarta");
8395
}
8496

97+
@NotNull
98+
private List<Dependency> getDependencies(Xml.Document mavenAsXMLDocument) {
99+
return mavenAsXMLDocument
100+
.getMarkers()
101+
.findFirst(MavenResolutionResult.class)
102+
.get()
103+
.getPom()
104+
.getRequestedDependencies();
105+
}
106+
107+
@NotNull
108+
private Xml.Document getRootBuildFile() {
109+
110+
return parsePom(loadFile(Path.of("pom.xml")));
111+
}
112+
85113
private void verifyAutoConfigurationIsRefactored() {
86114
String autoConfig = loadFile(Path.of("src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports"));
87115
assertThat(autoConfig).isEqualTo("com.hello.GreetingConfig");
@@ -143,19 +171,6 @@ private void verifyConstructorBindingRemoval() {
143171
"\n");
144172
}
145173

146-
private void verifyMicrometerPackageUpdate() {
147-
String micrometerClass = loadFile(Path.of("src/main/java/org/springboot/example/upgrade/MicrometerConfig.java"));
148-
assertThat(micrometerClass).isEqualTo(
149-
"package org.springboot.example.upgrade;\n" +
150-
"\n" +
151-
"import io.micrometer.binder.MeterBinder;\n" +
152-
"\n" +
153-
"public class MicroMeterConfig {\n" +
154-
"\n" +
155-
" private MeterBinder k;\n" +
156-
"}\n");
157-
}
158-
159174
private void verifyYamlConfigurationUpdate() {
160175
String micrometerClass = loadFile(Path.of("src/main/resources/application.yaml"));
161176
assertThat(micrometerClass).isEqualTo(
@@ -244,9 +259,7 @@ private void verifyPropertyConfigurationUpdate() {
244259
}
245260

246261
private void verifyParentPomVersion() {
247-
String pomContent = loadFile(Path.of("pom.xml"));
248-
249-
Xml.Document mavenAsXMLDocument = parsePom(pomContent);
262+
Xml.Document mavenAsXMLDocument = getRootBuildFile();
250263

251264
Xml.Tag parentTag =mavenAsXMLDocument
252265
.getRoot()

applications/spring-shell/src/test/java/org/springframework/sbm/shell/ApplyShellCommandTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class ApplyShellCommandTest {
5858
@Test
5959
void testApply() {
6060
String recipeName = "recipe-1";
61-
Recipe recipe = new Recipe();
6261
AttributedString applyOutput = new AttributedString("applyOutput");
6362
List<Recipe> applicableRecipes = List.of();
6463
AttributedString applicableRecipesOutput = new AttributedString("applicableRecipesOutput");
@@ -67,8 +66,8 @@ void testApply() {
6766

6867
ProjectContext projectContext = mock(ProjectContext.class);
6968
when(projectContextHolder.getProjectContext()).thenReturn(projectContext);
70-
when(applyCommand.execute(projectContext, recipeName)).thenReturn(recipe);
71-
when(applyCommandRenderer.render(recipe)).thenReturn(applyOutput);
69+
when(applyCommand.execute(projectContext, recipeName)).thenReturn(List.of());
70+
when(applyCommandRenderer.render(recipeName, List.of())).thenReturn(applyOutput);
7271
when(applicableRecipeListCommand.execute(projectContext)).thenReturn(applicableRecipes);
7372
when(applicableRecipeListRenderer.render(applicableRecipes)).thenReturn(applicableRecipesOutput);
7473

applications/spring-shell/src/test/resources/testcode/boot-migration-27-30/pom.xml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
<groupId>org.springframework.boot</groupId>
2323
<artifactId>spring-boot-starter-web</artifactId>
2424
</dependency>
25-
<dependency>
26-
<groupId>io.micrometer</groupId>
27-
<artifactId>micrometer-registry-prometheus</artifactId>
28-
</dependency>
2925
<dependency>
3026
<groupId>org.ehcache</groupId>
3127
<artifactId>ehcache</artifactId>
@@ -48,6 +44,10 @@
4844
<artifactId>rxjava</artifactId>
4945
<version>3.1.5</version>
5046
</dependency>
47+
<dependency>
48+
<groupId>org.apache.johnzon</groupId>
49+
<artifactId>johnzon-core</artifactId>
50+
</dependency>
5151
<dependency>
5252
<groupId>org.springframework.boot</groupId>
5353
<artifactId>spring-boot-starter-test</artifactId>
@@ -70,13 +70,6 @@
7070
<enabled>false</enabled>
7171
</snapshots>
7272
</repository>
73-
<!-- <repository>-->
74-
<!-- <id>spring-milestone</id>-->
75-
<!-- <url>https://repo.spring.io/milestone</url>-->
76-
<!-- <snapshots>-->
77-
<!-- <enabled>false</enabled>-->
78-
<!-- </snapshots>-->
79-
<!-- </repository>-->
8073
<repository>
8174
<id>spring-release</id>
8275
<url>https://repo.spring.io/release</url>

applications/spring-shell/src/test/resources/testcode/boot-migration-27-30/src/main/java/org/springboot/example/upgrade/MicroMeterConfig.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

ci/images/ci-image/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ubuntu:focal-20220801
2+
#
3+
#VOLUME /var/run/docker.sock
4+
#
5+
###########################################################
6+
# JAVA
7+
###########################################################
8+
9+
ADD ./setup.sh /setup.sh
10+
ADD ./get-jdk-url.sh /get-jdk-url.sh
11+
ADD ./get-docker-url.sh /get-docker-url.sh
12+
RUN ./setup.sh java17
13+
14+
ENV JAVA_HOME /opt/openjdk
15+
ENV PATH $PATH:$JAVA_HOME/bin
16+
ENV MAVEN_HOME /usr/share/maven
17+
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
18+
19+
#
20+
21+
22+
23+
#ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"]
24+
#ENTRYPOINT ["sh"]
25+
ENTRYPOINT [ "switch", "shell=/bin/bash", "--", "codep", "/bin/docker daemon" ]

ci/images/ci-image/entrypoint.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2021 - 2022 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -e
19+
20+
mvn --version
21+
22+
exec "$@"

ci/images/ci-image/get-docker-url.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2021 - 2022 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
set -e
18+
19+
version="20.10.17"
20+
echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz";

ci/images/ci-image/get-jdk-url.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
case "$1" in
5+
java17)
6+
echo "https://github.com/bell-sw/Liberica/releases/download/17.0.4+8/bellsoft-jdk17.0.4+8-linux-amd64.tar.gz"
7+
# echo "https://github.com/bell-sw/Liberica/releases/download/17.0.4+8/bellsoft-jdk17.0.4+8-linux-aarch64.tar.gz"
8+
9+
;;
10+
java18)
11+
echo "https://github.com/bell-sw/Liberica/releases/download/18.0.2+10/bellsoft-jdk18.0.2+10-linux-amd64.tar.gz"
12+
;;
13+
*)
14+
echo $"Unknown java version"
15+
exit 1
16+
esac

0 commit comments

Comments
 (0)