Skip to content

Commit bc10a10

Browse files
committed
Merge remote-tracking branch 'origin/update-from-template' into develop
2 parents 10f2bfe + 44bfac8 commit bc10a10

File tree

9 files changed

+151
-35
lines changed

9 files changed

+151
-35
lines changed

.config/pmd/java/ruleset.xml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,71 @@
218218
</properties>
219219
</rule>
220220

221+
<rule name="AvoidPostConstruct"
222+
language="java"
223+
message="Avoid @PostConstruct"
224+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
225+
<description>
226+
Using a `@PostConstruct` method is usually only done when field injection is used and initialization needs to be performed after that.
227+
228+
It's better to do this directly in the constructor with constructor injection, so that all logic will be encapsulated there.
229+
This also makes using the bean in environments where JavaEE is not present - for example in tests - a lot easier, as forgetting to call the `@PostConstruct` method is no longer possible.
230+
</description>
231+
<priority>3</priority>
232+
<properties>
233+
<property name="xpath">
234+
<value>
235+
<![CDATA[
236+
//MethodDeclaration[pmd-java:hasAnnotation('jakarta.annotation.PostConstruct')]
237+
]]>
238+
</value>
239+
</property>
240+
</properties>
241+
</rule>
242+
243+
<rule name="AvoidPreDestroy"
244+
language="java"
245+
message="Avoid @PreDestroy"
246+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
247+
<description>
248+
`@PreDestroy` should be replaced by implementing `AutoCloseable` and overwriting the `close` method instead.
249+
250+
This also makes using the bean in environments where JavaEE is not present - for example in tests - a lot easier, as forgetting to call the `@PreDestroy` method is no much more difficult.
251+
</description>
252+
<priority>3</priority>
253+
<properties>
254+
<property name="xpath">
255+
<value>
256+
<![CDATA[
257+
//MethodDeclaration[pmd-java:hasAnnotation('jakarta.annotation.PreDestroy')]
258+
]]>
259+
</value>
260+
</property>
261+
</properties>
262+
</rule>
263+
264+
<rule name="AvoidUnmanagedThreads"
265+
language="java"
266+
message="Avoid unmanaged threads"
267+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
268+
<description>
269+
Trying to manually manage threads usually gets quickly out of control and may result in various problems like uncontrollable spawning of threads.
270+
Threads can also not be cancelled properly.
271+
272+
Use managed Thread services like `ExecutorService` and `CompletableFuture` instead.
273+
</description>
274+
<priority>3</priority>
275+
<properties>
276+
<property name="xpath">
277+
<value>
278+
<![CDATA[
279+
//MethodCall[pmd-java:matchesSig('java.lang.Thread#start()') or pmd-java:matchesSig('java.lang.Thread#startVirtualThread(java.lang.Runnable)') or pmd-java:matchesSig('java.lang.Thread$Builder#start(java.lang.Runnable)')]
280+
]]>
281+
</value>
282+
</property>
283+
</properties>
284+
</rule>
285+
221286
<rule name="JavaObjectSerializationIsUnsafe"
222287
language="java"
223288
message="Using Java Object (De-)Serialization is unsafe and has led to too many security vulnerabilities"

.github/workflows/broken-links.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
echo "number=$(gh issue list -l 'bug' -l 'automated' -L 1 -S 'in:title \"Link Checker Report\"' -s 'open' --json 'number' --jq '.[].number')" >> $GITHUB_OUTPUT
3030
env:
3131
GH_TOKEN: ${{ github.token }}
32-
32+
3333
- name: Close issue if everything is fine
3434
if: steps.lychee.outputs.exit_code == 0 && steps.find-issue.outputs.number != ''
3535
run: gh issue close -r 'not planned' ${{ steps.find-issue.outputs.number }}

.github/workflows/check-build.yml

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,27 @@ jobs:
2626
build:
2727
runs-on: ubuntu-latest
2828
timeout-minutes: 30
29-
3029
strategy:
3130
matrix:
3231
java: [17, 21]
3332
distribution: [temurin]
34-
3533
steps:
3634
- uses: actions/checkout@v5
37-
35+
3836
- name: Set up JDK
3937
uses: actions/setup-java@v5
4038
with:
4139
distribution: ${{ matrix.distribution }}
4240
java-version: ${{ matrix.java }}
43-
cache: 'maven'
44-
41+
42+
- name: Cache Maven
43+
uses: actions/cache@v4
44+
with:
45+
path: ~/.m2/repository
46+
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
47+
restore-keys: |
48+
${{ runner.os }}-mvn-build-
49+
4550
- name: Cache Vaadin prod bundles
4651
uses: actions/cache@v4
4752
with:
@@ -50,10 +55,10 @@ jobs:
5055
key: ${{ runner.os }}-vaadin-prod-bundles-${{ hashFiles('**/pom.xml') }}
5156
restore-keys: |
5257
${{ runner.os }}-vaadin-prod-bundles-
53-
58+
5459
- name: Build with Maven
55-
run: ./mvnw -B clean package -Pproduction
56-
60+
run: ./mvnw -B clean package
61+
5762
- name: Check for uncommited changes
5863
run: |
5964
if [[ "$(git status --porcelain)" != "" ]]; then
@@ -83,21 +88,34 @@ jobs:
8388
runs-on: ubuntu-latest
8489
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
8590
timeout-minutes: 15
86-
8791
strategy:
8892
matrix:
8993
java: [17]
9094
distribution: [temurin]
91-
9295
steps:
9396
- uses: actions/checkout@v5
94-
97+
9598
- name: Set up JDK
9699
uses: actions/setup-java@v5
97100
with:
98101
distribution: ${{ matrix.distribution }}
99102
java-version: ${{ matrix.java }}
100-
cache: 'maven'
103+
104+
- name: Cache Maven
105+
uses: actions/cache@v4
106+
with:
107+
path: ~/.m2/repository
108+
key: ${{ runner.os }}-mvn-checkstyle-${{ hashFiles('**/pom.xml') }}
109+
restore-keys: |
110+
${{ runner.os }}-mvn-checkstyle-
111+
112+
- name: CheckStyle Cache
113+
uses: actions/cache@v4
114+
with:
115+
path: '**/target/checkstyle-cachefile'
116+
key: ${{ runner.os }}-checkstyle-${{ hashFiles('**/pom.xml') }}
117+
restore-keys: |
118+
${{ runner.os }}-checkstyle-
101119
102120
- name: Run Checkstyle
103121
run: ./mvnw -B checkstyle:check -P checkstyle -T2C
@@ -106,12 +124,10 @@ jobs:
106124
runs-on: ubuntu-latest
107125
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
108126
timeout-minutes: 15
109-
110127
strategy:
111128
matrix:
112129
java: [17]
113130
distribution: [temurin]
114-
115131
steps:
116132
- uses: actions/checkout@v5
117133

@@ -120,7 +136,22 @@ jobs:
120136
with:
121137
distribution: ${{ matrix.distribution }}
122138
java-version: ${{ matrix.java }}
123-
cache: 'maven'
139+
140+
- name: Cache Maven
141+
uses: actions/cache@v4
142+
with:
143+
path: ~/.m2/repository
144+
key: ${{ runner.os }}-mvn-pmd-${{ hashFiles('**/pom.xml') }}
145+
restore-keys: |
146+
${{ runner.os }}-mvn-pmd-
147+
148+
- name: PMD Cache
149+
uses: actions/cache@v4
150+
with:
151+
path: '**/target/pmd/pmd.cache'
152+
key: ${{ runner.os }}-pmd-${{ hashFiles('**/pom.xml') }}
153+
restore-keys: |
154+
${{ runner.os }}-pmd-
124155
125156
- name: Run PMD
126157
run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C

.github/workflows/release.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,30 @@ permissions:
88
contents: write
99
pull-requests: write
1010

11+
# DO NOT RESTORE CACHE for critical release steps to prevent a (extremely unlikely) scenario
12+
# where a supply chain attack could be achieved due to poisoned cache
1113
jobs:
1214
check-code:
1315
runs-on: ubuntu-latest
1416
timeout-minutes: 30
1517
steps:
1618
- uses: actions/checkout@v5
17-
19+
1820
- name: Set up JDK
1921
uses: actions/setup-java@v5
2022
with:
2123
java-version: '17'
2224
distribution: 'temurin'
23-
cache: 'maven'
24-
25+
26+
# Try to reuse existing cache from check-build
27+
- name: Try restore Maven Cache
28+
uses: actions/cache/restore@v4
29+
with:
30+
path: ~/.m2/repository
31+
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: |
33+
${{ runner.os }}-mvn-build-
34+
2535
- name: Build with Maven
2636
run: ./mvnw -B clean package -Pproduction -T2C
2737

@@ -51,30 +61,30 @@ jobs:
5161
upload_url: ${{ steps.create-release.outputs.upload_url }}
5262
steps:
5363
- uses: actions/checkout@v5
54-
64+
5565
- name: Configure Git
5666
run: |
5767
git config --global user.email "[email protected]"
5868
git config --global user.name "GitHub Actions"
59-
69+
6070
- name: Un-SNAP
6171
run: ./mvnw -B versions:set -DremoveSnapshot -DprocessAllModules -DgenerateBackupPoms=false
62-
72+
6373
- name: Get version
6474
id: version
6575
run: |
6676
version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
6777
echo "release=$version" >> $GITHUB_OUTPUT
6878
echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT
69-
79+
7080
- name: Commit and Push
7181
run: |
7282
git add -A
7383
git commit -m "Release ${{ steps.version.outputs.release }}"
7484
git push origin
7585
git tag v${{ steps.version.outputs.release }}
7686
git push origin --tags
77-
87+
7888
- name: Create Release
7989
id: create-release
8090
uses: shogo82148/actions-create-release@4661dc54f7b4b564074e9fbf73884d960de569a3 # v1
@@ -118,7 +128,7 @@ jobs:
118128
timeout-minutes: 60
119129
steps:
120130
- uses: actions/checkout@v5
121-
131+
122132
- name: Init Git and pull
123133
run: |
124134
git config --global user.email "[email protected]"
@@ -174,7 +184,7 @@ jobs:
174184
timeout-minutes: 15
175185
steps:
176186
- uses: actions/checkout@v5
177-
187+
178188
- name: Init Git and pull
179189
run: |
180190
git config --global user.email "[email protected]"
@@ -186,7 +196,15 @@ jobs:
186196
with:
187197
java-version: '17'
188198
distribution: 'temurin'
189-
cache: 'maven'
199+
200+
# Try to reuse existing cache from check-build
201+
- name: Try restore Maven Cache
202+
uses: actions/cache/restore@v4
203+
with:
204+
path: ~/.m2/repository
205+
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
206+
restore-keys: |
207+
${{ runner.os }}-mvn-build-
190208
191209
- name: Build site
192210
run: ./mvnw -B compile site -DskipTests -T2C
@@ -214,7 +232,7 @@ jobs:
214232
timeout-minutes: 10
215233
steps:
216234
- uses: actions/checkout@v5
217-
235+
218236
- name: Init Git and pull
219237
run: |
220238
git config --global user.email "[email protected]"
@@ -229,7 +247,7 @@ jobs:
229247
git add -A
230248
git commit -m "Preparing for next development iteration"
231249
git push origin
232-
250+
233251
- name: pull-request
234252
env:
235253
GH_TOKEN: ${{ github.token }}

.github/workflows/test-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
env:
3434
PACKAGES_CENTRAL_TOKEN: ${{ secrets.PACKAGES_CENTRAL_TOKEN }}
3535
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
36-
36+
3737
- name: Set up JDK
3838
uses: actions/setup-java@v5
3939
with: # running setup-java again overwrites the settings.xml

.github/workflows/update-from-template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
# If no PAT is used the following error occurs on a push:
4444
# refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission
4545
token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }}
46-
46+
4747
- name: Init Git
4848
run: |
4949
git config --global user.email "[email protected]"
@@ -190,7 +190,7 @@ jobs:
190190
# If no PAT is used the following error occurs on a push:
191191
# refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission
192192
token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }}
193-
193+
194194
- name: Init Git
195195
run: |
196196
git config --global user.email "[email protected]"

.idea/codeStyles/Project.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flow/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
<dependency>
274274
<groupId>com.puppycrawl.tools</groupId>
275275
<artifactId>checkstyle</artifactId>
276-
<version>11.0.0</version>
276+
<version>11.0.1</version>
277277
</dependency>
278278
</dependencies>
279279
<configuration>
@@ -300,6 +300,7 @@
300300
<artifactId>maven-pmd-plugin</artifactId>
301301
<version>3.27.0</version>
302302
<configuration>
303+
<analysisCache>true</analysisCache>
303304
<includeTests>true</includeTests>
304305
<printFailingErrors>true</printFailingErrors>
305306
<rulesets>

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<dependency>
5050
<groupId>com.puppycrawl.tools</groupId>
5151
<artifactId>checkstyle</artifactId>
52-
<version>11.0.0</version>
52+
<version>11.0.1</version>
5353
</dependency>
5454
</dependencies>
5555
<configuration>
@@ -76,6 +76,7 @@
7676
<artifactId>maven-pmd-plugin</artifactId>
7777
<version>3.27.0</version>
7878
<configuration>
79+
<analysisCache>true</analysisCache>
7980
<includeTests>true</includeTests>
8081
<printFailingErrors>true</printFailingErrors>
8182
<rulesets>

0 commit comments

Comments
 (0)