Skip to content

Commit ea0880e

Browse files
committed
Merge branch '250-migrate-to-spring-boot-3-3-1' of https://github.com/osscameroon/js-generator into 250-migrate-to-spring-boot-3-3-1
Update local repo
2 parents 0e33d97 + e3e6b35 commit ea0880e

File tree

13 files changed

+178
-219
lines changed

13 files changed

+178
-219
lines changed

jsgenerator-api/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
<build>
1919
<plugins>
20+
<plugin>
21+
<groupId>org.graalvm.buildtools</groupId>
22+
<artifactId>native-maven-plugin</artifactId>
23+
</plugin>
2024
<plugin>
2125
<groupId>org.springframework.boot</groupId>
2226
<artifactId>spring-boot-maven-plugin</artifactId>

jsgenerator-desktop/pom.xml

+18-152
Original file line numberDiff line numberDiff line change
@@ -9,179 +9,45 @@
99
<version>${revision}</version>
1010
</parent>
1111

12-
1312
<modelVersion>4.0.0</modelVersion>
14-
1513
<artifactId>jsgenerator-desktop</artifactId>
16-
1714
<name>jsgenerator-desktop</name>
1815

1916
<properties>
20-
<javafx.version>17.0.2</javafx.version>
21-
<javafx.plugin.version>0.0.8</javafx.plugin.version>
22-
<mainClass>com.osscameroon.jsgenerator.desktop.HelloApplication</mainClass>
17+
<start-class>com.osscameroon.jsgenerator.desktop.autoconfigure.JsGeneratorDesktop</start-class>
2318
</properties>
2419

25-
2620
<dependencies>
27-
28-
<dependency>
29-
<groupId>org.springframework.boot</groupId>
30-
<artifactId>spring-boot-starter</artifactId>
31-
</dependency>
32-
3321
<dependency>
3422
<groupId>com.osscameroon</groupId>
3523
<artifactId>jsgenerator-core</artifactId>
3624
</dependency>
37-
38-
39-
<dependency>
40-
<groupId>org.openjfx</groupId>
41-
<artifactId>javafx-controls</artifactId>
42-
<version>${javafx.version}</version>
43-
</dependency>
4425
<dependency>
4526
<groupId>org.openjfx</groupId>
4627
<artifactId>javafx-fxml</artifactId>
47-
<version>${javafx.version}</version>
48-
</dependency>
49-
<dependency>
50-
<groupId>org.openjfx</groupId>
51-
<artifactId>javafx-web</artifactId>
52-
<version>${javafx.version}</version>
5328
</dependency>
54-
<dependency>
55-
<groupId>org.controlsfx</groupId>
56-
<artifactId>controlsfx</artifactId>
57-
<version>11.1.1</version>
58-
</dependency>
59-
<dependency>
60-
<groupId>com.dlsc.formsfx</groupId>
61-
<artifactId>formsfx-core</artifactId>
62-
<version>11.5.0</version>
63-
<exclusions>
64-
<exclusion>
65-
<groupId>org.openjfx</groupId>
66-
<artifactId>*</artifactId>
67-
</exclusion>
68-
</exclusions>
69-
</dependency>
70-
<dependency>
71-
<groupId>net.synedra</groupId>
72-
<artifactId>validatorfx</artifactId>
73-
<version>0.4.0</version>
74-
<exclusions>
75-
<exclusion>
76-
<groupId>org.openjfx</groupId>
77-
<artifactId>*</artifactId>
78-
</exclusion>
79-
</exclusions>
80-
</dependency>
81-
<dependency>
82-
<groupId>org.kordamp.ikonli</groupId>
83-
<artifactId>ikonli-javafx</artifactId>
84-
<version>12.3.1</version>
85-
</dependency>
86-
<dependency>
87-
<groupId>org.kordamp.bootstrapfx</groupId>
88-
<artifactId>bootstrapfx-core</artifactId>
89-
<version>0.4.0</version>
90-
</dependency>
91-
<dependency>
92-
<groupId>eu.hansolo</groupId>
93-
<artifactId>tilesfx</artifactId>
94-
<version>17.1.9</version>
95-
<exclusions>
96-
<exclusion>
97-
<groupId>org.openjfx</groupId>
98-
<artifactId>*</artifactId>
99-
</exclusion>
100-
</exclusions>
101-
</dependency>
102-
103-
<!-- Dependency of eu.hansolo.tilesfx
104-
We added it in pom in order to avoid "module not found: eu.hansolo.fx.countries"
105-
-->
106-
107-
<dependency>
108-
<groupId>eu.hansolo.fx</groupId>
109-
<artifactId>countries</artifactId>
110-
<version>17.0.22</version>
111-
112-
</dependency>
113-
114-
115-
<!-- Dependency of eu.hansolo.tilesfx
116-
We added it in pom in order to avoid "module not found: eu.hansolo.fx.heatmap"
117-
-->
118-
119-
<dependency>
120-
<groupId>eu.hansolo.fx</groupId>
121-
<artifactId>heatmap</artifactId>
122-
<version>17.0.9</version>
123-
124-
</dependency>
125-
126-
127-
<!-- Dependency of eu.hansolo.tilesfx
128-
We added it in pom in order to avoid "module not found: eu.hansolo.toolboxfx"
129-
-->
130-
<dependency>
131-
<groupId>eu.hansolo</groupId>
132-
<artifactId>toolboxfx</artifactId>
133-
<version>17.0.28</version>
134-
135-
</dependency>
136-
137-
138-
<!-- Dependency of eu.hansolo.tilesfx
139-
We added it in pom in order to avoid "module not found: eu.hansolo.toolbox"
140-
-->
141-
142-
<dependency>
143-
<groupId>eu.hansolo</groupId>
144-
<artifactId>toolbox</artifactId>
145-
<version>17.0.22</version>
146-
147-
</dependency>
148-
149-
<!-- Dependency of eu.hansolo.tilesfx
150-
We added it in pom in order to avoid "module not found: javafx.swing"
151-
-->
152-
153-
154-
<dependency>
155-
<groupId>org.openjfx</groupId>
156-
<artifactId>javafx-swing</artifactId>
157-
<version>20-ea+4</version>
158-
</dependency>
159-
160-
161-
16229
</dependencies>
16330

16431
<build>
16532
<plugins>
16633
<plugin>
167-
<groupId>org.openjfx</groupId>
168-
<artifactId>javafx-maven-plugin</artifactId>
169-
<version>${javafx.plugin.version}</version>
170-
<executions>
171-
<execution>
172-
<!-- Default configuration for running with: mvn clean javafx:run -->
173-
<id>default-cli</id>
174-
<configuration>
175-
<mainClass>${mainClass}</mainClass>
176-
<launcher>app</launcher>
177-
<jlinkZipName>app</jlinkZipName>
178-
<jlinkImageName>app</jlinkImageName>
179-
<noManPages>true</noManPages>
180-
<stripDebug>true</stripDebug>
181-
<noHeaderFiles>true</noHeaderFiles>
182-
</configuration>
183-
</execution>
184-
</executions>
34+
<groupId>org.graalvm.buildtools</groupId>
35+
<artifactId>native-maven-plugin</artifactId>
36+
</plugin>
37+
<plugin>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-maven-plugin</artifactId>
40+
<configuration>
41+
<skip>false</skip>
42+
</configuration>
43+
</plugin>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-compiler-plugin</artifactId>
47+
<configuration>
48+
<source>22</source>
49+
<target>22</target>
50+
</configuration>
18551
</plugin>
18652
</plugins>
18753
</build>

jsgenerator-desktop/src/main/java/com/osscameroon/jsgenerator/desktop/HelloApplication.java

-23
This file was deleted.

jsgenerator-desktop/src/main/java/com/osscameroon/jsgenerator/desktop/HelloController.java

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.osscameroon.jsgenerator.desktop.autoconfigure;
2+
3+
import com.osscameroon.jsgenerator.core.autoconfigure.JsGeneratorCoreAutoconfigure;
4+
import com.osscameroon.jsgenerator.desktop.controller.FxmlNavigator;
5+
import com.osscameroon.jsgenerator.desktop.controller.FxmlResolver;
6+
import com.osscameroon.jsgenerator.desktop.controller.HelloViewController;
7+
import javafx.application.Application;
8+
import javafx.fxml.FXMLLoader;
9+
import javafx.scene.Parent;
10+
import javafx.scene.Scene;
11+
import javafx.stage.Stage;
12+
import org.springframework.boot.SpringApplication;
13+
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
14+
import org.springframework.boot.autoconfigure.SpringBootApplication;
15+
import org.springframework.context.ApplicationContext;
16+
import org.springframework.context.annotation.Bean;
17+
import org.springframework.context.annotation.Lazy;
18+
import org.springframework.core.io.ClassPathResource;
19+
20+
import java.io.IOException;
21+
22+
@ImportAutoConfiguration(JsGeneratorCoreAutoconfigure.class)
23+
@SpringBootApplication(scanBasePackageClasses = HelloViewController.class)
24+
public class JsGeneratorDesktop extends Application {
25+
private static ApplicationContext context;
26+
private static FxmlResolver fxmlResolver;
27+
private static Scene scene;
28+
29+
public static void main(String[] args) {
30+
context = SpringApplication.run(JsGeneratorDesktop.class, args);
31+
fxmlResolver = context.getBean(FxmlResolver.class);
32+
launch(JsGeneratorDesktop.class, args);
33+
}
34+
35+
/**
36+
* Inject this bean to navigate from one view to another, like a router.
37+
*
38+
* @return
39+
*/
40+
@Bean
41+
@Lazy
42+
public FxmlNavigator fxmlNavigator() {
43+
return scene::setRoot;
44+
}
45+
46+
@Bean
47+
public FxmlResolver fxmlResolver() {
48+
return path -> {
49+
path = "com/osscameroon/jsgenerator/desktop/controller/%s.fxml".formatted(path);
50+
final var loader = new FXMLLoader(new ClassPathResource(path).getURL());
51+
loader.setControllerFactory(context::getBean);
52+
return (Parent) loader.load();
53+
};
54+
}
55+
56+
@Override
57+
public void start(Stage stage) throws IOException {
58+
final var parent = fxmlResolver.resolve("hello-view");
59+
stage.setScene(scene = new Scene(parent));
60+
stage.show();
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.osscameroon.jsgenerator.desktop.controller;
2+
3+
import javafx.scene.Parent;
4+
5+
@FunctionalInterface
6+
public interface FxmlNavigator {
7+
void navigate(Parent parent);
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.osscameroon.jsgenerator.desktop.controller;
2+
3+
import javafx.scene.Parent;
4+
5+
import java.io.IOException;
6+
7+
@FunctionalInterface
8+
public interface FxmlResolver {
9+
Parent resolve(String relativePathWithoutExtension) throws IOException;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.osscameroon.jsgenerator.desktop.controller;
2+
3+
import com.osscameroon.jsgenerator.core.Converter;
4+
import javafx.fxml.FXML;
5+
import javafx.scene.control.Label;
6+
import javafx.scene.control.TextArea;
7+
import org.springframework.stereotype.Component;
8+
9+
import java.io.ByteArrayInputStream;
10+
import java.io.ByteArrayOutputStream;
11+
import java.io.IOException;
12+
import java.nio.charset.StandardCharsets;
13+
14+
@Component
15+
public final class HelloViewController {
16+
private final Converter converter;
17+
18+
@FXML
19+
private TextArea inputArea;
20+
@FXML
21+
private Label outputLabel;
22+
23+
public HelloViewController(Converter converter) {
24+
this.converter = converter;
25+
}
26+
27+
@FXML
28+
private void convert() throws IOException {
29+
try (var stream = new ByteArrayOutputStream()) {
30+
converter.convert(new ByteArrayInputStream(inputArea.textProperty().getValue().getBytes()), stream);
31+
outputLabel.setText(stream.toString(StandardCharsets.UTF_8));
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
module com.osscameroon.jsgenerator.desktop {
2+
exports com.osscameroon.jsgenerator.desktop.autoconfigure;
3+
exports com.osscameroon.jsgenerator.desktop.controller;
4+
5+
opens com.osscameroon.jsgenerator.desktop.controller to javafx.fxml, spring.beans;
6+
opens com.osscameroon.jsgenerator.desktop.autoconfigure to javafx.fxml, spring.beans;
27

38
requires com.osscameroon.jsgenerator.core;
4-
requires javafx.controls;
5-
requires javafx.fxml;
6-
requires javafx.web;
79

8-
requires org.controlsfx.controls;
9-
requires com.dlsc.formsfx;
10-
requires net.synedra.validatorfx;
11-
requires org.kordamp.ikonli.javafx;
12-
requires org.kordamp.bootstrapfx.core;
13-
requires eu.hansolo.tilesfx;
10+
requires spring.boot.autoconfigure;
11+
requires spring.boot;
12+
requires spring.context;
1413

15-
opens com.osscameroon.jsgenerator.desktop to javafx.fxml;
16-
exports com.osscameroon.jsgenerator.desktop;
14+
requires javafx.graphics;
15+
requires javafx.controls;
16+
requires javafx.fxml;
17+
requires spring.core;
1718
}

0 commit comments

Comments
 (0)