Skip to content

Commit 0c5d561

Browse files
aludwikooctonato
andauthored
fix: java 17 for spring samples and maven archetypes (#1156)
* fix: testing java 17 for samples * fix: java 17 for maven archetypes * fix: java 17 for kalix action example * fix: java 17 for event sourced counter sample * fix: java 17 for views sample * Update samples/spring-eventsourced-customer-registry/pom.xml Co-authored-by: Renato Cavalcanti <[email protected]> * fixing maven poms * fixing maven poms * reverting changes * cleanups and renames * testing build with java 17 * reverting java 17 from grpc archetypes * missing jackson annotations Co-authored-by: Renato Cavalcanti <[email protected]>
1 parent 78fded9 commit 0c5d561

File tree

33 files changed

+129
-284
lines changed

33 files changed

+129
-284
lines changed

.circleci/config.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ commands:
1717
parent: main
1818

1919
install-java-11:
20-
description: install openjdk-11
20+
description: install openjdk-17
2121
steps:
2222
- run:
23-
name: Install java 11
23+
name: Install java 17
2424
command: |
25-
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz -O /tmp/openjdk-11.tar.gz
25+
wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.4.1%2B1/OpenJDK17U-jdk_x64_linux_hotspot_17.0.4.1_1.tar.gz -O /tmp/openjdk-17.tar.gz
2626
2727
sudo mkdir -p /usr/lib/jvm
28-
sudo tar xfvz /tmp/openjdk-11.tar.gz --directory /usr/lib/jvm
29-
rm -f /tmp/openjdk-11.tar.gz
28+
sudo tar xfvz /tmp/openjdk-17.tar.gz --directory /usr/lib/jvm
29+
rm -f /tmp/openjdk-17.tar.gz
3030
31-
sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.8+10/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done'
32-
sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.8+10/bin/*; do update-alternatives --set $(basename $bin) $bin; done'
31+
sudo sh -c 'for bin in /usr/lib/jvm/jdk-17.0.4.1+1/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done'
32+
sudo sh -c 'for bin in /usr/lib/jvm/jdk-17.0.4.1+1/bin/*; do update-alternatives --set $(basename $bin) $bin; done'
3333
3434
setup_sbt:
3535
description: "Set up sbt"

build.sbt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ lazy val sdkJava = project
6565
"-Xdoclint:none",
6666
"-overview",
6767
((Compile / javaSource).value / "overview.html").getAbsolutePath,
68-
"--no-module-directories",
6968
"-notimestamp",
7069
"-doctitle",
7170
"Kalix Java SDK",

maven-java/kalix-spring-boot-archetype/src/main/resources/archetype-resources/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
1717
<mainClass>${package}.Main</mainClass>
1818

19-
<jdk.target>11</jdk.target>
19+
<jdk.target>17</jdk.target>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2121

2222
<kalix-sdk.version>@project.version@</kalix-sdk.version>
@@ -91,7 +91,7 @@
9191
<name>${dockerImage}:%l</name>
9292
<build>
9393
<!-- Base Docker image which contains jre-->
94-
<from>docker.io/library/adoptopenjdk:${jdk.target}-jre-hotspot</from>
94+
<from>docker.io/library/eclipse-temurin:${D}{jdk.target}-alpine</from>
9595
<createImageOptions>
9696
<platform>linux/amd64</platform>
9797
</createImageOptions>

samples/spring-customer-registry-views-quickstart/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>com.example</groupId>
6-
<artifactId>spring-customer-registry</artifactId>
6+
<artifactId>spring-customer-registry-views</artifactId>
77
<version>1.0-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

@@ -16,7 +16,7 @@
1616
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
1717
<mainClass>customer.Main</mainClass>
1818

19-
<jdk.target>11</jdk.target>
19+
<jdk.target>17</jdk.target>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2121

2222
<kalix-sdk.version>1.0.8</kalix-sdk.version>
@@ -123,7 +123,7 @@
123123
<name>${dockerImage}:%l</name>
124124
<build>
125125
<!-- Base Docker image which contains jre-->
126-
<from>docker.io/library/adoptopenjdk:${jdk.target}-jre-hotspot</from>
126+
<from>docker.io/library/eclipse-temurin:${jdk.target}-alpine</from>
127127
<createImageOptions>
128128
<platform>linux/amd64</platform>
129129
</createImageOptions>

samples/spring-customer-registry-views-quickstart/src/it/java/customer/api/CustomerIntegrationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void create() throws InterruptedException {
4646
.block(timeout);
4747

4848
Assertions.assertEquals(HttpStatus.OK, response.getStatusCode());
49-
Assertions.assertEquals("Johanna", getCustomerById(id).name);
49+
Assertions.assertEquals("Johanna", getCustomerById(id).name());
5050
}
5151

5252
@Test
@@ -73,7 +73,7 @@ public void changeName() throws InterruptedException {
7373

7474

7575
Assertions.assertEquals(HttpStatus.OK, resUpdate.getStatusCode());
76-
Assertions.assertEquals("Katarina", getCustomerById(id).name);
76+
Assertions.assertEquals("Katarina", getCustomerById(id).name());
7777
}
7878

7979
@Test
@@ -102,7 +102,7 @@ public void changeAddress() throws InterruptedException {
102102

103103

104104
Assertions.assertEquals(HttpStatus.OK, resUpdate.getStatusCode());
105-
Assertions.assertEquals("Elm st. 5", getCustomerById(id).address.street);
105+
Assertions.assertEquals("Elm st. 5", getCustomerById(id).address().street());
106106
}
107107

108108

@@ -131,7 +131,7 @@ public void findByName() throws Exception {
131131
.retrieve()
132132
.bodyToMono(Customer.class)
133133
.block(timeout)
134-
.name,
134+
.name(),
135135
new IsEqual("Foo")
136136
);
137137
}
@@ -160,7 +160,7 @@ public void findByEmail() throws Exception {
160160
.retrieve()
161161
.bodyToMono(Customer.class)
162162
.block(timeout)
163-
.name,
163+
.name(),
164164
new IsEqual("Bar")
165165
);
166166
}

samples/spring-customer-registry-views-quickstart/src/main/java/customer/api/Address.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,5 @@
33
* Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
44
*/
55

6-
import com.fasterxml.jackson.annotation.JsonCreator;
7-
import com.fasterxml.jackson.annotation.JsonProperty;
8-
9-
public class Address {
10-
public String street;
11-
public String city;
12-
13-
@JsonCreator
14-
public Address(@JsonProperty("street") String street, @JsonProperty("city") String city) {
15-
this.street = street;
16-
this.city = city;
17-
}
6+
public record Address(String street, String city) {
187
}

samples/spring-customer-registry-views-quickstart/src/main/java/customer/api/Customer.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,13 @@
33
* Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
44
*/
55

6-
import com.fasterxml.jackson.annotation.JsonCreator;
7-
import com.fasterxml.jackson.annotation.JsonProperty;
6+
public record Customer(String customerId, String email, String name, Address address) {
87

9-
public class Customer {
10-
public String customerId;
11-
public String email;
12-
public String name;
13-
public Address address;
14-
15-
// TODO: remove JsonCreator and JsonProperty
16-
// this should not be needed and it's not when running the application
17-
// however, the integration tests seems to need it.
18-
// Probably related to how the compiler is configured for the tests?
19-
@JsonCreator
20-
public Customer(@JsonProperty("customerId") String customerId,
21-
@JsonProperty("email") String email,
22-
@JsonProperty("name") String name,
23-
@JsonProperty("address") Address address) {
24-
this.customerId = customerId;
25-
this.email = email;
26-
this.name = name;
27-
this.address = address;
8+
public Customer withName(String newName){
9+
return new Customer(customerId, email, newName, address);
2810
}
2911

30-
12+
public Customer withAddress(Address newAddress){
13+
return new Customer(customerId, email, name, newAddress);
14+
}
3115
}

samples/spring-customer-registry-views-quickstart/src/main/java/customer/api/CustomerEntity.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ public ValueEntity.Effect<Customer> getCustomer() {
3636

3737
@PostMapping("/changeName/{newName}")
3838
public Effect<String> changeName(@PathVariable String newName) {
39-
Customer customer = currentState();
40-
customer.name = newName;
41-
return effects().updateState(customer).thenReply("OK");
39+
Customer updatedCustomer = currentState().withName(newName);
40+
return effects().updateState(updatedCustomer).thenReply("OK");
4241
}
4342

4443
@PostMapping("/changeAddress")
4544
public Effect<String> changeAddress(@RequestBody Address newAddress) {
46-
Customer customer = currentState();
47-
customer.address = newAddress;
48-
return effects().updateState(customer).thenReply("OK");
45+
Customer updatedCustomer = currentState().withAddress(newAddress);
46+
return effects().updateState(updatedCustomer).thenReply("OK");
4947
}
5048

5149
}

samples/spring-customer-registry-views-quickstart/src/test/java/customer/api/CustomerEntityTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void testCustomerNameChange() {
2525
{
2626
ValueEntityResult<String> result = testKit.call(e -> e.changeName("FooBar"));
2727
assertEquals("OK", result.getReply());
28-
assertEquals("FooBar", testKit.getState().name);
28+
assertEquals("FooBar", testKit.getState().name());
2929
}
3030

3131
}
@@ -43,8 +43,8 @@ public void testCustomerAddressChange() {
4343
Address newAddress = new Address("Sesame Street", "Sesame City");
4444
ValueEntityResult<String> result = testKit.call(e -> e.changeAddress(newAddress));
4545
assertEquals("OK", result.getReply());
46-
assertEquals("Sesame Street", testKit.getState().address.street);
47-
assertEquals("Sesame City", testKit.getState().address.city);
46+
assertEquals("Sesame Street", testKit.getState().address().street());
47+
assertEquals("Sesame City", testKit.getState().address().city());
4848
}
4949

5050
}

samples/spring-eventsourced-counter/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ With both the proxy and your application running, once you have defined endpoint
3838

3939
- increase (or create) a counter named `hello` with value `10`
4040
```shell
41-
curl -i -XPOST localhost:9000/counter/hello/increase/10
41+
curl -XPOST localhost:9000/counter/hello/increase/10
4242
```
4343

4444
- retrieve the value of a counter named `hello`
4545
```shell
46-
curl -i -XGET localhost:9000/counter/hello
46+
curl -XGET localhost:9000/counter/hello
4747
```
4848

4949
- multiply existing counter named `hello` by value `5`
5050
```shell
51-
curl -i -XPOST localhost:9000/counter/hello/multiply/5
51+
curl -XPOST localhost:9000/counter/hello/multiply/5
5252
```
5353

5454
### Deploy

0 commit comments

Comments
 (0)