Skip to content

Commit af0d9c0

Browse files
committed
chore: fix lack of test resources when npm build is skip
1 parent 456e1cf commit af0d9c0

6 files changed

Lines changed: 231 additions & 2 deletions

File tree

spring-boot-admin-server-ui/pom.xml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
<relativePath>../spring-boot-admin-build</relativePath>
3232
</parent>
3333

34+
<properties>
35+
<ui-resources.relative-path>META-INF/spring-boot-admin-server-ui</ui-resources.relative-path>
36+
</properties>
37+
3438
<dependencies>
3539
<dependency>
3640
<groupId>de.codecentric</groupId>
@@ -73,7 +77,63 @@
7377
</dependency>
7478
</dependencies>
7579

80+
<profiles>
81+
<!--
82+
Profile: noNpm
83+
Set this profile to skip any frontend related build step in this project.
84+
Skipping frontend tests can be achieved by using default flag -D skipTests.
85+
-->
86+
<profile>
87+
<id>noNpm</id>
88+
<build>
89+
<plugins>
90+
<!--
91+
Run this only when this profile is active since, when it's not, the missing resources are
92+
already generated and provided under the right path from the NPM+Maven build.
93+
-->
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-resources-plugin</artifactId>
97+
<executions>
98+
<!--
99+
Copy some predefined resources, which are usually generated during the frontend build,
100+
otherwise some of the tests in
101+
the de.codecentric.boot.admin.server.ui.AdminUiServletApplicationTest will fail because
102+
Thymeleaf can't find the resources like, for example, sba-settings.js.
103+
-->
104+
<execution>
105+
<id>copy-dummy-test-resources</id>
106+
<phase>generate-resources</phase>
107+
<goals>
108+
<goal>copy-resources</goal>
109+
</goals>
110+
<configuration>
111+
<outputDirectory>${project.build.outputDirectory}/${ui-resources.relative-path}</outputDirectory>
112+
<resources>
113+
<resource>
114+
<directory>${project.basedir}/src/test/resources/${ui-resources.relative-path}</directory>
115+
<filtering>false</filtering>
116+
</resource>
117+
</resources>
118+
</configuration>
119+
</execution>
120+
</executions>
121+
</plugin>
122+
</plugins>
123+
</build>
124+
</profile>
125+
</profiles>
126+
76127
<build>
128+
<testResources>
129+
<testResource>
130+
<directory>${project.basedir}/src/test/resources</directory>
131+
<excludes>
132+
<!-- These resources are needed only when running with the noNpm profile active -->
133+
<exclude>${ui-resources.relative-path}/*</exclude>
134+
</excludes>
135+
</testResource>
136+
</testResources>
77137
<plugins>
78138
<plugin>
79139
<groupId>com.github.eirslett</groupId>
@@ -155,7 +215,7 @@
155215
</goals>
156216
<configuration>
157217
<outputDirectory>
158-
${project.build.outputDirectory}/META-INF/spring-boot-admin-server-ui
218+
${project.build.outputDirectory}/${ui-resources.relative-path}
159219
</outputDirectory>
160220
<resources>
161221
<resource>

spring-boot-admin-server-ui/src/test/java/de/codecentric/boot/admin/server/ui/AdminUiServletApplicationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static class TestAdminApplication {
6666
public static class SecurityConfiguration {
6767

6868
@Bean
69-
protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
69+
protected SecurityFilterChain filterChain(HttpSecurity http) {
7070
return http.csrf(AbstractHttpConfigurer::disable)
7171
.authorizeHttpRequests((authz) -> authz.anyRequest().permitAll())
7272
.anonymous((config) -> config.principal("anonymousUser"))
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!--
2+
~ Copyright 2014-2020 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+
17+
<!doctype html>
18+
<html class="h-full">
19+
<head>
20+
<base href="/" th:href="${baseUrl}" />
21+
<meta charset="utf-8" />
22+
<title th:text="${uiSettings.title}">Spring Boot Admin</title>
23+
<link
24+
rel="shortcut icon"
25+
th:href="${uiSettings.favicon}"
26+
type="image/png"
27+
/>
28+
<meta content="width=device-width, initial-scale=1" name="viewport" />
29+
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
30+
<meta content="telephone=no,email=no" name="format-detection" />
31+
<meta
32+
content="#42d3a5"
33+
name="theme-color"
34+
th:content="${uiSettings.theme.color}"
35+
/>
36+
37+
<link href="./variables.css" rel="stylesheet" />
38+
39+
<link
40+
as="style"
41+
rel="preload"
42+
th:each="cssExtension : ${cssExtensions}"
43+
th:href="'extensions/' + ${cssExtension.resourcePath}"
44+
/>
45+
<script lang="javascript" src="sba-settings.js"></script>
46+
<link
47+
as="script"
48+
rel="preload"
49+
th:each="jsExtension : ${jsExtensions}"
50+
th:href="'extensions/' + ${jsExtension.resourcePath}"
51+
/>
52+
<script type="module" crossorigin src="./assets/sba-DqWTbRYH.js"></script>
53+
<link rel="modulepreload" crossorigin href="./assets/index-DIiXKTRC.js">
54+
<link rel="stylesheet" crossorigin href="./assets/index-ZFGUj1iQ.css">
55+
<link rel="stylesheet" crossorigin href="./assets/sba-BZCrJZH3.css">
56+
</head>
57+
<body class="h-full">
58+
<div id="app"></div>
59+
60+
</body>
61+
</html>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!--
2+
~ Copyright 2014-2019 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+
17+
<!doctype html>
18+
<html class="h-full">
19+
<head>
20+
<base href="/" th:href="${baseUrl}" />
21+
<meta charset="utf-8" />
22+
<meta content="width=device-width, initial-scale=1" name="viewport" />
23+
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
24+
<meta content="telephone=no,email=no" name="format-detection" />
25+
<meta content="#42d3a5" name="theme-color" />
26+
27+
<link
28+
rel="shortcut icon"
29+
th:href="${uiSettings.favicon}"
30+
type="image/png"
31+
/>
32+
<title th:text="${uiSettings.title}">Spring Boot Admin - Login</title>
33+
<script th:inline="javascript">
34+
var csrf = /*[[${_csrf}]]*/ {};
35+
var uiSettings = /*[[${uiSettings}]]*/ {};
36+
var param = /*[[${param}]]*/ {};
37+
</script>
38+
<script type="module" crossorigin src="./assets/login-B2h9tIKB.js"></script>
39+
<link rel="modulepreload" crossorigin href="./assets/index-DIiXKTRC.js">
40+
<link rel="stylesheet" crossorigin href="./assets/index-ZFGUj1iQ.css">
41+
<link rel="stylesheet" crossorigin href="./assets/login-ohsYTZfl.css">
42+
</head>
43+
<body class="flex flex-col min-h-full h-full">
44+
<div
45+
class="absolute w-full h-full t-0 l-0 bg-white/40 backdrop-blur-sm z-0"
46+
></div>
47+
<section
48+
id="login"
49+
class="relative z-10 flex items-center justify-center h-full"
50+
></section>
51+
52+
</body>
53+
</html>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2014-2019 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+
17+
//This is a Thymleaf template whill will be rendered by the backend
18+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
19+
var SBA = {
20+
uiSettings: /*[[${uiSettings}]]*/ {},
21+
user: /*[[${user}]]*/ null,
22+
extensions: {
23+
js: /*[[${jsExtensions}]]*/ [],
24+
css: /*[[${cssExtensions}]]*/ [],
25+
},
26+
csrf: {
27+
parameterName: /*[[${_csrf} ? ${_csrf.parameterName} : 'null']]*/ null,
28+
headerName: /*[[${_csrf} ? ${_csrf.headerName} : 'null']]*/ null,
29+
},
30+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:root {
2+
--main-50: /*[(${palette.rgbColor50})]*/ #e8fbef;
3+
--main-100: /*[(${palette.rgbColor100})]*/ #d0f7df;
4+
--main-200: /*[(${palette.rgbColor200})]*/ #a1efbd;
5+
--main-300: /*[(${palette.rgbColor300})]*/ #71e69c;
6+
--main-400: /*[(${palette.rgbColor400})]*/ #41de7b;
7+
--main-500: /*[(${palette.rgbColor500})]*/ #22c55e;
8+
--main-600: /*[(${palette.rgbColor600})]*/ #1a9547;
9+
--main-700: /*[(${palette.rgbColor700})]*/ #116530;
10+
--main-800: /*[(${palette.rgbColor800})]*/ #09351a;
11+
--main-900: /*[(${palette.rgbColor900})]*/ #010603;
12+
13+
--bg-color-start: /*[(${uiSettings.theme.palette.shade300})]*/ #71e69c;
14+
--bg-color-stop: /*[(${uiSettings.theme.palette.shade700})]*/ #09351a;
15+
}
16+
17+
.bg-color-start {
18+
transition: 0.4s ease;
19+
stop-color: var(--bg-color-start);
20+
}
21+
22+
.bg-color-stop {
23+
transition: 0.4s ease;
24+
stop-color: var(--bg-color-stop);
25+
}

0 commit comments

Comments
 (0)