Skip to content

Commit 440ce51

Browse files
committed
feat: backported to jdk-11
1 parent 2dde2ef commit 440ce51

File tree

8 files changed

+55
-88
lines changed

8 files changed

+55
-88
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
java: [ '17', '19', '21' ]
8+
java: [ '11', '17', '19', '21' ]
99
name: Temurin ${{ matrix.java }}
1010
steps:
1111
- uses: actions/checkout@v3

.github/workflows/release-to-maven-central.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Maven Central Repository
2020
uses: actions/setup-java@v4
2121
with:
22-
java-version: 17
22+
java-version: 11
2323
distribution: 'temurin'
2424
server-id: central
2525
server-username: MAVEN_USERNAME

email-template-builder-markdown/src/main/java/io/rocketbase/mail/markdown/CssInlinerAttributeProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public AttributeProvider create(AttributeProviderContext attributeProviderContex
3030
"; font-size: " + configuration.getText().getSize() +
3131
"; line-height: " + configuration.getText().getLineHeight() +
3232
"; color: " + configuration.getText().getColor());
33-
} else if (node instanceof Heading heading) {
33+
} else if (node instanceof Heading) {
34+
Heading heading = (Heading) node;
3435
TbFont font = null;
3536
switch (heading.getLevel()) {
3637
case 1:

email-template-builder-markdown/src/test/java/io/rocketbase/mail/MarkdownTest.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,22 @@ public class MarkdownTest {
1212
@Test
1313
public void testSome() {
1414
// given
15-
String input = """
16-
This is *Sparta*
17-
# Heading 1
18-
## Heading 2
19-
### Heading 3
20-
#### Heading 4
21-
""";
15+
String input = "This is *Sparta*\n" +
16+
"# Heading 1\n" +
17+
"## Heading 2\n" +
18+
"### Heading 3\n" +
19+
"#### Heading 4\n";
2220
// when
2321
MarkdownLine markdownLine = new MarkdownLine(input);
2422

2523
// then
2624
assertThat(markdownLine.getMarkdown(), notNullValue());
2725
assertThat(markdownLine.getHtml(), notNullValue());
2826
assertThat(markdownLine.getMarkdown(), equalTo(input));
29-
assertThat(markdownLine.getHtml(), equalTo("""
30-
<p style="font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; margin: .4em 0 1.1875em; font-size: 16px; line-height: 1.625; color: #51545E">This is <em>Sparta</em></p>
31-
<h1 style="font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 22px; color: #333333">Heading 1</h1>
32-
<h2 style="font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 16px; color: #333333">Heading 2</h2>
33-
<h3 style="font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 14px; color: #333333">Heading 3</h3>
34-
<h4 style="font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 14px; color: #333333">Heading 4</h4>
35-
"""));
27+
assertThat(markdownLine.getHtml(), equalTo("<p style=\"font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; margin: .4em 0 1.1875em; font-size: 16px; line-height: 1.625; color: #51545E\">This is <em>Sparta</em></p>\n" +
28+
"<h1 style=\"font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 22px; color: #333333\">Heading 1</h1>\n" +
29+
"<h2 style=\"font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 16px; color: #333333\">Heading 2</h2>\n" +
30+
"<h3 style=\"font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 14px; color: #333333\">Heading 3</h3>\n" +
31+
"<h4 style=\"font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 14px; color: #333333\">Heading 4</h4>\n"));
3632
}
3733
}

email-template-builder/src/main/java/io/rocketbase/mail/line/AbstractHtmlLine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected String embedLinks(String html) {
4343
Matcher matcherHref = PATTERN_A_HREF.matcher(href);
4444
while (matcherHref.find()) {
4545
String link = matcherHref.group(1).replaceAll("('|\")", "");
46-
result = result.replace(matcherATag.group(), "%s -> %s".formatted(linkText, link));
46+
result = result.replace(matcherATag.group(), String.format("%s -> %s", linkText, link));
4747
}
4848

4949
}

email-template-builder/src/test/java/io/rocketbase/mail/EmailTemplateBuilderTest.java

Lines changed: 34 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,14 @@ public void standardTestHtml() {
7373
.keyValue("Username", "{{username}}")
7474
.and()
7575
.html("If you have any questions, feel free to <a href=\"mailto:{{support_email}}\">email our customer success team</a>. (We're lightning quick at replying.) We also offer <a href=\"{{live_chat_url}}\">live chat</a> during business hours.",
76-
"""
77-
If you have any questions, feel free to email our customer success team
78-
(We're lightning quick at replying.) We also offer live chat during business hours.\
79-
""").and()
80-
.text("""
81-
Cheers,
82-
The [Product Name] Team\
83-
""").and()
76+
"If you have any questions, feel free to email our customer success team\n" +
77+
"(We're lightning quick at replying.) We also offer live chat during business hours.").and()
78+
.text("Cheers,\n" +
79+
"The [Product Name] Team").and()
8480
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
85-
.footerText("""
86-
[Company Name, LLC]
87-
1234 Street Rd.
88-
Suite 1234\
89-
""").and()
81+
.footerText("[Company Name, LLC]\n" +
82+
"1234 Street Rd.\n" +
83+
"Suite 1234").and()
9084
.footerImage("https://cdn.rocketbase.io/assets/loading/no-image.jpg").width(100).linkUrl("https://www.rocketbase.io").and()
9185
.build();
9286
// then
@@ -127,16 +121,12 @@ public void sideImage() {
127121
.button("Button", "http://localhost").red().center().and()
128122
.and()
129123

130-
.text("""
131-
Cheers,
132-
The [Product Name] Team\
133-
""").and()
124+
.text("Cheers,\n" +
125+
"The [Product Name] Team").and()
134126
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
135-
.footerText("""
136-
[Company Name, LLC]
137-
1234 Street Rd.
138-
Suite 1234\
139-
""").and()
127+
.footerText("[Company Name, LLC]\n" +
128+
"1234 Street Rd.\n" +
129+
"Suite 1234").and()
140130
.footerImage("https://cdn.rocketbase.io/assets/loading/no-image.jpg").width(100).linkUrl("https://www.rocketbase.io").and()
141131
.build();
142132
// then
@@ -201,16 +191,12 @@ public void gallery() {
201191
.button("action", "http://localhost").red().right().and()
202192
.and()
203193

204-
.text("""
205-
Cheers,
206-
The [Product Name] Team\
207-
""").and()
194+
.text("Cheers,\n" +
195+
"The [Product Name] Team").and()
208196
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
209-
.footerText("""
210-
[Company Name, LLC]
211-
1234 Street Rd.
212-
Suite 1234\
213-
""").and()
197+
.footerText("[Company Name, LLC]\n" +
198+
"1234 Street Rd.\n" +
199+
"Suite 1234").and()
214200
.footerImage("https://cdn.rocketbase.io/assets/loading/no-image.jpg").width(100).linkUrl("https://www.rocketbase.io").and()
215201
.build();
216202
// then
@@ -235,21 +221,17 @@ public void standardTableTestHtml() {
235221
.text("Thanks for using [Product Name]. This is an invoice for your recent purchase").and()
236222
.tableSimple("#.## '€'")
237223
.headerRow("Description", "Amount")
238-
.itemRow("""
239-
Special Product
240-
Some extra explanations in separate line\
241-
""", BigDecimal.valueOf(1333, 2))
224+
.itemRow("Special Product\n" +
225+
"Some extra explanations in separate line", BigDecimal.valueOf(1333, 2))
242226
.itemRow("Short service", BigDecimal.valueOf(103, 1))
243227
.footerRow("Total", BigDecimal.valueOf(2363, 2))
244228
.and()
245229
.button("Download PDF", "http://localhost").gray().right().and()
246230
.text("If you have any questions about this receipt, simply reply to this email or reach out to our support team for help.").and()
247231
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
248-
.footerText("""
249-
[Company Name, LLC]
250-
1234 Street Rd.
251-
Suite 1234\
252-
""").and()
232+
.footerText("[Company Name, LLC]\n" +
233+
"1234 Street Rd.\n" +
234+
"Suite 1234").and()
253235
.build();
254236
// then
255237
assertThat(htmlTextEmail, notNullValue());
@@ -273,30 +255,22 @@ public void standardTableExtendedTestHtml() {
273255
.text("Thanks for using [Product Name]. This is an invoice for your recent purchase").and()
274256
.tableSimpleWithImage("#.## '€'")
275257
.headerRow("Preview", "Description", "Amount")
276-
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCW1142-07052_small.jpg?v=1589200198", """
277-
Damen Harbour Tanktop × 1
278-
QUARTZ PINK / S\
279-
""", BigDecimal.valueOf(4995, 2))
280-
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCM1886-0718_201_fdf0be52-639f-4ea8-9143-6bd75e0821b1_small.jpg?v=1583509609", """
281-
Herren ten Classic T-Shirt
282-
FOREST GREEN HEATHER / XL\
283-
""", BigDecimal.valueOf(3995, 2))
284-
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCM1939-0439_1332_da6f3e7c-e18d-4778-be97-c6c0b482b643_small.jpg?v=1583509671", """
285-
Herren Joshua Hanfshorts
286-
DARK OCEAN BLUE / XL\
287-
""", BigDecimal.valueOf(6995, 2))
258+
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCW1142-07052_small.jpg?v=1589200198", "Damen Harbour Tanktop × 1\n" +
259+
"QUARTZ PINK / S", BigDecimal.valueOf(4995, 2))
260+
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCM1886-0718_201_fdf0be52-639f-4ea8-9143-6bd75e0821b1_small.jpg?v=1583509609", "Herren ten Classic T-Shirt\n" +
261+
"FOREST GREEN HEATHER / XL", BigDecimal.valueOf(3995, 2))
262+
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCM1939-0439_1332_da6f3e7c-e18d-4778-be97-c6c0b482b643_small.jpg?v=1583509671", "Herren Joshua Hanfshorts\n" +
263+
"DARK OCEAN BLUE / XL", BigDecimal.valueOf(6995, 2))
288264
.footerRow("Sum", BigDecimal.valueOf(15985, 2))
289265
.footerRow("Code - PLANT5", BigDecimal.valueOf(-799, 2))
290266
.footerRow("Total incl. Tax\n", BigDecimal.valueOf(15186, 2))
291267
.and()
292268
.button("Download PDF", "http://localhost").gray().right().and()
293269
.text("If you have any questions about this receipt, simply reply to this email or reach out to our support team for help.").and()
294270
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
295-
.footerText("""
296-
[Company Name, LLC]
297-
1234 Street Rd.
298-
Suite 1234\
299-
""").and()
271+
.footerText("[Company Name, LLC]\n" +
272+
"1234 Street Rd.\n" +
273+
"Suite 1234").and()
300274
.build();
301275
// then
302276
assertThat(htmlTextEmail, notNullValue());
@@ -340,11 +314,9 @@ public void customTableTest() {
340314
.button("Download PDF", "http://localhost").gray().right().and()
341315
.text("If you have any questions about this receipt, simply reply to this email or reach out to our support team for help.").and()
342316
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
343-
.footerText("""
344-
[Company Name, LLC]
345-
1234 Street Rd.
346-
Suite 1234\
347-
""");
317+
.footerText("[Company Name, LLC]\n" +
318+
"1234 Street Rd.\n" +
319+
"Suite 1234");
348320

349321
HtmlTextEmail htmlTextEmail = builder.build();
350322
// then

email-template-builder/src/test/java/io/rocketbase/mail/HtmlLineTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ class HtmlLineTest {
1010
@Test
1111
void testHtmlExtraction() {
1212
HtmlLine htmlLine = new HtmlLine(null, "<p>My very <i>easy</i> example that should <div style='background: red'>work</div></p>also the text version should look<br>very fine... See also <a href='http://test.de' style='color: red'>test.de</a><br>see you soon :)");
13-
assertThat(htmlLine.getText(), equalTo("""
14-
My very easy example that should work
15-
also the text version should look
16-
very fine... See also test.de -> http://test.de
17-
see you soon :)\
18-
"""));
13+
assertThat(htmlLine.getText(), equalTo("My very easy example that should work\n" +
14+
"also the text version should look\n" +
15+
"very fine... See also test.de -> http://test.de\n" +
16+
"see you soon :)"));
1917
}
2018
}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ SOFTWARE.
7272

7373
<properties>
7474
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
75-
<maven.compiler.source>17</maven.compiler.source>
76-
<maven.compiler.target>17</maven.compiler.target>
75+
<maven.compiler.source>11</maven.compiler.source>
76+
<maven.compiler.target>11</maven.compiler.target>
7777
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
7878
<pebble.version>3.2.4</pebble.version>
7979
<lombok.version>1.18.36</lombok.version>

0 commit comments

Comments
 (0)