├── .gitignore
├── .travis.yml
├── CODE_OF_CONDUCT.md
├── LICENSE
├── Procfile
├── README.md
├── app.json
├── build.gradle
├── docs
├── IDEA_SETTINGS.md
├── architecture.jpg
├── gwt-project-structure-gwt.jpg
├── gwt-project-structure-web.jpg
├── gwt-run-config.jpg
└── spring-run-config.jpg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
├── main
├── java
│ └── com
│ │ └── codecrafters
│ │ ├── SpringBootGwt.gwt.xml
│ │ ├── client
│ │ ├── SpringBootGwt.java
│ │ ├── TodoItem.java
│ │ ├── TodoItemLabel.java
│ │ ├── TodoItemLabel.ui.xml
│ │ ├── TodoItemService.java
│ │ ├── TodoPanel.java
│ │ └── TodoPanel.ui.xml
│ │ └── server
│ │ ├── ScheduledDatabaseResetTask.java
│ │ ├── SpringBootGwtApplication.java
│ │ ├── SpringBootGwtProperties.java
│ │ ├── TodoItem.java
│ │ ├── TodoItemRepository.java
│ │ └── TodoItemRestController.java
└── resources
│ ├── META-INF
│ └── additional-spring-configuration-metadata.json
│ ├── application-test.properties
│ ├── application.properties
│ └── static
│ └── index.html
└── test
└── groovy
└── com
└── codecrafters
└── server
├── ScheduledDatabaseResetTaskTest.groovy
├── TodoItemRepositoryIntegrationTest.groovy
└── TodoItemRestControllerIntegrationTest.groovy
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Eclipse template
2 | *.pydevproject
3 | .metadata
4 | .gradle
5 | bin/
6 | tmp/
7 | *.tmp
8 | *.bak
9 | *.swp
10 | *~.nib
11 | local.properties
12 | .settings/
13 | .loadpath
14 |
15 | # Eclipse Core
16 | .project
17 |
18 | # External tool builders
19 | .externalToolBuilders/
20 |
21 | # Locally stored "Eclipse launch configurations"
22 | *.launch
23 |
24 | # CDT-specific
25 | .cproject
26 |
27 | # JDT-specific (Eclipse Java Development Tools)
28 | .classpath
29 |
30 | # Java annotation processor (APT)
31 | .factorypath
32 |
33 | # PDT-specific
34 | .buildpath
35 |
36 | # sbteclipse plugin
37 | .target
38 |
39 | # TeXlipse plugin
40 | .texlipse
41 |
42 | ### Java template
43 | *.class
44 |
45 | # Mobile Tools for Java (J2ME)
46 | .mtj.tmp/
47 |
48 | # Package Files #
49 | *.jar
50 | *.war
51 | *.ear
52 |
53 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
54 | hs_err_pid*
55 |
56 | ### GWT template
57 | # gwt caches and compiled units #
58 | war/gwt_bree/
59 | gwt-unitCache/
60 |
61 | # boilerplate generated classes #
62 | .apt_generated/
63 |
64 | # more caches and things from deploy #
65 | war/WEB-INF/deploy/
66 | war/WEB-INF/classes/
67 |
68 | #compilation logs
69 | .gwt/
70 |
71 |
72 | #gwt junit compilation files
73 | www-test/
74 |
75 | #old GWT (1.5) created this dir
76 | .gwt-tmp/
77 |
78 | ### Gradle template
79 | build/
80 |
81 | # Ignore Gradle GUI config
82 | gradle-app.setting
83 |
84 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
85 |
86 | ### JetBrains template
87 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
88 |
89 | *.iml
90 |
91 | ## Directory-based project format:
92 | .idea/*
93 | # if you remove the above rule, at least ignore the following:
94 |
95 | # User-specific stuff:
96 | # .idea/workspace.xml
97 | # .idea/tasks.xml
98 | # .idea/dictionaries
99 |
100 | # Sensitive or high-churn files:
101 | # .idea/dataSources.ids
102 | # .idea/dataSources.xml
103 | # .idea/sqlDataSources.xml
104 | # .idea/dynamic.xml
105 | # .idea/uiDesigner.xml
106 |
107 | # Gradle:
108 | # .idea/gradle.xml
109 | # .idea/libraries
110 |
111 | # Mongo Explorer plugin:
112 | # .idea/mongoSettings.xml
113 |
114 | ## File-based project format:
115 | *.ipr
116 | *.iws
117 |
118 | ## Plugin-specific files:
119 |
120 | # IntelliJ
121 | /out/
122 |
123 | # mpeltonen/sbt-idea plugin
124 | .idea_modules/
125 |
126 | # JIRA plugin
127 | atlassian-ide-plugin.xml
128 |
129 | # Crashlytics plugin (for Android Studio and IntelliJ)
130 | com_crashlytics_export_strings.xml
131 | crashlytics.properties
132 | crashlytics-build.properties
133 |
134 | ### Custom
135 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
136 | !gradle-wrapper.jar
137 |
138 | # Add run configurations for intellij
139 | !.idea/runConfigurations/
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team (via Github Issues). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018 Fabian Dietenberger
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: java -Dserver.port=$PORT $JAVA_OPTS -Xms64m -Xmx384m -Xss512k -XX:+UseConcMarkSweepGC -jar build/libs/*.jar
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Spring Boot GWT
2 |
3 | [](https://travis-ci.org/feedm3/spring-boot-gwt)
4 | [](http://badges.mit-license.org)
5 |
6 | [](https://heroku.com/deploy?template=https://github.com/feedm3/spring-boot-gwt/blob/master)
7 |
8 | This is a demo project to show Spring Boot in conjunction with GWT. It uses the latest dependencies
9 | (Spring Boot 2.0.1 and GWT 2.8.2) and Java 8. The deployed app can be found [here](https://spring-boot-gwt.herokuapp.com/).
10 |
11 | ## Run
12 |
13 | To run this project you have to start Spring Boot and GWT separate. If you use IntelliJ, see the
14 | [IDEA Settings readme](docs/IDEA_SETTINGS.md) for the correct configuration.
15 |
16 | Spring Boot can also be started with gradle.
17 |
18 | ```
19 | gradlew bootRun
20 | ```
21 |
22 | ## Test
23 |
24 | Currently only the server side code is tested. To run the tests use the following command
25 |
26 | ```
27 | gradlew test
28 | ```
29 |
30 | We use [Spock](https://github.com/spockframework/spock) as testing framework because of the great
31 | readability, syntax and built in features.
32 |
33 | #### Outdated dependencies
34 |
35 | To check for outdated dependencies
36 | ```
37 | gradlew dependencyUpdates -Drevision=release
38 | ```
39 |
40 | ## Build
41 |
42 | The project con be build to a single jar file with an embedded tomcat:
43 |
44 | ```
45 | gradlew clean build
46 | ```
47 |
48 | After gradle build the project the finished jar file is in `build/libs/spring-boot-gwt-1.0.0.jar`
49 | and can simply be started with
50 |
51 | ```
52 | java -jar build/libs/spring-boot-gwt-1.0.0.jar
53 | ```
54 |
55 | ### Heroku
56 |
57 | To deploy this app to heroku use the __Deploy to Heroku__ Button on the top.
58 |
59 | Heroku uses the gradle `stage` task to build the project. Because Spring Boot puts everything we
60 | need into the jar file we only have to tell heroku to execute this jar file.
61 |
62 | ## Technical Details
63 |
64 | 
65 |
66 | The client side and server side are strictly separated. The GWT files are in the `client` package
67 | (except the `.gwt.xml`) and the server side code is in the `server` package. All static client code
68 | like the `index.html` and css files are inside the [`static`](src/main/resources/static) folder. Gradle
69 | will also put the compiled sources in this folder.
70 |
71 | The communication is made via JSON for which reason we have make 2 implementations of the object we
72 | send (POJO in the frontend and POJO with javax annotations in the backend).
73 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Spring Boot with GWT demo app",
3 | "description": "A barebone Spring Boot app using GWT as frontend",
4 | "repository": "https://github.com/feedm3/spring-boot-gwt",
5 | "keywords": [
6 | "spring boot",
7 | "spring",
8 | "gwt"
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 | dependencies {
6 | classpath 'org.wisepersist:gwt-gradle-plugin:1.0.6'
7 | }
8 | }
9 |
10 | plugins {
11 | id 'java'
12 | id 'eclipse'
13 | id 'groovy'
14 | id 'idea'
15 | id 'org.springframework.boot' version '2.0.1.RELEASE'
16 | id 'com.github.ben-manes.versions' version '0.17.0'
17 | }
18 |
19 | apply plugin: 'gwt'
20 | apply plugin: 'io.spring.dependency-management'
21 |
22 | sourceCompatibility = 1.8
23 | targetCompatibility = 1.8
24 | def GWT_VERSION = '2.8.2'
25 | ext['spock.version'] = '1.1'
26 |
27 | repositories {
28 | jcenter()
29 | }
30 |
31 | sourceSets {
32 | main.java.srcDir "src/main/java"
33 | main.resources.srcDir "src/main/resources"
34 | test.java.srcDir "src/test/java"
35 | test.groovy.srcDir "src/test/groovy"
36 | test.resources.srcDir "src/test/resources"
37 | }
38 |
39 | dependencies {
40 | // although the gwt plugin should already download the gwt dependencies, we have to add
41 | // them manually as some jetty dependencies are missing otherwise
42 | compileOnly("com.google.gwt:gwt-user:${GWT_VERSION}")
43 | compileOnly("com.google.gwt:gwt-dev:${GWT_VERSION}")
44 | compileOnly('org.fusesource.restygwt:restygwt:2.2.3')
45 |
46 | compile('javax.ws.rs:javax.ws.rs-api:2.1')
47 | compile('org.springframework.boot:spring-boot-starter-data-jpa')
48 | compile('org.springframework.boot:spring-boot-starter-jetty')
49 | compile('org.springframework.boot:spring-boot-starter-web') {
50 | exclude module: 'spring-boot-starter-tomcat'
51 | }
52 |
53 | runtime('com.h2database:h2')
54 |
55 | testCompile('org.springframework.boot:spring-boot-starter-test')
56 | testCompile('org.codehaus.groovy:groovy-all:2.4.15')
57 | testCompile('org.spockframework:spock-core:1.1-groovy-2.4')
58 | testCompile('org.spockframework:spock-spring:1.1-groovy-2.4')
59 |
60 | annotationProcessor('org.springframework.boot:spring-boot-configuration-processor')
61 | }
62 |
63 | task wrapper(type: Wrapper) {
64 | gradleVersion = '4.6'
65 | }
66 |
67 | gwt {
68 | gwtVersion = GWT_VERSION
69 | modules 'com.codecrafters.SpringBootGwt'
70 | maxHeapSize = "1024M"
71 | }
72 |
73 | compileJava.dependsOn(processResources)
74 |
75 | bootJar.dependsOn compileGwt
76 | bootJar {
77 | baseName = 'spring-boot-gwt'
78 | version = '1.0.0'
79 |
80 | into('BOOT-INF/classes/static') {
81 | from compileGwt.outputs
82 | }
83 | }
84 |
85 | eclipse {
86 | classpath {
87 | containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
88 | containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/docs/IDEA_SETTINGS.md:
--------------------------------------------------------------------------------
1 | # IDEA Settings
2 |
3 | To run both the frontend and backend in IntelliJ, make sure the following settings are set:
4 |
5 | #### Project Structure...
6 |
7 | 
8 | 
9 |
10 | #### Run configs
11 |
12 | 
13 | 
--------------------------------------------------------------------------------
/docs/architecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feedm3/spring-boot-gwt/449a953a5e2a9fde1799eddef2b14bd65334d6a4/docs/architecture.jpg
--------------------------------------------------------------------------------
/docs/gwt-project-structure-gwt.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feedm3/spring-boot-gwt/449a953a5e2a9fde1799eddef2b14bd65334d6a4/docs/gwt-project-structure-gwt.jpg
--------------------------------------------------------------------------------
/docs/gwt-project-structure-web.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feedm3/spring-boot-gwt/449a953a5e2a9fde1799eddef2b14bd65334d6a4/docs/gwt-project-structure-web.jpg
--------------------------------------------------------------------------------
/docs/gwt-run-config.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feedm3/spring-boot-gwt/449a953a5e2a9fde1799eddef2b14bd65334d6a4/docs/gwt-run-config.jpg
--------------------------------------------------------------------------------
/docs/spring-run-config.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feedm3/spring-boot-gwt/449a953a5e2a9fde1799eddef2b14bd65334d6a4/docs/spring-run-config.jpg
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feedm3/spring-boot-gwt/449a953a5e2a9fde1799eddef2b14bd65334d6a4/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/src/main/java/com/codecrafters/SpringBootGwt.gwt.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/main/java/com/codecrafters/client/SpringBootGwt.java:
--------------------------------------------------------------------------------
1 | package com.codecrafters.client;
2 |
3 | import com.google.gwt.core.client.EntryPoint;
4 | import com.google.gwt.core.client.GWT;
5 | import com.google.gwt.user.client.ui.RootPanel;
6 | import org.fusesource.restygwt.client.Defaults;
7 |
8 | /**
9 | * This class is used as entry point for our GWT application. It configures the app and adds the UI.
10 | *
11 | * @author Fabian Dietenberger
12 | */
13 | public class SpringBootGwt implements EntryPoint {
14 |
15 | public void onModuleLoad() {
16 | useCorrectRequestBaseUrl();
17 | RootPanel.get().add(new TodoPanel());
18 | }
19 |
20 | private void useCorrectRequestBaseUrl() {
21 | if (isDevelopmentMode()) {
22 | // our spring boot server is running at port 80. If we don't change the url
23 | // resty gwt would use the gwt servlet port
24 | Defaults.setServiceRoot("http://localhost:8080");
25 | } else {
26 | // in production our compiled javascript code gets copied into
27 | // a 'springbootgwt' folder into the static resources. So if we
28 | // dont change the default url resty gwt would put the folders name
29 | // to the base url
30 | Defaults.setServiceRoot(GWT.getHostPageBaseURL());
31 | }
32 | }
33 |
34 | /**
35 | * Detect if the app is in development mode.
36 | *
37 | * @return true if in development mode
38 | */
39 | private static native boolean isDevelopmentMode()/*-{
40 | return typeof $wnd.__gwt_sdm !== 'undefined';
41 | }-*/;
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/codecrafters/client/TodoItem.java:
--------------------------------------------------------------------------------
1 | package com.codecrafters.client;
2 |
3 | /**
4 | * This class is used to represent a todoItem.
5 | *
6 | * @author Fabian Dietenberger
7 | */
8 | class TodoItem {
9 |
10 | private long id;
11 | private String text;
12 |
13 | public TodoItem() {
14 | }
15 |
16 | public TodoItem(final String text) {
17 | this.text = text;
18 | }
19 |
20 | public long getId() {
21 | return id;
22 | }
23 |
24 | public void setId(final long id) {
25 | this.id = id;
26 | }
27 |
28 | public String getText() {
29 | return text;
30 | }
31 |
32 | public void setText(final String text) {
33 | this.text = text;
34 | }
35 |
36 | @Override
37 | public String toString() {
38 | return "TodoItem{" +
39 | "id=" + id +
40 | ", text='" + text + '\'' +
41 | '}';
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/codecrafters/client/TodoItemLabel.java:
--------------------------------------------------------------------------------
1 | package com.codecrafters.client;
2 |
3 | import com.google.gwt.core.client.GWT;
4 | import com.google.gwt.event.dom.client.ClickEvent;
5 | import com.google.gwt.uibinder.client.UiBinder;
6 | import com.google.gwt.uibinder.client.UiField;
7 | import com.google.gwt.user.client.ui.Composite;
8 | import com.google.gwt.user.client.ui.Label;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * This class is used to represent a {@link TodoItem} in a panel.
15 | *
16 | * @author Fabian Dietenberger
17 | */
18 | class TodoItemLabel extends Composite {
19 |
20 | interface TodoItemLabelUiBinder extends UiBinder