Skip to content

Commit 9820956

Browse files
Merge pull request #19 from briancorbinxyz/feature/packaging
Feature/packaging
2 parents 6d2fc50 + cdcdfef commit 9820956

File tree

70 files changed

+314
-177
lines changed

Some content is hidden

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

70 files changed

+314
-177
lines changed

.vscode/launch.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,35 @@
1414
"type": "java",
1515
"name": "SecureConnectionTest$Server",
1616
"request": "launch",
17-
"mainClass": "org.example.SecureConnectionTest$Server",
17+
"mainClass": "org.xxdc.oss.example.SecureConnectionTest$Server",
1818
"projectName": "app"
1919
},
2020
{
2121
"type": "java",
2222
"name": "SecureConnectionTest$Client",
2323
"request": "launch",
24-
"mainClass": "org.example.SecureConnectionTest$Client",
24+
"mainClass": "org.xxdc.oss.example.SecureConnectionTest$Client",
2525
"projectName": "app"
2626
},
2727
{
2828
"type": "java",
2929
"name": "SecureConnection$Client",
3030
"request": "launch",
31-
"mainClass": "org.example.SecureConnection$Client",
31+
"mainClass": "org.xxdc.oss.example.SecureConnection$Client",
3232
"projectName": "app"
3333
},
3434
{
3535
"type": "java",
3636
"name": "SecureConnection$Server",
3737
"request": "launch",
38-
"mainClass": "org.example.SecureConnection$Server",
38+
"mainClass": "org.xxdc.oss.example.SecureConnection$Server",
3939
"projectName": "app"
4040
},
4141
{
4242
"type": "java",
4343
"name": "SecureConnection",
4444
"request": "launch",
45-
"mainClass": "org.example.SecureConnection",
45+
"mainClass": "org.xxdc.oss.example.SecureConnection",
4646
"projectName": "app"
4747
},
4848
{
@@ -82,7 +82,7 @@
8282
"type": "java",
8383
"name": "App",
8484
"request": "launch",
85-
"mainClass": "org.example.App",
85+
"mainClass": "org.xxdc.oss.example.App",
8686
"projectName": "app",
8787
"env": {
8888
"LIB_PATH": "${workspaceFolder}/app/build/cargo/debug",
@@ -95,7 +95,7 @@
9595
"type": "java",
9696
"name": "GameClient",
9797
"request": "launch",
98-
"mainClass": "org.example.GameClient",
98+
"mainClass": "org.xxdc.oss.example.GameClient",
9999
"projectName": "app",
100100
"env": {
101101
"LIB_PATH": "${workspaceFolder}/app/build/cargo/debug",
@@ -109,7 +109,7 @@
109109
"name": "GameClient (on ZGC)",
110110
"request": "launch",
111111
"vmArgs": "-XX:+UseZGC",
112-
"mainClass": "org.example.GameClient",
112+
"mainClass": "org.xxdc.oss.example.GameClient",
113113
"projectName": "app",
114114
"env": {
115115
"LIB_PATH": "${workspaceFolder}/app/build/cargo/debug",
@@ -122,7 +122,7 @@
122122
"type": "java",
123123
"name": "GameServer",
124124
"request": "launch",
125-
"mainClass": "org.example.GameServer",
125+
"mainClass": "org.xxdc.oss.example.GameServer",
126126
"projectName": "app",
127127
"env": {
128128
"LIB_PATH": "${workspaceFolder}/app/build/cargo/debug",
@@ -136,7 +136,7 @@
136136
"name": "GameServer (on ZGC)",
137137
"request": "launch",
138138
"vmArgs": "-XX:+UseZGC",
139-
"mainClass": "org.example.GameServer",
139+
"mainClass": "org.xxdc.oss.example.GameServer",
140140
"projectName": "app",
141141
"env": {
142142
"LIB_PATH": "${workspaceFolder}/app/build/cargo/debug",

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@
2929
"org"
3030
],
3131
"java.configuration.updateBuildConfiguration": "automatic",
32+
"java.dependency.packagePresentation": "hierarchical",
3233
}

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,18 @@ https://openjdk.org/projects/jdk/17/
5757

5858
### Algorithms
5959

60-
The following algorithms are used by the AI BOT in this project:
60+
The following algorithms are used by the AI BOT in this project (For a detailed discussion see [Road to JDK 25 - An Algorithmic Interlude](https://briancorbinxyz.medium.com/over-engineering-tic-tac-toe-an-algorithmic-interlude-8af3aa13173a):
6161

6262
- [Random](https://en.wikipedia.org/wiki/Randomness) See: [Random.java](app/src/main/java/org/example/bot/Random.java)
6363
- [Minimax](https://en.wikipedia.org/wiki/Minimax) See: [Minimax.java](app/src/main/java/org/example/bot/Minimax.java)
64-
- [Alpha-Beta](https://en.wikipedia.org/wiki/Alpha-beta_pruning) See: [AlphaBeta.java](app/src/main/java/org/example/bot/AlphaBeta.java)
64+
- [Minimax w. Alpha-Beta](https://en.wikipedia.org/wiki/Alpha-beta_pruning) See: [AlphaBeta.java](app/src/main/java/org/example/bot/AlphaBeta.java)
6565
- [MaxN](https://en.wikipedia.org/wiki/Maxn_algorithm) See: [MaxN.java](app/src/main/java/org/example/bot/MaxN.java)
6666
- [Paranoid](https://en.wikipedia.org/wiki/Paranoid_AI) See: [Paranoid.java](app/src/main/java/org/example/bot/Paranoid.java)
67-
- [Monte Carlo](https://en.wikipedia.org/wiki/Monte_Carlo_method) See [MonteCarlo.java](app/src/main/java/org/example/bot/MonteCarloTreeSearch.java)
67+
- [Monte Carlo Tree Search](https://en.wikipedia.org/wiki/Monte_Carlo_method) See [MonteCarloTreeSearch.java](app/src/main/java/org/example/bot/MonteCarloTreeSearch.java)
68+
69+
70+
---
71+
72+
### Quick Start
73+
74+
- To run the single game application, use the following command: `./gradlew run`

app/build.gradle.kts

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
application
66
id("org.graalvm.buildtools.native") version "0.10.2"
77
id("com.diffplug.spotless") version "7.0.0.BETA1"
8+
`maven-publish`
89
}
910

1011
repositories {
@@ -13,6 +14,8 @@ repositories {
1314
gradlePluginPortal()
1415
}
1516

17+
val jdkVersion = "22"
18+
1619
// JDK22: Foreign Function Interface (FFI)
1720
// Support building native Rust library using Cargo:
1821
// https://doc.rust-lang.org/cargo/getting-started/installation.html
@@ -103,7 +106,7 @@ dependencies {
103106
tasks.register<JavaExec>("jmh") {
104107
mainClass.set("org.openjdk.jmh.Main")
105108
classpath = sourceSets["main"].runtimeClasspath
106-
args = listOf("org.example.interop.benchmark.PlayerIdsBenchmark")
109+
args = listOf("org.xxdc.oss.example.interop.benchmark.PlayerIdsBenchmark")
107110
}
108111

109112
testing {
@@ -119,8 +122,10 @@ testing {
119122
// Apply a specific Java toolchain to ease working on different environments.
120123
java {
121124
toolchain {
122-
languageVersion = JavaLanguageVersion.of(23)
125+
languageVersion = JavaLanguageVersion.of(jdkVersion)
123126
}
127+
withJavadocJar()
128+
withSourcesJar()
124129
}
125130

126131
// Code formatting (./gradlew spotlessApply)
@@ -138,7 +143,7 @@ graalvmNative {
138143
javaLauncher = javaToolchains.launcherFor {
139144
// NB: On MacOS ARM ARCH the native-image implementation is not available
140145
// for the versions of GRAAL_VM Community edition - selecting Oracle
141-
languageVersion = JavaLanguageVersion.of(23)
146+
languageVersion = JavaLanguageVersion.of(jdkVersion)
142147
vendor = JvmVendorSpec.matching("Oracle")
143148
// languageVersion = JavaLanguageVersion.of(17)
144149
// vendor = JvmVendorSpec.GRAAL_VM
@@ -149,11 +154,11 @@ graalvmNative {
149154

150155
application {
151156
// Define the main class for the application.
152-
mainClass = "org.example.App"
157+
mainClass = "org.xxdc.oss.example.App"
153158
// JDK22: Foreign Function Interface (FFI)
154159
// Resolves Warning:
155160
// WARNING: A restricted method in java.lang.foreign.SymbolLookup has been called
156-
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module
161+
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.xxdc.oss.example.GameBoardNativeImpl in an unnamed module
157162
// WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
158163
// WARNING: Restricted methods will be blocked in a future release unless native access is enabled
159164
applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC")
@@ -164,6 +169,53 @@ tasks.run.configure {
164169
standardInput = System.`in`
165170
}
166171

172+
// https://docs.gradle.org/current/userguide/publishing_maven.html
173+
publishing {
174+
repositories {
175+
// Publish to GitHub Packages
176+
// https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-gradle
177+
maven {
178+
name = "GitHubPackages"
179+
url = uri("https://maven.pkg.github.com/briancorbinxyz/overengineering-tictactoe")
180+
credentials {
181+
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
182+
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
183+
}
184+
}
185+
}
186+
publications {
187+
create<MavenPublication>("maven") {
188+
groupId = "org.xxdc.oss.example"
189+
artifactId = "tictactoe"
190+
version = "1.0.0-jdk$jdkVersion"
191+
from(components["java"])
192+
pom {
193+
name.set("tictactoe")
194+
description.set("An Over-Engineered Tic Tac Toe game")
195+
url.set("https://github.com/briancorbinxyz/overengineering-tictactoe")
196+
licenses {
197+
license {
198+
name.set("MIT License")
199+
url.set("https://opensource.org/licenses/MIT")
200+
}
201+
developers {
202+
developer {
203+
id.set("briancorbinxyz")
204+
name.set("Brian Corbin")
205+
email.set("mail@briancorbin.xyz")
206+
}
207+
}
208+
}
209+
scm {
210+
connection.set("scm:git:git://github.com/briancorbinxyz/overengineering-tictactoe.git")
211+
developerConnection.set("scm:git:ssh://github.com/briancorbinxyz/overengineering-tictactoe.git")
212+
url.set("https://github.com/briancorbinxyz/overengineering-tictactoe")
213+
}
214+
}
215+
}
216+
}
217+
}
218+
167219
tasks.withType<Test>().all {
168220
systemProperty(
169221
"java.library.path", libPath
@@ -172,7 +224,7 @@ tasks.withType<Test>().all {
172224
// JDK22: Foreign Function Interface (FFI)
173225
// Resolves Warning:
174226
// WARNING: A restricted method in java.lang.foreign.SymbolLookup has been called
175-
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module
227+
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.xxdc.oss.example.GameBoardNativeImpl in an unnamed module
176228
// WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
177229
// WARNING: Restricted methods will be blocked in a future release unless native access is enabled
178230
jvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC")
@@ -189,7 +241,7 @@ tasks.named<JavaExec>("run") {
189241
// JDK22: Foreign Function Interface (FFI)
190242
// Resolves Warning:
191243
// WARNING: A restricted method in java.lang.foreign.SymbolLookup has been called
192-
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.example.GameBoardNativeImpl in an unnamed module
244+
// WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by org.xxdc.oss.example.GameBoardNativeImpl in an unnamed module
193245
// WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
194246
// WARNING: Restricted methods will be blocked in a future release unless native access is enabled
195247
jvmArgs = listOf("--enable-native-access=ALL-UNNAMED", "-XX:+UseZGC")

app/src/main/java/org/example/App.java renamed to app/src/main/java/org/xxdc/oss/example/App.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
22
* This source file was generated by the Gradle 'init' task
33
*/
4-
package org.example;
4+
package org.xxdc.oss.example;
55

66
import java.io.File;
77
import java.lang.System.Logger;
88
import java.lang.System.Logger.Level;
9-
import org.example.bot.BotStrategy;
10-
import org.example.bot.BotStrategyConfig;
9+
import org.xxdc.oss.example.bot.BotStrategy;
10+
import org.xxdc.oss.example.bot.BotStrategyConfig;
1111

1212
/** A simple java tic-tac-toe game. */
1313
public class App {

app/src/main/java/org/example/BotPlayer.java renamed to app/src/main/java/org/xxdc/oss/example/BotPlayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package org.example;
1+
package org.xxdc.oss.example;
22

33
import java.io.Serializable;
44
import java.util.function.ToIntFunction;
5-
import org.example.bot.BotStrategy;
5+
import org.xxdc.oss.example.bot.BotStrategy;
66

77
/**
88
* Represents a bot player in the game. The bot player uses a random number generator to make moves

app/src/main/java/org/example/Game.java renamed to app/src/main/java/org/xxdc/oss/example/Game.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.example;
1+
package org.xxdc.oss.example;
22

33
import java.io.File;
44
import java.io.IOException;

app/src/main/java/org/example/GameBoard.java renamed to app/src/main/java/org/xxdc/oss/example/GameBoard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.example;
1+
package org.xxdc.oss.example;
22

33
import java.util.ArrayList;
44
import java.util.List;

app/src/main/java/org/example/GameBoardDefaultImpl.java renamed to app/src/main/java/org/xxdc/oss/example/GameBoardDefaultImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.example;
1+
package org.xxdc.oss.example;
22

33
import java.io.Serializable;
44
import java.util.Arrays;

app/src/main/java/org/example/GameBoardNativeImpl.java renamed to app/src/main/java/org/xxdc/oss/example/GameBoardNativeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package org.example;
1+
package org.xxdc.oss.example;
22

33
import java.lang.System.Logger;
44
import java.lang.invoke.MethodHandles;
5-
import org.example.interop.TicTacToeLibrary;
5+
import org.xxdc.oss.example.interop.TicTacToeLibrary;
66

77
/**
88
* Implements the GameBoard interface using a native library. This class manages the lifetime of the

0 commit comments

Comments
 (0)