An open API service indexing awesome lists of open source software.

https://github.com/gwtboot/restygwt-enum-date

RestyGWT Example for Date and Enum
https://github.com/gwtboot/restygwt-enum-date

Last synced: 4 months ago
JSON representation

RestyGWT Example for Date and Enum

Awesome Lists containing this project

README

          

# RestyGWT: restygwt-enum-date
RestyGWT Example for Date and Enum.

![Build Status](https://github.com/gwtboot/restygwt-enum-date/actions/workflows/maven.yml/badge.svg)

This example uses GWT Boot: https://github.com/gwtboot/gwt-boot-samples

This example shows how to structure your Maven modules for a development toward GWT 3.

# Modules

There are three modules available:
1. _Shared_: restygwt-enum-date-shared
2. _Client / Web browser with GWT_: restygwt-enum-date-client
3. _Server with Spring Boot_: restygwt-enum-date-server

# Development Time

On the development time you should start two processes: Client and Server. But this is
not a must. If you just need to build your UI you only need to start the Client part
and you can mock all the call to the REST APIs from Server part with simple interfaces.

## Shared
For the Shared classes and interfaces you just need to run mvn:clean install to deploy your shared to the local
Maven repository. The Shared module is your interface between the Client and the Server part.

## Client
For the Client part you can start the standard process for GWT just like it is shown in the example from GWT Boot:

```
https://github.com/gwtboot/gwt-boot-samples
```

Start with following command:

```
mvn gwt:generate-module gwt:devmode
```

## Server
For the Server part you just start the Spring Boot app. In this example the class:

```
RestygwtDateEnumServerApplication.java
```

That's it. You will have two clean separate processes which are independent of each other. All the
Maven libs are also independent, so it won't mix between the Client and the Server part.
Your Client module is therefore ready for GWT 3, because it does not use the Maven libs from the Server,
in this case, which come from the Spring Boot framework.

# Deployment / Runtime

On the deployment time you only need the Server module, since the Server module has a dependency
to the Client module but only for the JavaScript part. In the Client module the Maven Assembly Plugin will
create a special package with classifier _javascript_. In our example

```
restygwt-enum-date-client-1.0.0-SNAPSHOT-javascript
```

which only contains the transpiled JavaScript files from GWT. Here is how the dependency to the JavaScript
distribution created, see this [pom.xml](https://github.com/lofidewanto/restygwt-enum-date/blob/master/restygwt-enum-date-server/pom.xml):

```

maven-dependency-plugin


unpack
prepare-package

unpack




com.example
restygwt-enum-date-client
${restygwt-enum-date-client.version}
javascript


**/*index.html
${project.build.directory}/classes/static
false
true




```
Here is how to create the _javascript_ distribution from the Client module, see this [pom.xml](https://github.com/lofidewanto/restygwt-enum-date/blob/master/restygwt-enum-date-client/pom.xml) and this Assembly file [distribution.xml](https://github.com/lofidewanto/restygwt-enum-date/blob/master/restygwt-enum-date-client/src/assembly/distribution.xml):

```

maven-assembly-plugin


src/assembly/distribution.xml




make-assembly
package

single




```

```

javascript

jar


false



${project.build.directory}/${project.artifactId}-${project.version}
.

**/*


**/*index.html


```

To run in the deployment time you should build from the top Maven module _restygwt-enum-date_:

```
mvn:clean install
```

To run the Spring Boot standalone:

```
java -jar restygwt-enum-date-server-1.0.0-SNAPSHOT.jar
```

# Epilog

Advantages of this structure in comparison with the structure in [Spring Boot with GWT](https://github.com/gwtboot/gwt-boot-samples/tree/master/gwt-boot-sample-basic-with-spring-boot):
- Clean separation of the modules and each modules are independent of each other.
- The GWT module is clean and pure GWT Maven libs and is ready for GWT 3.
- The Spring Boot module is completely pure Spring Boot, no other Maven libs is included.
- In the deployment you just need to start the Server module with Spring Boot as you include the transpiled JavaScript automatically from the dependency from the Client module.