Skip to content

Commit 83d16ab

Browse files
committed
add tooling functionality, unfinished
- further implement gwt ui - starts separating swing from web basics - implements tooling - a lot of wrongs still there - especially object drawing still has a bug were preview lines are not deleted
1 parent 3d99a5d commit 83d16ab

44 files changed

Lines changed: 10823 additions & 99 deletions

Some content is hidden

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

build.gradle

Lines changed: 112 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ apply plugin: 'io.github.fvarrui.javapackager.plugin'
3535
group = 'io.github.kovzol'
3636
ext.softwareVersion = '0.86'
3737

38+
sourceSets {
39+
main {
40+
java {
41+
srcDirs = ['src/main/java', 'src/main/gwt']
42+
}
43+
resources {
44+
srcDirs = ['src/main/resources']
45+
}
46+
}
47+
test {
48+
java {
49+
srcDirs = ['src/test/java']
50+
}
51+
resources {
52+
srcDirs = ['src/test/resources']
53+
}
54+
}
55+
}
56+
3857
// These are default settings based on Gradle's standard layout:
3958
ext.poDir = 'src/main/po'
4059
ext.classesDir = 'build/classes/java/main'
@@ -51,13 +70,22 @@ tasks.addRule("Pattern: msgFmt_<FILE>Po: Compile <FILE>.po into <FILE>.class.")
5170
outputs.file output
5271
doLast {
5372
def msgFmtCmd = "msgfmt --java2 -d ${classesDir} -r i18n.Messages -l ${language} ${input}"
54-
exec {
55-
ignoreExitValue true
56-
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
57-
commandLine 'cmd', '/c', msgFmtCmd
58-
} else {
59-
commandLine 'bash', '-c', msgFmtCmd
73+
try {
74+
exec {
75+
ignoreExitValue true
76+
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
77+
commandLine 'cmd', '/c', msgFmtCmd
78+
} else {
79+
commandLine 'bash', '-c', msgFmtCmd
80+
}
6081
}
82+
} catch (Exception e) {
83+
// If msgfmt is not available, log a warning but don't fail the build
84+
logger.warn("Warning: msgfmt command not found. Internationalization will not be available.")
85+
logger.warn("Install gettext to enable internationalization support.")
86+
// Create an empty directory to satisfy the output requirement
87+
def outputDir = new File("${classesDir}/i18n")
88+
outputDir.mkdirs()
6189
}
6290
}
6391
}
@@ -158,9 +186,13 @@ dependencies {
158186
'commons-cli:commons-cli:1.4'
159187
compileOnly group: 'org.gwtproject', name: 'gwt-dev', version: '2.12.2' // has vulnerabilities even in the latest version
160188
compileOnly group: 'org.gwtproject', name: 'gwt-user', version: '2.12.2'
189+
190+
// JUnit 5 dependencies
191+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
192+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
161193
}
162194

163-
// relevant for later insert the main file for GWT here later
195+
// GWT configuration
164196
gwt {
165197
modules = ["webapp.JGEXWebApp"]
166198
}
@@ -188,6 +220,17 @@ javadoc {
188220
mustRunAfter "msgFmtAll"
189221
}
190222

223+
// Configure test task
224+
test {
225+
useJUnitPlatform() // Use JUnit 5 platform
226+
mustRunAfter "msgFmtAll"
227+
}
228+
229+
// Make compileTestJava depend on msgFmtAll
230+
tasks.named("compileTestJava") {
231+
dependsOn "msgFmtAll"
232+
}
233+
191234
javapackager {
192235
description = "JGEX combines dynamic geometry software, automated geometry theorem prover with a visually dynamic approach for presenting proofs."
193236
mainClass = applicationMainClass
@@ -243,8 +286,68 @@ task runGproverMain2(type: JavaExec) {
243286
mainClass = 'gprover.Main2'
244287
}
245288

246-
// this copies files from the webapp folder to the war folder to be usable by GWT
289+
// GWT-related tasks
290+
291+
// This copies files from the webapp folder to the war folder to be usable by GWT
247292
tasks.register("prepareWebApp", Copy) {
293+
description "Copies web resources to the GWT war directory"
294+
group "GWT"
248295
from("src/main/webapp")
249296
into("build/gwt/war")
250-
}
297+
}
298+
299+
// Make GWT tasks depend on prepareWebApp
300+
tasks.named("gwtDevMode") {
301+
dependsOn prepareWebApp
302+
303+
// Configure Java compatibility for GWT development mode
304+
doFirst {
305+
// Ensure we're using a compatible Java version
306+
println "Running GWT DevMode with Java version: ${System.getProperty('java.version')}"
307+
}
308+
309+
// Set JVM args for Java 17 compatibility
310+
jvmArgs = ["-Xmx1024M", "-Xms512M", "--add-opens=java.base/java.lang=ALL-UNNAMED", "--add-opens=java.base/java.util=ALL-UNNAMED", "--add-opens=java.base/java.nio=ALL-UNNAMED"]
311+
312+
// Set GWT compiler args
313+
args = ["-style", "PRETTY", "-logLevel", "INFO"]
314+
}
315+
316+
tasks.named("gwtCompile") {
317+
dependsOn prepareWebApp
318+
}
319+
320+
// Add a task to run the GWT application in development mode
321+
tasks.register("runGwtDev") {
322+
description "Runs the GWT application in development mode"
323+
group "GWT"
324+
dependsOn gwtDevMode
325+
doLast {
326+
println "GWT development server started at http://127.0.0.1:8888/index.html"
327+
println "Press Ctrl+C to stop the server"
328+
}
329+
}
330+
331+
// Add a task to build and run the GWT application in production mode
332+
tasks.register("buildGwt") {
333+
description "Builds the GWT application for production"
334+
group "GWT"
335+
dependsOn gwtCompile
336+
doLast {
337+
println "GWT application built successfully in build/gwt/war"
338+
println "You can deploy the contents of this directory to a web server"
339+
}
340+
}
341+
342+
// Add a task to serve the compiled GWT application
343+
tasks.register("serveGwt") {
344+
description "Serves the compiled GWT application"
345+
group "GWT"
346+
dependsOn buildGwt
347+
doLast {
348+
println "To serve the GWT application, you can use a simple HTTP server:"
349+
println "cd build/gwt/war"
350+
println "python -m http.server 8000"
351+
println "Then open http://localhost:8000 in your browser"
352+
}
353+
}

0 commit comments

Comments
 (0)