@@ -16,6 +16,7 @@ WebforJ typically packages the app as a WAR file and runs using Jetty. Enable th
1616plugins {
1717 id 'java'
1818 id 'war'
19+ id 'org.gretty'
1920}
2021```
2122
@@ -83,28 +84,18 @@ tasks.register('copyWebforjConfig', Copy) {
8384processResources.dependsOn copyWebforjConfig
8485```
8586
86- ## 7. Jetty server integration
87+ ## 7. Gretty integration
8788
88- If you're using Jetty for local development like in the Maven Jetty plugin setup :
89+ Configure your gretty setup, its going to handle the jetty deployment :
8990
9091``` groovy
91- tasks.register('startJetty', JavaExec) {
92- mainClass = 'org.eclipse.jetty.start.Main'
93- args = ['jetty:run']
94- classpath = sourceSets.main.runtimeClasspath
95- }
96-
97- tasks.register('stopJetty', JavaExec) {
98- mainClass = 'org.eclipse.jetty.start.Main'
99- args = ['jetty:stop']
100- classpath = sourceSets.main.runtimeClasspath
92+ gretty {
93+ httpPort = 8080
94+ contextPath = '/'
95+ servletContainer = 'jetty11'
10196}
10297```
10398
104- ::: tip
105- Replace ` org.eclipse.jetty.start.Main ` with your embedded Jetty class if applicable.
106- :::
107-
10899## 8. Testing
109100
110101To enable JUnit 5 (Jupiter), include:
@@ -133,6 +124,69 @@ test {
133124- Open the folder, and VS Code will detect the Gradle project.
134125- Use the Gradle Tasks tab or command palette to build or run tasks.
135126
127+
128+ ## 10. Running the app
129+
130+ Since you are using gretty you will need to build a gradle wrapper first. For this purpose run ` gradle wrapper ` .
131+ Now you can use ` ./gradlew appRun ` and the task will utilize the jetty deployment automatically.
132+
133+ The completed ` build.gradle ` should look similar to this:
134+
135+ ``` groovy
136+ plugins {
137+ id 'java'
138+ id 'war'
139+ id 'org.gretty' version '4.1.1'
140+ }
141+
142+ group = 'com.gradletest'
143+ version = '1.0-SNAPSHOT'
144+
145+ java {
146+ toolchain {
147+ languageVersion.set(JavaLanguageVersion.of(21))
148+ }
149+ }
150+
151+ gretty {
152+ httpPort = 8080
153+ contextPath = '/'
154+ servletContainer = 'jetty11'
155+ }
156+
157+ def webforjVersion = '25.00'
158+
159+ repositories {
160+ mavenCentral()
161+ maven {
162+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots'
163+ mavenContent { snapshotsOnly() }
164+ }
165+ }
166+
167+ dependencies {
168+ implementation "com.webforj:webforj:$webforjVersion"
169+ implementation 'org.slf4j:slf4j-simple:2.0.16'
170+
171+ testImplementation 'com.microsoft.playwright:playwright:1.49.0'
172+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
173+ }
174+
175+ test {
176+ useJUnitPlatform()
177+ }
178+
179+ def configFile = project.hasProperty('prod') ? 'webforj-prod.conf' : 'webforj-dev.conf'
180+
181+ tasks.register('copyWebforjConfig', Copy) {
182+ from "src/main/resources/${configFile}"
183+ into "$buildDir/resources/main"
184+ rename { 'webforj.conf' }
185+ }
186+
187+ processResources.dependsOn 'copyWebforjConfig'
188+
189+ ```
136190---
137191
138192
0 commit comments