Archetype reference
What the archetypes generate and how the generated project is configured.
Maven coordinates
| Archetype | groupId | artifactId |
|---|---|---|
| Clean skeleton | io.github.nalukit.archetype | clean-modular-springboot-webapp |
| With example code | io.github.nalukit.archetype | modular-springboot-webapp |
Use -DarchetypeVersion=LATEST for the newest release. To try a local build, install the project with mvn clean install and generate with -DarchetypeVersion=HEAD-SNAPSHOT.
Archetype properties
| Property | Default | Meaning |
|---|---|---|
groupId, artifactId, version, package | asked by Maven | Standard Maven archetype properties of the generated project |
module | App | Name of the GWT module and its entry point class, for example Basic |
module-short-name | lower case module | Short name of the GWT module, used in the servlet path of the example and as moduleShortName in the client module |
mvn archetype:generate \
-DarchetypeGroupId=io.github.nalukit.archetype \
-DarchetypeArtifactId=modular-springboot-webapp \
-DarchetypeVersion=LATEST \
-DgroupId=com.example -DartifactId=myapp -Dversion=0.1-SNAPSHOT \
-Dpackage=com.example.myapp -Dmodule=MyApp -Dmodule-short-name=myapp
Generated versions
| Component | Version | Property in the parent POM |
|---|---|---|
| Java | 17 | maven.compiler.source (server), sourceLevel (GWT plugin) |
| GWT | 2.13.1 | gwt.version |
| Spring Boot | 4.1.0 | spring-boot.version |
| SnakeYAML | 2.6 | snakeyaml.version |
| gwt-maven-plugin | 1.2.0 | plugin management |
The parent POM imports the GWT and Spring Boot dependency management. Change the versions in its properties section.
Module layout
The generated project consists of a parent POM and three modules, named after your artifactId:
| Module | Packaging | Content |
|---|---|---|
<artifactId>-client | gwt-app | GWT module descriptor module.gwt.xml and the entry point class. Depends on gwt-user, gwt-dev and on the shared module, including its sources. |
<artifactId>-shared | jar | Code used by client and server. Builds a sources JAR for the GWT compiler. gwt-servlet-jakarta is provided. |
<artifactId>-server | war | Spring Boot application, application.yaml, static files under public and web.xml. Depends on the shared module and, at runtime, on the client module. |
myapp/
├── pom.xml
├── readme.txt
├── myapp-client/
│ ├── pom.xml
│ └── src/main/
│ ├── module.gwt.xml
│ └── java/…/App.java
├── myapp-shared/
│ ├── pom.xml
│ └── src/main/java/…
└── myapp-server/
├── pom.xml
└── src/main/
├── java/…/Application.java
├── resources/application.yaml
├── resources/public/ (index.html, css, favicon.ico)
└── webapp/WEB-INF/web.xml
Clean skeleton vs. example
| Module | clean-modular-springboot-webapp | modular-springboot-webapp |
|---|---|---|
| client | Empty entry point with an onModuleLoad() method | Example entry point that calls the greeting service |
| shared | package-info.java only | GreetingService, GreetingServiceAsync, GreetingResponse and FieldVerifier |
| server | Application, configuration and start page | Additionally GreetingServiceImpl, a servlet for the GWT-RPC service |
GWT module and client build
The client module inherits the GWT user library and the Clean theme, and declares the entry point:
<module>
<inherits name="com.google.gwt.user.User" />
<inherits name="com.google.gwt.user.theme.clean.Clean" />
<source path="" />
<entry-point class="${package}.${module}" />
</module>
The client POM configures the gwt-maven-plugin with moduleName, moduleShortName and a work directory under target/gwt. The parent POM points the plugin's launcherDir to <artifactId>-server/target/classes/launcherDir/. This is how the server serves the compiled GWT application.
Spring Boot server
Application extends SpringBootServletInitializer, so the WAR also runs in an external servlet container. It is annotated with @SpringBootApplication and @ServletComponentScan, which lets Spring find servlets annotated with @WebServlet. A nested component sets the document root to launcherDir when that directory exists. GWT-RPC needs this to find its serialization policy files during development.
Setting in application.yaml | Value |
|---|---|
server.port | 8080 |
spring.web.resources.static-locations | classpath:/launcherDir/,classpath:/public/ |
spring.application.name | your artifactId |
spring.servlet.multipart.max-file-size / max-request-size | 20MB |
server.error.whitelabel.enabled | false |
The server build repackages the WAR with the spring-boot-maven-plugin and names it after the artifactId (finalName). spring-boot-starter-tomcat is provided, and spring-boot-devtools is included for development.
Example GWT-RPC service
Only in modular-springboot-webapp. The shared module declares the service, the server implements it as a servlet:
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
GreetingResponse greetServer(String name) throws IllegalArgumentException;
}
@WebServlet("/${module-short-name}/greet")
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
// …
}
The relative path greet is resolved against the GWT module base URL, which contains the module-short-name. Both parts therefore fit together without further configuration.
Contributing
Clone the repository and run mvn clean verify. The build generates sample projects from both archetypes and compares them with reference projects. The generated samples are located in target/test-classes/projects/basic-webapp/project/basic-webapp of each archetype module. See the repository README.