Skip to content

Commit 46be279

Browse files
authored
V3 casl 1164 changed build gradle to correctly run for v3 (#481)
* V3 casl 1164 changed build gradle to correctly run for v3 Signed-off-by: Marcin-Here <[email protected]> * V3 casl 1164 added new docker images and jar run commands to README Signed-off-by: Marcin-Here <[email protected]> * V3 casl 1164 changed readConfigFile to proxy model Signed-off-by: Marcin-Here <[email protected]> --------- Signed-off-by: Marcin-Here <[email protected]>
1 parent f6cea1a commit 46be279

File tree

16 files changed

+76
-46
lines changed

16 files changed

+76
-46
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,25 @@ Apart from bare Postgres, Naksha needs [PostGIS]() extension which is mandatory.
6060
You can use standalone instance installed directly on your host machine but there's also a docker image that hosts Postgres 16 with all the extensions mentioned above already installed. You can find its definition in [this Dockerfile](here-naksha-app-service/src/jvmTest/psql_container/Dockerfile).
6161

6262
To use the containerized Postgres with your locally runnning Naksha:
63-
1) Navigate to [Dockerfile directory](here-naksha-app-service/src/jvmTest/psql_container):
64-
```
65-
cd here-naksha-app-service/src/jvmTest/psql_container
66-
```
67-
2) Build the image:
68-
```
69-
docker build --no-cache -t <IMAGE_ID> .
70-
```
71-
3) Run the container (supplied options omit all auth - use it only locally, tweak if needed):
72-
```
73-
docker run -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_INITDB_ARGS="--auth-host=trust --auth-local=trust" -e POSTGRES_HOST_AUTH_METHOD=trust <IMAGE_ID>
74-
```
63+
1) Pull docker image:
64+
```bash
65+
docker pull ghcr.io/naksha-oss/naksha-postgres:v16.2-r5
66+
```
67+
2) Run docker image with password set to default:
68+
```bash
69+
docker run -p 5432:5432 -e PGPASSWORD=password ghcr.io/naksha-oss/naksha-postgres:v16.2-r5
70+
```
71+
72+
3) When the docker container is started for the first time, it will generate a random password so to simplify local development we can change it to default.
73+
Also if you want locally persist your db changes refer to detailed containerized Postgres build.
74+
For more detailed containerized Postgres build refer to [this README](deployment/docker/README.md).
75+
76+
7577
4) Now your database should be available on `localhost` with port `5432` - you can start Naksha the same way as described in [Run App](#run-app) section.
7678

7779
5) \[optional extension run\] Now you can run naksha jar and include [example config with additional extensions enabled](here-naksha-app-service/src/main/resources/test-config-with-extensions.json) like so:
7880
```
79-
java -jar build/libs/naksha-2.0.6-all.jar test-config-with-extensions 'jdbc:postgresql://localhost:5432/postgres?user=postgres&password=pswd&schema=naksha&app=naksha_local&id=naksha_admin_db'
81+
java -jar here-naksha-app-service/build/libs/naksha-app-service-3.0.0-beta.24.jar test-config-with-extensions 'jdbc:postgresql://localhost:5432/postgres?user=postgres&password=pswd&schema=naksha&app=naksha_local&id=naksha_admin_db'
8082
```
8183

8284
### Run App
@@ -102,11 +104,11 @@ To ramp up Naksha with the jar, run:
102104
java -jar <jar-file> <config-id> <database-url>
103105
104106
# Example 1 : Start service with test config against default Database URL (useful for local env)
105-
java -jar build/libs/naksha-2.0.6-all.jar test-config
107+
java -jar here-naksha-app-service/build/libs/naksha-app-service-3.0.0-beta.24.jar test-config
106108
# Example 2 : Start service with given custom config and custom database URL (useful for cloud env)
107-
java -jar build/libs/naksha-2.0.6-all.jar cloud-config 'jdbc:postgresql://localhost:5432/postgres?user=postgres&password=pswd&schema=naksha&app=naksha_local&id=naksha_admin_db'
109+
java -jar here-naksha-app-service/build/libs/naksha-app-service-3.0.0-beta.24.jar cloud-config 'jdbc:postgresql://localhost:5432/postgres?user=postgres&password=pswd&schema=naksha&app=naksha_local&id=naksha_admin_db'
108110
# Example 3 : Start service with given custom config and default (local) database URL
109-
java -jar build/libs/naksha-2.0.6-all.jar custom-config
111+
java -jar here-naksha-app-service/build/libs/naksha-app-service-3.0.0-beta.24.jar custom-config
110112
111113
```
112114

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,7 @@ fun Task.publishToCentral() {
290290
}
291291
}
292292
tasks.register("publishToCentral") { publishToCentral() }
293+
294+
tasks.register("shadowJar") {
295+
dependsOn(":here-naksha-app-service:shadowJar")
296+
}

here-naksha-app-service/build.gradle.kts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
plugins {
24
alias(libs.plugins.kotlin.multiplatform)
5+
alias(libs.plugins.shadow)
36
}
47

58
description = gatherDescription()
9+
val mainApiClass = "com.here.naksha.app.service.NakshaApp"
10+
val fatJarBaseName = "naksha-app-service"
611

712
kotlin {
13+
jvm {
14+
mainRun {
15+
this.mainClass.set(mainApiClass)
16+
}
17+
}
818
sourceSets {
919
jvmMain {
1020
jvmToolchain(23)
@@ -38,8 +48,6 @@ kotlin {
3848
}
3949
}
4050
}
41-
42-
jvm {}
4351
}
4452

4553
tasks {
@@ -49,6 +57,23 @@ tasks {
4957
useJUnitPlatform()
5058
maxHeapSize = "6g"
5159
}
60+
val shadowJar by registering(ShadowJar::class) {
61+
archiveBaseName.set(fatJarBaseName)
62+
archiveClassifier.set("")
63+
archiveVersion.set(project.version.toString())
64+
65+
// mustRunAfter("testCodeCoverageReport")
66+
//
67+
// mergeServiceFiles()
68+
// isZip64 = true
69+
70+
manifest {
71+
attributes["Main-Class"] = mainApiClass
72+
}
73+
74+
from(kotlin.jvm().compilations.getByName("main").output)
75+
configurations = listOf(project.configurations.getByName("jvmRuntimeClasspath"))
76+
}
5277
}
5378
setOverallCoverage(0.0) // only increasing allowed!
5479

here-naksha-app-service/src/jvmMain/java/com/here/naksha/app/service/NakshaApp.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import io.vertx.ext.web.client.WebClient;
4040
import io.vertx.ext.web.client.WebClientOptions;
4141
import java.io.IOException;
42+
import java.net.URLEncoder;
43+
import java.nio.charset.StandardCharsets;
4244
import java.sql.SQLException;
4345
import java.util.ArrayList;
4446
import java.util.Date;
@@ -49,6 +51,8 @@
4951
import java.util.concurrent.atomic.AtomicBoolean;
5052
import java.util.concurrent.atomic.AtomicLong;
5153
import java.util.concurrent.atomic.AtomicReference;
54+
55+
import naksha.model.NakshaContext;
5256
import naksha.model.NakshaVersion;
5357
import org.jetbrains.annotations.NotNull;
5458
import org.jetbrains.annotations.Nullable;
@@ -67,7 +71,7 @@ public final class NakshaApp extends Thread {
6771

6872
private static final String DEFAULT_MAP_ID = "naksha";
6973

70-
private static final String DEFAULT_URL = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=pswd"
74+
private static final String DEFAULT_URL = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=password"
7175
+ "&schema=" + DEFAULT_MAP_ID
7276
+ "&app=" + NakshaHubConfig.defaultAppName();
7377
//+ "&id=" + PgStorage.ADMIN_STORAGE_ID;
@@ -202,6 +206,7 @@ public NakshaApp(
202206
}
203207
// Instantiate NakshaHub instance
204208
// TODO: what about appName?
209+
NakshaContext.newInstance(appName).attachToCurrentThread();
205210
this.hub = NakshaHubFactory.getInstance(storageUrl, nakshaHubConfig, configId);
206211
nakshaHubConfig = hub.getConfig(); // use the config finally set by NakshaHub instance
207212
log.info("Using server config : {}", nakshaHubConfig);

here-naksha-common-http/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ plugins {
55
description = gatherDescription()
66

77
kotlin {
8+
9+
jvm {}
10+
811
sourceSets {
912
jvmMain {
1013
jvmToolchain(23)
1114
dependencies {
1215
}
1316
}
1417
}
15-
16-
jvm {}
1718
}
1819

1920
tasks {

here-naksha-handler-activitylog/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
description = gatherDescription()
66

77
kotlin {
8+
jvm {}
89
sourceSets {
910
jvmMain {
1011
jvmToolchain(23)
@@ -25,8 +26,6 @@ kotlin {
2526
}
2627
}
2728
}
28-
29-
jvm {}
3029
}
3130

3231
tasks {

here-naksha-lib-base/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
description = gatherDescription()
1111

1212
kotlin {
13+
jvm {}
1314
sourceSets {
1415
commonMain {
1516
dependencies {
@@ -50,7 +51,6 @@ kotlin {
5051
}
5152
}
5253

53-
jvm {}
5454
js(IR) {
5555
outputModuleName = "naksha_base"
5656
useEsModules()

here-naksha-lib-core/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
description = gatherDescription()
66

77
kotlin {
8+
jvm {}
89
sourceSets {
910
jvmMain {
1011
jvmToolchain(23)
@@ -32,8 +33,6 @@ kotlin {
3233
}
3334
}
3435
}
35-
36-
jvm {}
3736
}
3837

3938
tasks {

here-naksha-lib-ext-manager/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
description = gatherDescription()
66

77
kotlin {
8+
jvm {}
89
sourceSets {
910
jvmMain {
1011
jvmToolchain(23)
@@ -23,8 +24,6 @@ kotlin {
2324
}
2425
}
2526
}
26-
27-
jvm {}
2827
}
2928

3029
tasks {

here-naksha-lib-geo/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
description = gatherDescription()
1111

1212
kotlin {
13+
jvm {}
1314
sourceSets {
1415
commonMain {
1516
dependencies {
@@ -54,7 +55,6 @@ kotlin {
5455
}
5556
}
5657

57-
jvm {}
5858
js(IR) {
5959
outputModuleName = "naksha_geo"
6060
useEsModules()

0 commit comments

Comments
 (0)