Skip to content

Commit d4ee371

Browse files
Update getting started (#354)
Now uses gwt-maven-archetype and gwt-maven-springboot-archetype, and has an IntelliJ section. Co-authored-by: Colin Alworth <[email protected]>
1 parent 586370f commit d4ee371

17 files changed

+285
-16
lines changed

src/main/markdown/doc/latest/tutorial/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ You may also optionally do the following:
3737

3838
### Build a Sample GWT Application
3939

40-
1. [Build a Sample GWT Application](gettingstarted.html)
40+
1. [Build a Sample GWT Application](gettingstarted-v2.html)
4141
* Get started with GWT by developing the StockWatcher application from scratch. You'll learn to create a GWT project, build the UI with GWT wigdets and panels, code the client-side functionality in the Java language, debug in development mode, apply CSS styles, compile the Java into JavaScript, and run the application in production mode.
4242

4343
### Client-Server Communication

src/main/markdown/download.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Download
4747
<a href="versions.html">[Old versions]</a>
4848
</p>
4949
<p style='font-size: 90%;'>
50-
Next: Go to <a href="gettingstarted.html">Getting Started with the GWT SDK</a>
50+
Next: Go to <a href="gettingstarted-v2.html">Getting Started with the GWT SDK</a>
5151
</p>
5252
</div>
5353
</div>
@@ -66,7 +66,7 @@ Download
6666
<div class='moreinfo'>
6767
<a class='download-button' href="http://gwt-plugins.github.io/documentation/gwt-eclipse-plugin/Download.html">Download Plugin &amp; SDKs</a>
6868
<p style='font-size: 90%;'>
69-
Next: Go to <a href="usingeclipse.html">Set up Eclipse</a>, then <a href="doc/latest/tutorial/gettingstarted.html">Build a Sample App</a>
69+
Next: Go to <a href="usingeclipse.html">Set up Eclipse</a>, then <a href="doc/latest/tutorial/gettingstarted-v2.html">Build a Sample App</a>
7070
</p>
7171
</div>
7272
</div>
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
Getting Started
2+
===
3+
4+
Starting with 2.11.0 of the GWT SDK the [webAppCreator](gettingstarted-outdated.html) is deprecated. Instead, we will use
5+
the [gwt-maven-archetypes](https://github.com/tbroyer/gwt-maven-archetypes) by Thomas Broyer to create a new GWT project. Using the **artifactId: modular-webapp**
6+
the plugin generates a Maven project with separate modules for
7+
8+
* client
9+
* server
10+
* shared.
11+
12+
**Separation of code is the way to go in modern web development.**
13+
14+
## TOC
15+
16+
* [Prerequisites](#prereqs)
17+
* [Create your first web application](#create)
18+
* [Run locally in super dev mode](#run)
19+
* [Make a few changes](#change)
20+
* [Debugging the browser](#bebug)
21+
* [Compile and run in production mode](#compile)
22+
* [Set up an IDE](#setup)
23+
24+
## Prerequisites<a id="prereqs"></a>
25+
26+
1. GWT 2.11.0 still supports Java 8 (running and building). We suggest to use at least Java 11 or 17. If necessary, download and
27+
install the Java SE Development Kit (JDK) <a href="https://adoptium.net/de/temurin/releases/"
28+
rel="nofollow">from Eclipse Temurin</a> for your platform. Install the JDK by following the
29+
installation instructions.
30+
2. Apache Maven is also necessary to run the gwt-maven-archetype. In this sample the Maven CLI is used. If
31+
you don't already have it, install <a href="https://maven.apache.org/download.cgi" rel="nofollow">Apache Maven</a>.
32+
33+
If you have problems running the gwt-maven-archetype from the command line, try setting the
34+
$JDK_HOME environment variable with export JDK_HOME="[pathToJDK]" and $MAVEN_HOME environment variable with export MAVEN_HOME="[pathToMaven]"
35+
and add both to the path.
36+
37+
## Create your first web application<a id="create"></a>
38+
39+
Open a terminal and choose the directory you like to generate the project into. Generate a new project using:
40+
41+
```
42+
mvn archetype:generate \
43+
-DarchetypeGroupId=net.ltgt.gwt.archetypes \
44+
-DarchetypeVersion=LATEST \
45+
-DarchetypeArtifactId=modular-webapp
46+
```
47+
48+
The archetype will request values for:
49+
50+
* **groupId**: com.mycompany.mywebapp
51+
* **artifactId**: mywebapp
52+
* **version**: HEAD-SNAPSHOT
53+
* **package**: com.mycompany.mywebapp
54+
* **module-short-name**: mywebap
55+
56+
After entering the parameter above, the terminal shows something like that:
57+
58+
```
59+
[INFO] Using property: module = App
60+
Define value for property 'groupId': com.mycompany.mywebapp
61+
Define value for property 'artifactId': mywebapp
62+
Define value for property 'version' 1.0-SNAPSHOT: : HEAD-SNAPSHOT
63+
Define value for property 'package' com.mycompany.mywebapp: : com.mycompany.mywebapp
64+
Define value for property 'module-short-name' app: : MyWebApp
65+
Confirm properties configuration:
66+
module: App
67+
groupId: com.mycompany.mywebapp
68+
artifactId: mywebapp
69+
version: HEAD-SNAPSHOT
70+
package: com.mycompany.mywebapp
71+
module-short-name: mywebapp
72+
Y: :
73+
```
74+
75+
Enter **Y** to continue.
76+
77+
Now, the new project will be generated and you see the following messages:
78+
79+
```
80+
[INFO] ----------------------------------------------------------------------------
81+
[INFO] Using following parameters for creating project from Archetype: modular-webapp:LATEST
82+
[INFO] ----------------------------------------------------------------------------
83+
[INFO] Parameter: groupId, Value: com.mycompany.mywebapp
84+
[INFO] Parameter: artifactId, Value: mywebapp
85+
[INFO] Parameter: version, Value: HEAD-SNAPSHOT
86+
[INFO] Parameter: package, Value: com.mycompany.mywebapp
87+
[INFO] Parameter: packageInPathFormat, Value: com/mycompany/mywebapp
88+
[INFO] Parameter: package, Value: com.mycompany.mywebapp
89+
[INFO] Parameter: module-short-name, Value: MyWebApp
90+
[INFO] Parameter: module, Value: App
91+
[INFO] Parameter: groupId, Value: com.mycompany.mywebapp
92+
[INFO] Parameter: artifactId, Value: mywebapp
93+
[INFO] Parameter: version, Value: HEAD-SNAPSHOT
94+
[INFO] Parent element not overwritten in /Users/gwt-user/Desktop/mywebapp/mywebapp-client/pom.xml
95+
[INFO] Parent element not overwritten in /Users/gwt-user/Desktop/mywebapp/mywebapp-shared/pom.xml
96+
[INFO] Parent element not overwritten in /Users/gwt-user/Desktop/mywebapp/mywebapp-server/pom.xml
97+
[INFO] Project created from Archetype in dir: /Users/gwt-user/Desktop/mywebapp
98+
[INFO] ------------------------------------------------------------------------
99+
[INFO] BUILD SUCCESS
100+
[INFO] ------------------------------------------------------------------------
101+
[INFO] Total time: 01:09 min
102+
[INFO] Finished at: 2023-12-17T17:38:02+01:00
103+
[INFO] ------------------------------------------------------------------------
104+
```
105+
106+
Switch to the generated directory by entering `cd mywebapp`.
107+
108+
Listing of the directory (**Windows**: dir, **Mac and Linux**: ls -la), shows:
109+
110+
```
111+
drwxr-xr-x@ 6 gwt-user staff 192 Dec 17 17:38 .
112+
drwx------@ 50 gwt-user staff 1600 Dec 17 17:38 ..
113+
drwxr-xr-x@ 4 gwt-user staff 128 Dec 17 17:38 mywebapp-client
114+
drwxr-xr-x@ 4 gwt-user staff 128 Dec 17 17:38 mywebapp-server
115+
drwxr-xr-x@ 4 gwt-user staff 128 Dec 17 17:38 mywebapp-shared
116+
-rw-r--r--@ 1 gwt-user staff 7423 Dec 17 17:38 pom.xml
117+
```
118+
119+
## Run locally in super dev mode<a id="run"></a>
120+
121+
To start the code server, run the following command:
122+
123+
```
124+
mvn gwt:codeserver -pl *-client -am
125+
```
126+
127+
and entering the following command in another terminal window to start the server:
128+
129+
```
130+
mvn jetty:run -pl *-server -am -Denv=dev
131+
```
132+
133+
Now, switch to your preferred browser (we suggest using: Chrome, FireFox or Opera) and enter:
134+
135+
```
136+
http://lcoalhost:8080
137+
```
138+
139+
Yet, the application is running in super dev mode. You see something like this in the browser:
140+
141+
<div class="screenshot"><a href="images/mywebapp.png"><img src="images/mywebapp.png" alt="Screenshot" width="42%"/></a></div>
142+
143+
## Make a few changes<a id="change"></a>
144+
145+
Let's change the label of the button. Because this is something on the client side, we need to locate the source code in the client module.
146+
The source code is located in the `mywebapp-client/src/main/java/com/mycompany/mywebapp` subdirectory and the source in the `App.java` class.
147+
148+
Look inside `App.java`. Line 42 constructs the "Send" button.
149+
150+
```
151+
final Button sendButton = new Button("Send");
152+
```
153+
154+
Change the text from "Send" to "Send to Server".
155+
156+
```
157+
final Button sendButton = new Button("Send to Server");
158+
```
159+
160+
Save the file and simply click "Refresh" in your browser to see your change. The button should now say "Send to Server" instead of "Send":
161+
162+
## Debugging the browser<a id="debug"></a>
163+
164+
In super dev mode, you can easily debug your client code in the browser. While running your application, open the dev tools
165+
in your browser. Select the `Sources`-tab and press `ctrl-P` (Windows/Linux) or `cmd-P` (macOS). A popup opens. Enter `App.java` and press return.
166+
167+
<div class="screenshot"><a href="images/sdm-debugger.png"><img src="images/sdm-debugger.png" alt="Screenshot" width="42%"/></a></div>
168+
169+
The source code of the `App.java` class is displayed in the debugger. Add a breakpoint by clicking of Line number 94. Press the send button.
170+
The execution will stop at line 94. The stacktrace is visible, the content of the variable, etc.
171+
172+
<div class="screenshot"><a href="images/sdm-debugger-breakpoint.png"><img src="images/sdm-debugger-breakpoint.png" alt="Screenshot" width="42%"/></a></div>
173+
174+
## Compile and run in production mode<a id="compile"></a>
175+
176+
To run the application as JavaScript in what GWT calls "production mode", create the application by executing:
177+
178+
```
179+
mvn clean package
180+
```
181+
182+
The Maven "package" goal invokes the GWT compiler which generates a number of JavaScript and HTML files from the
183+
MyWebApp Java source code in the `target/` subdirectory. There you will find a `mywebapp-server-HEAD-SNAPSHOT.war`.
184+
You can deploy this war file to every servlet engine and run it. Once running, enter `mywebapp-server-HEAD-SNAPSHOT/index.html`
185+
in your web browser. The application should look identical to the super dev mode above. You can change the name of the war using
186+
Maven 'buildname`.
187+
188+
Congratulations! You've created your first web application using GWT.
189+
Since you've compiled the project, you're now running pure JavaScript and
190+
HTML that works in Edge, Chrome, Firefox, Safari, and Opera. You could now deploy
191+
your application to production by serving the HTML and JavaScript files from your servlet engine.
192+
193+
In case you prefer a Spring Boot server, check the
194+
[gwt-maven-springboot-archetype](https://github.com/NaluKit/gwt-maven-springboot-archetype) plugin. It creates a
195+
project in a similar way, but uses Spring Boot instead of Jetty on the server side.
196+
197+
## Set up an IDE<a id="setup"></a>
198+
199+
Now that you've created your first app, you probably want to do something a
200+
bit more interesting. But first, if you normally work with an IDE you'll want to
201+
set up your IDE to use the GWT SDK:
202+
203+
[Set up Eclipse](usingeclipse.html)
204+
205+
[Set up IntelliJ](usingintellij.html)
206+
207+
Now, with your sample project set up, head over to [Build a Sample GWT App](doc/latest/tutorial/gettingstarted.html).

src/main/markdown/gettingstarted.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Getting Started
22
===
33

4+
Note: Starting with GWT 2.11.0 the webAppCreator is deprecated, please see the [new instructions](gettingstarted-v2.html).
5+
6+
47
* [Prerequisites](#prereqs)
58
* [Download and Install GWT](#download)
69
* [Create your first web application](#create)
@@ -13,11 +16,11 @@ Getting Started
1316

1417
1. You will need the Java SDK version 1.8 or later. If necessary, download and
1518
install the Java SE Development Kit (JDK) <a
16-
href="http://www.oracle.com/technetwork/java/javase/downloads/index.html"
19+
href="https://www.oracle.com/technetwork/java/javase/downloads/index.html"
1720
rel="nofollow">from Oracle</a> or <a href="https://adoptopenjdk.net/"
1821
rel="nofollow">from Adopt OpenJDK</a> for your platform.
1922
2. Apache Ant is also necessary to run command line arguments in this sample. If
20-
you don't already have it, install <a href="http://ant.apache.org/" rel="nofollow">Apache Ant</a>.
23+
you don't already have it, install <a href="https://ant.apache.org/" rel="nofollow">Apache Ant</a>.
2124

2225
If you have problems running Ant on the Mac, try setting the
2326
$JDK_HOME environment variable with export JDK_HOME="/Library/Java/Home"
@@ -55,7 +58,7 @@ run and use the SDK are located in the extracted directory.
5558

5659
## Create your first web application<a id="create"></a>
5760

58-
GWT ships with a command line utility called [webAppCreator](https://www.gwtproject.org/doc/latest/RefCommandLineTools.html#webAppCreator) that automatically generates all the files you'll need in order to start a GWT project. It also generates [Eclipse](http://www.eclipse.org/) project files and launch config files for easy debugging in GWT's development mode.
61+
GWT ships with a command line utility called [webAppCreator](https://www.gwtproject.org/doc/latest/RefCommandLineTools.html#webAppCreator) that automatically generates all the files you'll need in order to start a GWT project. It also generates [Eclipse](https://www.eclipse.org/) project files and launch config files for easy debugging in GWT's development mode.
5962

6063
You can create a new demo application in a new MyWebApp directory by running `webAppCreator`:
6164

@@ -156,4 +159,4 @@ set up Eclipse to use the GWT SDK:
156159
[Set up Eclipse](usingeclipse.html)
157160

158161
If you are going to stick with the command line, check out Speed Tracer and then
159-
head over to [Build a Sample GWT App](doc/latest/tutorial/gettingstarted.html).
162+
head over to [Build a Sample GWT App](doc/latest/tutorial/gettingstarted-v2.html).

src/main/markdown/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ GWT (pronounced 'gwit') is the official open source project for GWT releases 2.7
4545
</tr>
4646
<tr>
4747
<td>
48-
<a href="gettingstarted.html">
48+
<a href="gettingstarted-v2.html">
4949
<img src="images/learnmore.gif" style="float: left; margin-left: 50px; border: 0;" height="48" width="48" />
5050
</a>
5151
<div style="margin-left: 112px; margin-bottom: 10px;">
52-
<div style="font-size: 120%; font-weight: bold;"><a href="gettingstarted.html">Get Started</a></div>
52+
<div style="font-size: 120%; font-weight: bold;"><a href="gettingstarted-v2.html">Get Started</a></div>
5353
<div style="padding-top: 5px; line-height: 125%;">
5454
Walk through the first steps needed to get a web application up and running. From there, work through the fundamentals of GWT development with an in-depth tutorial.<br /><br />
5555
</div>

src/main/markdown/learnmore-sdk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ GWT is free, and all of the [code](https://gwt.googlesource.com/) is available u
111111

112112
## Ready to get started?
113113

114-
<a href="gettingstarted.html">
114+
<a href="gettingstarted-v2.html">
115115
<img src="images/arrow-md.png" style="float: left; margin:10px 10px 0px 0px; border-style:none; width: 80px; height: 80px" />
116116
</a>
117117

118-
[Download the SDK](gettingstarted.html) and get a simple web application up and running.
118+
[Download the SDK](gettingstarted-v2.html) and get a simple web application up and running.

src/main/markdown/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GWT is a development toolkit for building and optimizing complex browser-based a
1111

1212
The [GWT SDK](learnmore-sdk.html) contains the Java API libraries, compiler, and development server. It lets you write client-side applications in Java and deploy them as JavaScript.
1313

14-
* [Get Started](gettingstarted.html)
14+
* [Get Started](gettingstarted-v2.html)
1515
* [Tutorials](doc/latest/tutorial/index.html)
1616
* [Developer Guide](doc/latest/DevGuide.html)
1717

@@ -49,4 +49,4 @@ When you're ready to deploy, GWT compiles your Java source code into optimized,
4949

5050
## Ready to get started?
5151

52-
[Download the SDK](gettingstarted.html) and get a simple web application up and running. From there, work through the fundamentals of GWT development with the in-depth [tutorials](doc/latest/tutorial/index.html).
52+
[Download the SDK](gettingstarted-v2.html) and get a simple web application up and running. From there, work through the fundamentals of GWT development with the in-depth [tutorials](doc/latest/tutorial/index.html).

src/main/markdown/usingintellij.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Using IntelliJ
2+
===
3+
4+
GWT provides a set of tools that can simply be used with a
5+
text editor, the command line, and a browser. However, you may also use GWT with your
6+
favorite IDE. The Idea IntelliJ Ultimate Edition provides a GWT plugin, but the free Idea IntelliJ Community Edition
7+
is all you need. IntelliJ provides awesome Maven support, enabling the IDE to read the project classpath, and easily create run configurations for compiling and running a GWT project.
8+
9+
* [Download IntelliJ](#intellij)
10+
* [Import a Web Application](#importing)
11+
* [Run locally in Super Dev Mode](#running)
12+
13+
## Download IntelliJ<a id="intellij"></a>
14+
15+
If you do not already have IntelliJ, you may download it from the [IntelliJ Website](https://www.jetbrains.com/idea/download/).
16+
17+
## Import a Web Application<a id="importing"></a>
18+
19+
To import a Web Application - create with an archetype creator, select **File > New > Project from existing source**
20+
from the File menu. Select the root directory of the project you want to import and press `enter`.
21+
22+
A dialog opens:
23+
24+
<div class="screenshot"><a href="images/import-into-intellij.png"><img src="images/import-into-intellij.png" alt="Screenshot" width="42%"/></a></div>
25+
26+
Press `Create`. The import process starts and after a few seconds, the project window appears:
27+
28+
<div class="screenshot"><a href="images/intellij-project.png"><img src="images/intellij-project.png" alt="Screenshot" width="42%"/></a></div>
29+
30+
## Run locally in Super Dev Mode<a id="running"></a>
31+
32+
To improve the development experience, you can set up two run configurations, one for the code server and another for the server.
33+
34+
### Code Server Run Configuration
35+
36+
Press `Edit configuration`, a popup appears. Now press `+` and select `Maven`.
37+
38+
Enter `gwt:codeserver -pl mywebapp-client -am` in the field under `Run`:
39+
40+
<div class="screenshot"><a href="images/intellij-run-code-server.png"><img src="images/intellij-run-code-server.png" alt="Screenshot" width="42%"/></a></div>
41+
42+
Now you have a run configuration, that starts the code server.
43+
44+
Note: When running the code server from the command line, you need to run `gwt:codeserver -pl *-client -am`.
45+
This will not work inside a running configuration. Here you have to use the module name instead of '*'. Inside a run
46+
configuration, the command line looks like that: `gwt:codeserver -pl mywebapp-client -am`.
47+
48+
### Server Run Configuration
49+
50+
Press `Edit configuration`, a popup appears. Now press `+` and select `Maven`.
51+
52+
Enter `mvn jetty:run -pl *-server -am -Denv=dev` in the field under run:
53+
54+
<div class="screenshot"><a href="images/intellij-run-server.png"><img src="images/intellij-run-server.png" alt="Screenshot" width="42%"/></a></div>
55+
56+
Now, you have a run configuration, that starts the server.
57+
58+
Note: you have to use the module name instead of '*'.

src/main/resources/main.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<ul>
4141
<li class="logo"><a href="/">GWT homepage</a></li>
4242
<li><a href="overview.html"><i class="icon_overview"></i>Overview</a></li>
43-
<li class="sep"><a href="gettingstarted.html"><i class="icon_getstarted"></i>Get started</a></li>
43+
<li class="sep"><a href="gettingstarted-v2.html"><i class="icon_getstarted"></i>Get started</a></li>
4444
<li><a href="doc/latest/tutorial/index.html" class="active"><i class="icon_tutorials"></i>Tutorials</a></li>
4545
<li><a href="doc/latest/DevGuide.html"><i class="icon_doc"></i>Docs</a></li>
4646
<li><a href="examples.html"><i class="icon_ressources"></i>Resources</a></li>

src/main/resources/toc.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
- [Get Started](gettingstarted.html)
2-
- [Overview](gettingstarted.html 'Getting Started with GWT SDK')
1+
- [Get Started](gettingstarted-v2.html)
2+
- [Overview](gettingstarted-v2.html 'Getting Started with GWT SDK')
33
- [SDK Learn More](learnmore-sdk.html 'Learn more about the GWT SDK')
44
- [Configure Eclipse](usingeclipse.html)
5+
- [Configure IntelliJ](usingintellij.html)
56
- [Tutorials](doc/latest/tutorial/index.html)
67
- [Overview](doc/latest/tutorial/index.html)
78
- [Build a GWT App.](# 'Create, build and run a GWT application')

0 commit comments

Comments
 (0)