Skip to content

Commit dca7107

Browse files
committed
Move clientserver code into a subproject
Left behind was `ConnectionFactory` as it is really a MapTool-specific tool for building connections and servers rather than a part of the general client-server logic itself. Also pulled in was `Handshake` and `HandshakeObserver` since they are used in the client-server and are an important part of the process (the implementations were left behind though). Common build configurations wered moved into a `shared.gradle` file applied to the root project and subprojects. Dependencies specific to the clientserver subproject were moved out of the root project to keep things clear.
1 parent 8d3cd77 commit dca7107

27 files changed

+92
-52
lines changed

build.gradle

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,23 @@ plugins {
1818
id "base"
1919
id "java"
2020
id "org.ajoberstar.grgit" version "5.2.1"
21-
id "com.diffplug.spotless" version "6.25.0"
2221
id 'org.openjfx.javafxplugin' version '0.0.13'
2322
id 'org.beryx.runtime' version '1.13.0'
2423
id "com.google.protobuf" version "0.9.4"
2524
id 'com.github.johnrengelman.shadow' version '8.1.1'
25+
26+
id "com.diffplug.spotless" version "6.25.0" apply false
27+
}
28+
29+
allprojects {
30+
apply plugin: "com.diffplug.spotless"
2631
}
2732

33+
apply from: rootProject.file('buildSrc/shared.gradle')
34+
2835
// Definitions
2936
defaultTasks 'clean', 'build'
3037

31-
java {
32-
sourceCompatibility = JavaVersion.VERSION_21
33-
targetCompatibility = JavaVersion.VERSION_21
34-
}
35-
3638
def javaArgs = [
3739
"-Xss8M", "-Dsun.java2d.d3d=false", "-Dsentry.environment=Production", "-Dfile.encoding=UTF-8",
3840
"-Dpolyglot.engine.WarnInterpreterOnly=false",
@@ -112,32 +114,18 @@ ext {
112114
println "OS Detected: " + osdetector.os
113115
}
114116

117+
115118
spotless {
116119
java {
117-
target project.fileTree(project.rootDir) {
120+
target project.fileTree(project.projectDir) {
118121
include 'src/**/*.java'
119122
exclude '**/JTextAreaAppender.java'
120123
exclude 'src/main/java/net/rptools/maptool/client/ui/themes/Flat*ContrastIJTheme.java'
121124
exclude 'src/main/java/net/rptools/maptool/client/ui/themes/Utils.java'
122125
}
123-
licenseHeaderFile 'spotless.license.java'
124-
toggleOffOn()
125-
126-
// Now using the Google Java style guide
127-
googleJavaFormat("1.17.0")
128-
}
129-
130-
format 'misc', {
131-
target '**/*.gradle', '**/.gitignore'
132-
133-
// spotless has built-in rules for most basic formatting tasks
134-
trimTrailingWhitespace()
135-
// or spaces. Takes an integer argument if you don't like 4
136-
indentWithSpaces(4)
137126
}
138127
}
139128

140-
141129
// org.openjfx.javafxplugin
142130
javafx {
143131
version = '22'
@@ -325,23 +313,13 @@ runtime {
325313
}
326314
}
327315
}
328-
// In this section you declare where to find the dependencies of your project
329-
repositories {
330-
// Use 'jcenter' for resolving your dependencies.
331-
// You can declare any Maven/Ivy/file repository here.
332-
mavenLocal()
333-
mavenCentral()
334-
maven { url = 'https://maptool.craigs-stuff.net/repo/' }
335-
maven { url = 'https://jitpack.io' }
336-
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
337-
maven { url "https://cache-redirector.jetbrains.com/intellij-dependencies" }
338-
}
339-
340316

341317
// In this section you declare the dependencies for your production and test code
342318
dependencies {
343319
forms group: 'com.jetbrains.intellij.java', name: 'java-compiler-ant-tasks', version: '233.14475.56'
344320

321+
implementation project(':clientserver')
322+
345323
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.22.1'
346324
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.22.1'
347325
implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.20.0' // Bridges v1 to v2 for other code in other libs
@@ -492,16 +470,6 @@ dependencies {
492470
// Noise Generator
493471
implementation 'com.github.cwisniew:NoiseLib:1.0.0' // The most recent version, 1.0.0 is build for a later java version: major version 55 is newer than 54, the highest major version supported by this compiler
494472

495-
// webrtc
496-
implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.6'
497-
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0'
498-
if (osdetector.os.is('windows'))
499-
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:windows-x86_64'
500-
else if (osdetector.os.is('osx'))
501-
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:macos-x86_64'
502-
else if (osdetector.os.is('linux'))
503-
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:linux-x86_64'
504-
505473
// protobuf
506474
implementation "io.grpc:grpc-protobuf:1.61.1"
507475
implementation "com.google.protobuf:protobuf-java-util:3.25.2"
@@ -516,9 +484,6 @@ dependencies {
516484
implementation 'org.jsoup:jsoup:1.17.2'
517485
// eventbus
518486
implementation 'com.google.guava:guava:33.0.0-jre'
519-
// compression of messages between client and server
520-
implementation 'org.apache.commons:commons-compress:1.26.0'
521-
implementation 'com.github.luben:zstd-jni:1.5.5-11'
522487
// intellij forms runtime
523488
implementation 'com.jetbrains.intellij.java:java-gui-forms-rt:241.12019'
524489
// layout for forms created in code

buildSrc/shared.gradle

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// In this section you declare where to find the dependencies of your project
2+
repositories {
3+
mavenLocal()
4+
mavenCentral()
5+
maven { url = 'https://maptool.craigs-stuff.net/repo/' }
6+
maven { url = 'https://jitpack.io' }
7+
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
8+
maven { url "https://cache-redirector.jetbrains.com/intellij-dependencies" }
9+
}
10+
11+
java {
12+
sourceCompatibility = JavaVersion.VERSION_21
13+
targetCompatibility = JavaVersion.VERSION_21
14+
}
15+
16+
spotless {
17+
java {
18+
target project.fileTree(project.projectDir) {
19+
include 'src/**/*.java'
20+
}
21+
licenseHeaderFile rootProject.file('spotless.license.java')
22+
toggleOffOn()
23+
// Now using the Google Java style guide
24+
googleJavaFormat("1.17.0")
25+
}
26+
27+
format 'misc', {
28+
target '**/*.gradle', '**/.gitignore'
29+
30+
// spotless has built-in rules for most basic formatting tasks
31+
trimTrailingWhitespace()
32+
// or spaces. Takes an integer argument if you don't like 4
33+
indentWithSpaces(4)
34+
}
35+
}

clientserver/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
plugins {
2+
id "base"
3+
id "java-library"
4+
}
5+
6+
apply from: rootProject.file('buildSrc/shared.gradle')
7+
8+
// In this section you declare the dependencies for your production and test code
9+
dependencies {
10+
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.22.1'
11+
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.22.1'
12+
implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.20.0' // Bridges v1 to v2 for other code in other libs
13+
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.12'
14+
implementation group: 'commons-logging', name: 'commons-logging', version: '1.3.0'
15+
16+
// Better JSON functions...
17+
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1' // https://mvnrepository.com/artifact/com.google.code.gson/gson
18+
19+
// webrtc
20+
implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.6'
21+
// Needs to be API since WebRTCConnection implements PeerConnectionObserver and RTCDataChannelObserver.
22+
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0'
23+
if (osdetector.os.is('windows'))
24+
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:windows-x86_64'
25+
else if (osdetector.os.is('osx'))
26+
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:macos-x86_64'
27+
else if (osdetector.os.is('linux'))
28+
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:linux-x86_64'
29+
30+
// compression of messages between client and server
31+
implementation 'org.apache.commons:commons-compress:1.26.0'
32+
implementation 'com.github.luben:zstd-jni:1.5.5-11'
33+
}

src/main/java/net/rptools/maptool/server/Handshake.java renamed to clientserver/src/main/java/net/rptools/clientserver/simple/Handshake.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* <http://www.gnu.org/licenses/> and specifically the Affero license
1313
* text at <http://www.gnu.org/licenses/agpl.html>.
1414
*/
15-
package net.rptools.maptool.server;
15+
package net.rptools.clientserver.simple;
1616

1717
import java.util.concurrent.ExecutionException;
1818
import net.rptools.clientserver.simple.connection.Connection;

src/main/java/net/rptools/maptool/server/HandshakeObserver.java renamed to clientserver/src/main/java/net/rptools/clientserver/simple/HandshakeObserver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* <http://www.gnu.org/licenses/> and specifically the Affero license
1313
* text at <http://www.gnu.org/licenses/agpl.html>.
1414
*/
15-
package net.rptools.maptool.server;
15+
package net.rptools.clientserver.simple;
1616

1717
public interface HandshakeObserver {
1818

0 commit comments

Comments
 (0)