Skip to content

Commit af2f4cc

Browse files
authored
Rewrite SDK samples using Maven (#10247)
Restructured samples to build with Maven and be designed around splitting server/client where appropriate. Includes some package changes to better differentiate when a class is shared, client-only, or server-only. RequestFactory log requests with jakarta seem hard to use, but easy to copy into the sample project as an example of how to get around this issue. All samples are rebuilt to use jakarta.servlet, except mobilewebapp, which uses too old of an AppEngine version to update. All samples require Java 17+ except mobilewebapp, which doesn't work with any Java version other than 11 at this time. Fixes #10232
1 parent 2a8b571 commit af2f4cc

485 files changed

Lines changed: 3299 additions & 1181 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
/build/
77
# Generated poms
88
/maven/poms/**/pom.xml
9+
10+
# Maven build directories for samples
11+
samples/**/target/

common.ant.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@
144144
</ant>
145145
</presetdef>
146146

147+
<macrodef name="gwt.mvn">
148+
<attribute name="args" default="${mvn.args}" />
149+
<attribute name="dir" />
150+
<sequential>
151+
<echo message="Running 'mvn @{args}' in @{dir}"/>
152+
<exec dir="${basedir}" executable="mvn" failonerror="true">
153+
<arg line="@{args} --file @{dir}" />
154+
</exec>
155+
</sequential>
156+
</macrodef>
157+
147158
<macrodef name="gwt.javac">
148159
<attribute name="srcdir" default="src" />
149160
<attribute name="destdir" default="${javac.out}" />

dev/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
<pathelement location="${gwt.root}/user/src/"/>
326326
<pathelement location="${gwt.root}/user/super/"/>
327327
<!-- CompilerTest compiles the hello sample. -->
328-
<pathelement location="${gwt.root}/samples/hello/src/"/>
328+
<pathelement location="${gwt.root}/samples/hello/src/main/java"/>
329329
<!-- CompilerTest needs the dependecies to compile a project that uses UiBinder. -->
330330
<pathelement location="${gwt.tools.lib}/streamhtmlparser/streamhtmlparser-jsilver-r10/streamhtmlparser-jsilver-r10-1.5-rebased.jar"/>
331331
<pathelement location="${gwt.tools.lib}/gss/2015-11-04/closure-stylesheets-library-20151104-rebased.jar"/>

distro-source/build.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<target name="build" depends="filter, merge_codeserver" description="Packages the distro">
2727
<!-- TODO: figure out how to share most of this across platforms -->
2828
<mkdir dir="${gwt.build.dist}" />
29-
<mkdir dir="${gwt.build.out}/samples-scripts"/>
3029
<zip destfile="${project.dist}">
3130
<!-- jars -->
3231
<zipfileset file="${gwt.build.lib}/gwt-dev.jar" prefix="${project.distname}" />
@@ -56,14 +55,10 @@
5655
<zipfileset dir="${gwt.build.out}" prefix="${project.distname}">
5756
<include name="samples" />
5857
<include name="samples/*" />
59-
<include name="samples/*/build.xml" />
60-
<include name="samples/*/pom.xml" />
61-
<include name="samples/*/README-MAVEN.txt" />
62-
<include name="samples/*/src/**" />
63-
<include name="samples/*/war/**" />
64-
</zipfileset>
65-
<zipfileset dir="${gwt.build.out}/samples-scripts" prefix="${project.distname}/samples">
66-
<include name="*/*" />
58+
<include name="samples/**/pom.xml" />
59+
<include name="samples/*/README.md" />
60+
<include name="samples/*/COPYING" />
61+
<include name="samples/**/src/**" />
6762
</zipfileset>
6863
</zip>
6964

distro-source/core/src/samples/build.xml

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

samples/build.xml

Lines changed: 82 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
<project name="samples" default="build" basedir=".">
1+
<project name="samples" default="build" basedir="." xmlns:unless="ant:unless">
22
<property name="gwt.root" location=".." />
33
<property name="project.tail" value="samples" />
44
<import file="${gwt.root}/common.ant.xml" />
55

6-
<!-- "build" is the default when subprojects are directly targetted -->
7-
<property name="target" value="build" />
6+
<condition property="isJava11">
7+
<matches string="${java.version}" pattern="^11.*" />
8+
</condition>
89

9-
<target name="dynatable" description="Build dynatable">
10-
<gwt.ant dir="dynatable" />
10+
<!-- "verify" is the default maven command when subprojects are directly targeted -->
11+
<property name="mvn.args" value="verify" />
12+
13+
<target name="dynatable" description="Build dynatable" unless="isJava11">
14+
<gwt.mvn dir="dynatable" />
1115
</target>
1216

13-
<target name="dynatablerf" description="Build dynatablerf">
14-
<gwt.ant dir="dynatablerf" />
17+
<target name="dynatablerf" description="Build dynatablerf" unless="isJava11">
18+
<gwt.mvn dir="dynatablerf" />
1519
</target>
1620

1721
<target name="hello" description="Build hello">
18-
<gwt.ant dir="hello" />
22+
<gwt.mvn dir="hello" />
1923
</target>
2024

21-
<target name="json" description="Build json">
22-
<gwt.ant dir="json" />
25+
<target name="json" description="Build json" unless="isJava11">
26+
<gwt.mvn dir="json" />
2327
</target>
2428

25-
<target name="mail" description="Build mail">
26-
<gwt.ant dir="mail" />
29+
<target name="mail" description="Build mail" unless="isJava11">
30+
<gwt.mvn dir="mail" />
2731
</target>
2832

2933
<target name="mobilewebapp" description="Build mobile web app">
30-
<gwt.ant dir="mobilewebapp" />
31-
</target>
32-
33-
<target name="showcase" description="Build showcase">
34-
<gwt.ant dir="showcase" />
34+
<gwt.mvn dir="mobilewebapp" />
3535
</target>
3636

37-
<target name="validation" description="Build validation">
38-
<gwt.ant dir="validation" />
37+
<target name="showcase" description="Build showcase" unless="isJava11">
38+
<gwt.mvn dir="showcase" />
3939
</target>
4040

41-
<target name="validationtck" description="Build validation TCK">
42-
<gwt.ant dir="validationtck" />
41+
<target name="validation" description="Build validation" unless="isJava11">
42+
<gwt.mvn dir="validation" />
4343
</target>
4444

45-
<target name="-do" description="Run all subprojects" >
45+
<target name="-do" description="Run all subprojects">
4646
<antcall target="dynatable" />
4747
<antcall target="dynatablerf" />
4848
<antcall target="hello" />
@@ -51,39 +51,86 @@
5151
<antcall target="mobilewebapp" />
5252
<antcall target="showcase" />
5353
<antcall target="validation" />
54-
<!-- don't include validationtck, it is not really a sample -->
5554
</target>
5655

57-
<target name="build" description="Builds GWT">
56+
<target name="build" depends="source, gwtc, test" description="Build and package this project" />
57+
58+
<target name="gwtc" description="Builds GWT">
5859
<antcall target="-do">
59-
<param name="target" value="build" />
60+
<param name="mvn.args" value="verify" />
6061
</antcall>
6162
<length property="gwt.sample.length">
62-
<fileset dir="${gwt.build.out}/samples" includes="*/war/*/*.cache.html,*/war/*/*.cache.js"/>
63+
<fileset dir="." includes="*/target/*/*/*.cache.js"/>
6364
</length>
6465
<echo message="compiled size of all samples is ${gwt.sample.length} bytes." level="info"/>
6566
</target>
6667

6768
<target name="checkstyle" description="Static analysis of GWT source">
68-
<antcall target="-do">
69-
<param name="target" value="checkstyle" />
70-
</antcall>
69+
<gwt.checkstyle outputdirectory="${project.build}/dynatable/">
70+
<fileset dir="dynatable/">
71+
<include name="*/src/**/*.java" />
72+
</fileset>
73+
</gwt.checkstyle>
74+
<gwt.checkstyle outputdirectory="${project.build}/dynatablerf/">
75+
<fileset dir="dynatablerf/">
76+
<include name="*/src/**/*.java" />
77+
</fileset>
78+
</gwt.checkstyle>
79+
<gwt.checkstyle outputdirectory="${project.build}/hello/">
80+
<fileset dir="hello/">
81+
<include name="src/**/*.java" />
82+
</fileset>
83+
</gwt.checkstyle>
84+
<gwt.checkstyle outputdirectory="${project.build}/json/">
85+
<fileset dir="json/">
86+
<include name="*/src/**/*.java" />
87+
</fileset>
88+
</gwt.checkstyle>
89+
<gwt.checkstyle outputdirectory="${project.build}/mail/">
90+
<fileset dir="mail/">
91+
<include name="*/src/**/*.java" />
92+
</fileset>
93+
</gwt.checkstyle>
94+
<gwt.checkstyle outputdirectory="${project.build}/mobilewebapp/">
95+
<fileset dir="mobilewebapp/">
96+
<include name="*/src/**/*.java" />
97+
</fileset>
98+
</gwt.checkstyle>
99+
<gwt.checkstyle outputdirectory="${project.build}/showcase/">
100+
<fileset dir="showcase/">
101+
<include name="*/src/**/*.java" />
102+
</fileset>
103+
</gwt.checkstyle>
104+
<gwt.checkstyle outputdirectory="${project.build}/validation/">
105+
<fileset dir="validation/">
106+
<include name="*/src/**/*.java" />
107+
<!-- ValidationMessages is generated and has funny method names -->
108+
<exclude name="**/ValidationMessages.java" />
109+
</fileset>
110+
</gwt.checkstyle>
71111
</target>
72112

73113
<target name="source" description="Copy source to the output folder">
74-
<antcall target="-do">
75-
<param name="target" value="source" />
76-
</antcall>
114+
<copy todir="${project.build}">
115+
<fileset dir=".">
116+
<include name="**/src/**" />
117+
<include name="**/pom.xml" />
118+
<include name="*/README.md" />
119+
<include name="*/COPYING" />
120+
</fileset>
121+
</copy>
77122
</target>
78123

79-
<target name="test" description="Test GWT">
124+
<target name="test" description="Test GWT samples">
80125
<antcall target="-do">
81-
<param name="target" value="test" />
126+
<param name="mvn.args" value="test" />
82127
</antcall>
83128
</target>
84129

85130
<target name="clean" description="Cleans this project's intermediate and output files">
86131
<delete dir="${project.build}" />
87-
<delete dir="${gwt.build.out}/samples-scripts" />
132+
<antcall target="-do">
133+
<param name="mvn.args" value="clean" />
134+
</antcall>
88135
</target>
89136
</project>

0 commit comments

Comments
 (0)