Skip to content

Commit 94c0f45

Browse files
committed
Add ShadowJar support and new OpenAI sample tests
- Introduced `shadow-convention` in build scripts for multiple modules. - Enabled `shadow` publication in Maven configuration. - Added sample OpenAI `pom.xml` and example tests utilizing MockOpenai. - Added `httpStatusCode` with default value `200` in response classes and builders.
1 parent 3d2498e commit 94c0f45

File tree

22 files changed

+400
-74
lines changed

22 files changed

+400
-74
lines changed

.editorconfig

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ insert_final_newline = true
1818
trim_trailing_whitespace = false
1919

2020
[*.java]
21-
indent_size = 4
21+
indent_size = tab
22+
tab_width = 4
2223
ij_java_names_count_to_use_import_on_demand = 2147483647
2324
ij_java_packages_to_use_import_on_demand = unset
2425

2526
# noinspection EditorConfigKeyCorrectness
2627
[*.{kt,kts}]
27-
indent_size = 4
28+
indent_size = tab
29+
tab_width = 4
2830
max_line_length = 100
2931
ij_kotlin_name_count_to_use_star_import = 2147483647
3032
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
@@ -36,8 +38,9 @@ ktlint_function_naming_ignore_when_annotated_with = "Test"
3638
max_line_length = off
3739
ij_kotlin_name_count_to_use_star_import = unset
3840
ij_kotlin_name_count_to_use_star_import_for_members = unset
39-
ij_kotlin_packages_to_use_import_on_demand = kotlinx.serialization,kotlinx.serialization.descriptors,kotlinx.serialization.encoding
41+
ij_kotlin_packages_to_use_import_on_demand = kotlinx.serialization, kotlinx.serialization.descriptors, kotlinx.serialization.encoding
4042
insert_final_newline = unset
41-
# no-trailing-spaces:
42-
# in
43-
# standard:no-multi-spaces: 2
43+
44+
[*.xml]
45+
tab_width = 4
46+
indent_size = tab

.github/workflows/gradle.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ jobs:
5454
caches/keyrings
5555
5656
- name: Build with Gradle
57-
run: gradle clean build dokkaGenerate dokkaJavadocJar sourcesJar koverXmlReport
57+
run: |
58+
./gradlew \
59+
--rerun-tasks --no-daemon \
60+
-Dorg.gradle.maven.repo.local=.m2-local \
61+
clean build publishToMavenLocal koverXmlReport
62+
63+
- name: OpenAI Maven Integration Tests
64+
working-directory: ai-mocks-openai/samples/shadow
65+
run: mvn --batch-mode test
5866

5967
- name: Publish Test Report
6068
uses: mikepenz/action-junit-report@v5
@@ -81,6 +89,7 @@ jobs:
8189
token: ${{ secrets.CODECOV_TOKEN }}
8290
slug: mokksy/ai-mocks
8391

92+
8493
dependency-submission:
8594

8695
runs-on: ubuntu-latest

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.PHONY: build
22
build:
3-
./gradlew clean build dokkaJavadocJar sourcesJar koverHtmlReport
3+
rm -rf ~/.m2/repository/me/kpavlov/aimocks ~/.m2/repository/me/kpavlov/mokksy && \
4+
./gradlew --rerun-tasks clean build publishToMavenLocal koverHtmlReport && \
5+
(cd ai-mocks-openai/samples/shadow && mvn test)
46

57
.PHONY: test
68
test:
@@ -43,7 +45,7 @@ pom:
4345
.PHONY: publish
4446
publish:
4547
rm -rf ~/.m2/repository/me/kpavlov/aimocks ~/.m2/repository/me/kpavlov/mokksy
46-
./gradlew clean build check sourcesJar publishToMavenLocal
48+
./gradlew --rerun-tasks clean build check sourcesJar publishToMavenLocal
4749
echo "Publishing 📢"
4850
## https://vanniktech.github.io/gradle-maven-publish-plugin/central/#configuring-maven-central
4951
# ./gradlew publishToMavenCentral \

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
SONATYPE_PASSWORD=...
1414

1515
./gradlew clean build sourcesJar check publishToMavenCentral \
16-
--stacktrace --warning-mode=all \
16+
--stacktrace --rerun-tasks --warning-mode=all \
1717
-PmavenCentralUsername="$SONATYPE_USERNAME" \
1818
-PmavenCentralPassword="$SONATYPE_PASSWORD"
1919
```

ai-mocks-a2a/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
`dokka-convention`
66
`publish-convention`
77
`netty-convention`
8+
`shadow-convention`
89
}
910

1011
dokka {
@@ -63,3 +64,18 @@ kotlin {
6364
}
6465
}
6566
}
67+
68+
publishing {
69+
publications {
70+
create<MavenPublication>("shadow") {
71+
artifactId = "${project.name}-standalone"
72+
artifact(tasks.named("shadowJar")) {
73+
classifier = ""
74+
extension = "jar"
75+
}
76+
artifact(tasks["jvmSourcesJar"]) {
77+
classifier = "sources"
78+
}
79+
}
80+
}
81+
}

ai-mocks-anthropic/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
`kotlin-convention`
55
`dokka-convention`
66
`publish-convention`
7+
`shadow-convention`
78
}
89

910
dokka {
@@ -57,3 +58,18 @@ kotlin {
5758
}
5859
}
5960
}
61+
62+
publishing {
63+
publications {
64+
create<MavenPublication>("shadow") {
65+
artifactId = "${project.name}-standalone"
66+
artifact(tasks.named("shadowJar")) {
67+
classifier = ""
68+
extension = "jar"
69+
}
70+
artifact(tasks["jvmSourcesJar"]) {
71+
classifier = "sources"
72+
}
73+
}
74+
}
75+
}

ai-mocks-gemini/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
`kotlin-convention`
55
`dokka-convention`
66
`publish-convention`
7+
`shadow-convention`
78
}
89

910
dokka {
@@ -56,3 +57,18 @@ kotlin {
5657
}
5758
}
5859
}
60+
61+
publishing {
62+
publications {
63+
create<MavenPublication>("shadow") {
64+
artifactId = "${project.name}-standalone"
65+
artifact(tasks.named("shadowJar")) {
66+
classifier = ""
67+
extension = "jar"
68+
}
69+
artifact(tasks["jvmSourcesJar"]) {
70+
classifier = "sources"
71+
}
72+
}
73+
}
74+
}

ai-mocks-ollama/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
`kotlin-convention`
55
`dokka-convention`
66
`publish-convention`
7+
`shadow-convention`
78
}
89

910
kotlin {
@@ -62,3 +63,18 @@ kotlin {
6263
}
6364
}
6465
}
66+
67+
publishing {
68+
publications {
69+
create<MavenPublication>("shadow") {
70+
artifactId = "${project.name}-standalone"
71+
artifact(tasks.named("shadowJar")) {
72+
classifier = ""
73+
extension = "jar"
74+
}
75+
artifact(tasks["jvmSourcesJar"]) {
76+
classifier = "sources"
77+
}
78+
}
79+
}
80+
}

ai-mocks-openai/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
`dokka-convention`
66
`publish-convention`
77
`netty-convention`
8+
`shadow-convention`
89
// id("org.openapi.generator") version "7.12.0"
910
}
1011

@@ -59,3 +60,18 @@ kotlin {
5960
}
6061
}
6162
}
63+
64+
publishing {
65+
publications {
66+
create<MavenPublication>("shadow") {
67+
artifactId = "${project.name}-standalone"
68+
artifact(tasks.named("shadowJar")) {
69+
classifier = ""
70+
extension = "jar"
71+
}
72+
artifact(tasks["jvmSourcesJar"]) {
73+
classifier = "sources"
74+
}
75+
}
76+
}
77+
}

ai-mocks-openai/samples/OpenaiLc4jSample.ipynb

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"metadata": {
1111
"collapsed": true,
1212
"ExecuteTime": {
13-
"end_time": "2025-09-19T19:49:09.868118Z",
14-
"start_time": "2025-09-19T19:49:05.225077Z"
13+
"end_time": "2025-09-21T08:33:23.068468Z",
14+
"start_time": "2025-09-21T08:33:22.912180Z"
1515
}
1616
},
1717
"source": [
@@ -23,21 +23,21 @@
2323
" mavenCentral()\n",
2424
" }\n",
2525
" dependencies(\n",
26-
" \"me.kpavlov.aimocks:ai-mocks-openai-jvm:0.5.0-SNAPSHOT\",\n",
26+
" \"me.kpavlov.aimocks:ai-mocks-openai-standalone:0.5.0-SNAPSHOT\",\n",
2727
" \"io.kotest:kotest-assertions-core:5.9.1\",\n",
28-
" \"io.kotest:kotest-assertions-json:5.9.1\",\n",
2928
" \"dev.langchain4j:langchain4j-open-ai:1.5.0\",\n",
29+
" \"dev.langchain4j:langchain4j-kotlin:1.5.0-beta11\",\n",
3030
" )\n",
3131
"}"
3232
],
3333
"outputs": [],
34-
"execution_count": 10
34+
"execution_count": 3
3535
},
3636
{
3737
"metadata": {
3838
"ExecuteTime": {
39-
"end_time": "2025-09-19T19:49:09.960056Z",
40-
"start_time": "2025-09-19T19:49:09.877363Z"
39+
"end_time": "2025-09-21T08:33:27.746433Z",
40+
"start_time": "2025-09-21T08:33:27.667009Z"
4141
}
4242
},
4343
"cell_type": "code",
@@ -51,7 +51,7 @@
5151
"import io.kotest.matchers.shouldBe\n",
5252
"import io.kotest.matchers.shouldNotBe\n",
5353
"\n",
54-
"val openai = MockOpenai(verbose = true)\n",
54+
"val openai = MockOpenai(verbose = true, port = 0)\n",
5555
"\n",
5656
"val model: OpenAiChatModel =\n",
5757
" OpenAiChatModel\n",
@@ -61,8 +61,8 @@
6161
" .build()\n",
6262
"\n",
6363
"openai.completion {\n",
64-
" temperature = 0.42\n",
65-
" seed = 100500\n",
64+
"// temperature(0.42) = 0.42\n",
65+
"// seed = 100500\n",
6666
" model = \"4o\"\n",
6767
" maxTokens = 120\n",
6868
"} responds {\n",
@@ -96,31 +96,34 @@
9696
],
9797
"outputs": [
9898
{
99-
"ename": "java.lang.NoClassDefFoundError",
100-
"evalue": "io/ktor/server/plugins/contentnegotiation/ContentNegotiationConfig",
99+
"ename": "org.jetbrains.kotlinx.jupyter.exceptions.ReplCompilerException",
100+
"evalue": "at Cell In[4], line 3, column 35: Unresolved reference: chat\nat Cell In[4], line 10, column 14: None of the following functions can be called with the arguments supplied: \npublic constructor MockOpenai() defined in me.kpavlov.aimocks.openai.MockOpenai\npublic constructor MockOpenai(port: Int, verbose: Boolean) defined in me.kpavlov.aimocks.openai.MockOpenai\nat Cell In[4], line 20, column 3: Unresolved reference: temperature\nat Cell In[4], line 21, column 3: Unresolved reference: seed\nat Cell In[4], line 22, column 3: Val cannot be reassigned\nat Cell In[4], line 22, column 11: Type mismatch: inferred type is String but OpenAiChatModel was expected\nat Cell In[4], line 23, column 3: Unresolved reference: maxTokens\nat Cell In[4], line 25, column 3: Unresolved reference: assistantContent\nat Cell In[4], line 26, column 3: Unresolved reference: finishReason\nat Cell In[4], line 32, column 11: None of the following functions can be called with the arguments supplied: \npublic open fun chat(p0: ChatRequest!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel\npublic open fun chat(vararg p0: ChatMessage!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel\npublic open fun chat(p0: String!): String! defined in dev.langchain4j.model.openai.OpenAiChatModel\npublic open fun chat(p0: (Mutable)List<ChatMessage!>!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel\nat Cell In[4], line 33, column 7: Unresolved reference: parameters\nat Cell In[4], line 41, column 7: Unresolved reference: messages\nat Cell In[4], line 41, column 16: Unresolved reference: +=\nat Cell In[4], line 45, column 5: Unresolved reference: finishReason\nat Cell In[4], line 46, column 5: Unresolved reference: tokenUsage\nat Cell In[4], line 47, column 5: Unresolved reference: aiMessage",
101101
"output_type": "error",
102102
"traceback": [
103-
"java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationConfig",
104-
"\tat me.kpavlov.aimocks.openai.MockOpenai.<init>(MockOpenai.kt:33)",
105-
"\tat me.kpavlov.aimocks.openai.MockOpenai.<init>(MockOpenai.kt:27)",
106-
"\tat Line_24_jupyter.<init>(Line_24.jupyter.kts:10) at Cell In[11], line 10",
107-
"\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)",
108-
"\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)",
109-
"\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)",
110-
"\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:122)",
111-
"\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:48)",
112-
"\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)",
113-
"\tat kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:49)",
114-
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl$eval$resultWithDiagnostics$1.invokeSuspend(InternalEvaluatorImpl.kt:137)",
115-
"\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)",
116-
"\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)",
117-
"\tat kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)",
118-
"\tat kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)",
119-
"\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)",
120-
"\tat kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)",
121-
"\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:47)",
122-
"\tat kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)",
123-
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:137)",
103+
"org.jetbrains.kotlinx.jupyter.exceptions.ReplCompilerException: at Cell In[4], line 3, column 35: Unresolved reference: chat",
104+
"at Cell In[4], line 10, column 14: None of the following functions can be called with the arguments supplied: ",
105+
"public constructor MockOpenai() defined in me.kpavlov.aimocks.openai.MockOpenai",
106+
"public constructor MockOpenai(port: Int, verbose: Boolean) defined in me.kpavlov.aimocks.openai.MockOpenai",
107+
"at Cell In[4], line 20, column 3: Unresolved reference: temperature",
108+
"at Cell In[4], line 21, column 3: Unresolved reference: seed",
109+
"at Cell In[4], line 22, column 3: Val cannot be reassigned",
110+
"at Cell In[4], line 22, column 11: Type mismatch: inferred type is String but OpenAiChatModel was expected",
111+
"at Cell In[4], line 23, column 3: Unresolved reference: maxTokens",
112+
"at Cell In[4], line 25, column 3: Unresolved reference: assistantContent",
113+
"at Cell In[4], line 26, column 3: Unresolved reference: finishReason",
114+
"at Cell In[4], line 32, column 11: None of the following functions can be called with the arguments supplied: ",
115+
"public open fun chat(p0: ChatRequest!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel",
116+
"public open fun chat(vararg p0: ChatMessage!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel",
117+
"public open fun chat(p0: String!): String! defined in dev.langchain4j.model.openai.OpenAiChatModel",
118+
"public open fun chat(p0: (Mutable)List<ChatMessage!>!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel",
119+
"at Cell In[4], line 33, column 7: Unresolved reference: parameters",
120+
"at Cell In[4], line 41, column 7: Unresolved reference: messages",
121+
"at Cell In[4], line 41, column 16: Unresolved reference: +=",
122+
"at Cell In[4], line 45, column 5: Unresolved reference: finishReason",
123+
"at Cell In[4], line 46, column 5: Unresolved reference: tokenUsage",
124+
"at Cell In[4], line 47, column 5: Unresolved reference: aiMessage",
125+
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.JupyterCompilerImpl.compileSync(JupyterCompilerImpl.kt:151)",
126+
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:126)",
124127
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute_L4Nmkdk$lambda$0$0(CellExecutorImpl.kt:80)",
125128
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.withHost(ReplForJupyterImpl.kt:791)",
126129
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute-L4Nmkdk(CellExecutorImpl.kt:78)",
@@ -147,13 +150,11 @@
147150
"\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$Task.execute(JupyterExecutorImpl.kt:41)",
148151
"\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl.executorThread$lambda$0(JupyterExecutorImpl.kt:81)",
149152
"\tat kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)",
150-
"",
151-
"java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationConfig",
152-
"at Cell In[11], line 10"
153+
""
153154
]
154155
}
155156
],
156-
"execution_count": 11
157+
"execution_count": 4
157158
}
158159
],
159160
"metadata": {

0 commit comments

Comments
 (0)