Skip to content

Commit 6ceddc5

Browse files
authored
Merge pull request #988 from terrestris/update-keycloak
Include keycloak-js assets
2 parents 3547196 + 9237c35 commit 6ceddc5

22 files changed

+160
-9580
lines changed

pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
<jacoco-plugin.version>0.8.13</jacoco-plugin.version>
103103
<maven-project-info-reports-plugin.version>3.9.0</maven-project-info-reports-plugin.version>
104104
<jib-maven-plugin.version>3.4.6</jib-maven-plugin.version>
105+
<exec-maven-plugin.version>3.1.0</exec-maven-plugin.version>
105106

106107
<!-- Spring -->
107108
<spring-boot.version>3.5.5</spring-boot.version>
@@ -133,12 +134,14 @@
133134

134135
<!-- GeoServer/Geodata -->
135136
<geoserver-manager.version>1.7.0</geoserver-manager.version>
137+
<geotools.version>33.2</geotools.version>
136138

137139
<!-- Utils -->
138140
<commons.io.version>2.20.0</commons.io.version>
139141
<tika.version>3.2.2</tika.version>
140142
<reflections.version>0.10.2</reflections.version>
141143
<evo-inflector.version>1.3</evo-inflector.version>
144+
<commons-compress.version>1.28.0</commons-compress.version>
142145

143146
<!-- Testing -->
144147
<maven-project-info-reports-plugin.version>3.9.0</maven-project-info-reports-plugin.version>
@@ -147,7 +150,10 @@
147150

148151
<!-- Jib -->
149152
<image>docker-public.terrestris.de/shogun/${project.artifactId}:latest</image>
150-
<geotools.version>33.2</geotools.version>
153+
154+
<!-- Frontend (Landing Page) -->
155+
<bootstrap.version>5.1.1</bootstrap.version>
156+
<fontawesome.version>5.15.4</fontawesome.version>
151157
</properties>
152158

153159
<build>
@@ -501,6 +507,12 @@
501507
<version>${commons.io.version}</version>
502508
</dependency>
503509

510+
<dependency>
511+
<groupId>org.apache.commons</groupId>
512+
<artifactId>commons-compress</artifactId>
513+
<version>${commons-compress.version}</version>
514+
</dependency>
515+
504516
<!-- Apache Tika -->
505517
<dependency>
506518
<groupId>org.apache.tika</groupId>

shogun-boot/pom.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@
161161
<groupId>org.geotools</groupId>
162162
<artifactId>gt-main</artifactId>
163163
</dependency>
164+
165+
<dependency>
166+
<groupId>org.apache.commons</groupId>
167+
<artifactId>commons-compress</artifactId>
168+
</dependency>
164169
</dependencies>
165170

166171
<build>
@@ -198,6 +203,58 @@
198203
</execution>
199204
</executions>
200205
</plugin>
206+
<plugin>
207+
<groupId>org.codehaus.mojo</groupId>
208+
<artifactId>exec-maven-plugin</artifactId>
209+
<version>${exec-maven-plugin.version}</version>
210+
<executions>
211+
<execution>
212+
<id>download-keycloak-js</id>
213+
<phase>compile</phase>
214+
<goals>
215+
<goal>java</goal>
216+
</goals>
217+
<configuration>
218+
<mainClass>de.terrestris.shogun.boot.util.ResourceDownloader</mainClass>
219+
<arguments>
220+
<argument>https://registry.npmjs.org/keycloak-js/-/keycloak-js-${keycloak.version}.tgz</argument>
221+
<argument>${project.build.directory}/classes/public/assets/lib/keycloak</argument>
222+
</arguments>
223+
<classpathScope>compile</classpathScope>
224+
</configuration>
225+
</execution>
226+
<execution>
227+
<id>download-bootstrap</id>
228+
<phase>compile</phase>
229+
<goals>
230+
<goal>java</goal>
231+
</goals>
232+
<configuration>
233+
<mainClass>de.terrestris.shogun.boot.util.ResourceDownloader</mainClass>
234+
<arguments>
235+
<argument>https://registry.npmjs.org/bootstrap/-/bootstrap-${bootstrap.version}.tgz</argument>
236+
<argument>${project.build.directory}/classes/public/assets/lib/bootstrap</argument>
237+
</arguments>
238+
<classpathScope>compile</classpathScope>
239+
</configuration>
240+
</execution>
241+
<execution>
242+
<id>download-fontawesome</id>
243+
<phase>compile</phase>
244+
<goals>
245+
<goal>java</goal>
246+
</goals>
247+
<configuration>
248+
<mainClass>de.terrestris.shogun.boot.util.ResourceDownloader</mainClass>
249+
<arguments>
250+
<argument>https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-${fontawesome.version}.tgz</argument>
251+
<argument>${project.build.directory}/classes/public/assets/lib/fontawesome</argument>
252+
</arguments>
253+
<classpathScope>compile</classpathScope>
254+
</configuration>
255+
</execution>
256+
</executions>
257+
</plugin>
201258
<plugin>
202259
<groupId>io.github.git-commit-id</groupId>
203260
<artifactId>git-commit-id-maven-plugin</artifactId>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* SHOGun, https://terrestris.github.io/shogun/
2+
*
3+
* Copyright © 2025-present terrestris GmbH & Co. KG
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.txt
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+
package de.terrestris.shogun.boot.util;
18+
19+
import lombok.extern.log4j.Log4j2;
20+
import org.apache.commons.compress.archivers.ArchiveEntry;
21+
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
22+
23+
import java.io.FileInputStream;
24+
import java.io.IOException;
25+
import java.io.InputStream;
26+
import java.net.URI;
27+
import java.net.URISyntaxException;
28+
import java.nio.file.Files;
29+
import java.nio.file.Path;
30+
import java.nio.file.Paths;
31+
import java.nio.file.StandardCopyOption;
32+
import java.util.zip.GZIPInputStream;
33+
34+
/**
35+
* Utility class for downloading and extracting *.tar.gz resources from a given URL.
36+
*
37+
* It is currently designed to download resource assets (e.g. the Keycloak JS adapter) for the landing page during
38+
* the project initialization only.
39+
*/
40+
@Log4j2
41+
public class ResourceDownloader {
42+
public static void main(String[] args) throws IOException, URISyntaxException {
43+
String fileUrl = args[0];
44+
String extractPath = args[1];
45+
46+
ResourceDownloader.downloadAndExtract(fileUrl, extractPath);
47+
}
48+
49+
public static void downloadAndExtract(String fileUrl, String extractPath) throws IOException, URISyntaxException {
50+
log.info("Downloading file from URL: {}", fileUrl);
51+
52+
Path downloadedFile = Files.createTempDirectory("resource-downloader-");
53+
try (InputStream in = new URI(fileUrl).toURL().openStream()) {
54+
Files.copy(in, downloadedFile, StandardCopyOption.REPLACE_EXISTING);
55+
}
56+
57+
log.info("Extracting archive contents to: {}", extractPath);
58+
59+
Path extractionDir = Paths.get(extractPath);
60+
if (!Files.exists(extractionDir)) {
61+
Files.createDirectories(extractionDir);
62+
}
63+
64+
try (GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(downloadedFile.toFile()));
65+
TarArchiveInputStream tarInputStream = new TarArchiveInputStream(gzipInputStream)) {
66+
ArchiveEntry entry;
67+
while ((entry = tarInputStream.getNextEntry()) != null) {
68+
log.info("Extracting file: {}", entry.getName());
69+
70+
Path outputFile = extractionDir.resolve(entry.getName());
71+
72+
if (entry.isDirectory()) {
73+
Files.createDirectories(outputFile);
74+
} else {
75+
Files.createDirectories(outputFile.getParent());
76+
Files.copy(tarInputStream, outputFile, StandardCopyOption.REPLACE_EXISTING);
77+
}
78+
}
79+
}
80+
81+
log.info("Successfully downloaded and extracted resources.");
82+
}
83+
}

shogun-boot/src/main/resources/public/assets/lib/bootstrap/css/bootstrap.min.css

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

shogun-boot/src/main/resources/public/assets/lib/bootstrap/js/bootstrap.bundle.min.js

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

shogun-boot/src/main/resources/public/assets/lib/fontawesome/css/all.min.css

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

0 commit comments

Comments
 (0)