From 07e11a7817c26baf78257d0e9f628a8f66ef9a60 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 00:26:01 +0200 Subject: [PATCH 01/16] ci: create separate native jar tasks --- dist/java/build.gradle | 79 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 240dacc..3daebac 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -7,6 +7,75 @@ plugins { group = 'mp.code' version = '0.7.3' +tasks.register('windowsJar', Jar) { + outputs.upToDateWhen { false } + archiveClassifier = 'windows-x86_64' + from sourceSets.main.runtimeClasspath + from('artifacts') { + include('*.dll') + into('natives/') + } + doFirst { + if(!(new File('artifacts/codemp.dll').exists())) { + throw new GradleException("The required file does not exist!") + } + } +} + +tasks.register('macosJar', Jar) { + outputs.upToDateWhen { false } + archiveClassifier = 'osx-aarch_64' + from sourceSets.main.runtimeClasspath + from('artifacts') { + include('*.dylib') + into('natives/') + } + doFirst { + if(!(new File('artifacts/libcodemp.dylib').exists())) { + throw new GradleException("The required file does not exist!") + } + } +} + +tasks.register('linuxJar', Jar) { + outputs.upToDateWhen { false } + archiveClassifier = 'linux-x86_64' + from sourceSets.main.runtimeClasspath + from('artifacts') { + include('*.so') + into('natives/') + } + doFirst { + if(!(new File('artifacts/libcodemp.so').exists())) { + throw new GradleException("The required file does not exist! Maybe you need to `cargo build` the main library first?") + } + } +} + +configurations { + windowsJar { + canBeConsumed = true + canBeResolved = false + extendsFrom implementation, runtimeOnly + } + linuxJar { + canBeConsumed = true + canBeResolved = false + extendsFrom implementation, runtimeOnly + } + macosJar { + canBeConsumed = true + canBeResolved = false + extendsFrom implementation, runtimeOnly + } +} + +artifacts { + windowsJar(windowsJar) + macosJar(macosJar) + linuxJar(linuxJar) +} + java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 } @@ -29,17 +98,17 @@ tasks.register('cargoBuild', Exec) { commandLine 'cargo', 'build', '--release', '--features=java' } -jar.archiveClassifier = osdetector.classifier - def rustDir = projectDir.toPath() .parent .parent .resolve('target') .resolve('release') .toFile() -processResources { + +tasks.register('nativeBuild', Jar) { + archiveClassifier = osdetector.classifier dependsOn cargoBuild - outputs.upToDateWhen { false } // no caching + from sourceSets.main.runtimeClasspath from(rustDir) { include('*.dll') include('*.so') @@ -50,7 +119,7 @@ processResources { import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! signAllPublications() coordinates(project.group, rootProject.name, project.version) From d2635de37ba3a51cba46a2c815fc97c35bd92b5d Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 00:37:01 +0200 Subject: [PATCH 02/16] ci: new ci run Co-authored-by: alemi --- .github/workflows/java.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index fe9c6cd..e77c54c 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -23,26 +23,34 @@ jobs: filename: codemp.dll - runner: macos-14 target: darwin-arm64 - filename: codemp.dylib + filename: libcodemp.dylib steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: arduino/setup-protoc@v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + - run: cargo build --release --features=java + - uses: actions/upload-artifact@v4 + with: + name: codemp-java-${{ matrix.platform.target }} + path: target/release/${{ matrix.platform.filename }} + + publish: + needs: [build] + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + path: dist/java/artifacts + pattern: codemp-java-* - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '11' - uses: gradle/actions/setup-gradle@v4 with: - gradle-version: "8.10" # Quotes required to prevent YAML converting to number - - run: gradle build - working-directory: dist/java - - uses: actions/upload-artifact@v4 - with: - name: codemp-java-${{ matrix.platform.target }} - path: dist/java/build/libs + gradle-version: "8.10" - run: gradle publish working-directory: dist/java env: @@ -50,3 +58,4 @@ jobs: ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }} ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }} + From f7247d43520aa494e4aab5ded6a2aea1d4eb220b Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 00:42:43 +0200 Subject: [PATCH 03/16] ci: also run it on the test branch --- .github/workflows/java.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index e77c54c..58e8e63 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -4,6 +4,7 @@ on: push: branches: - stable + - fix/java-ci permissions: contents: read From 12f83769cb3a78558f1df98731b8c3d201ce8371 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 00:44:16 +0200 Subject: [PATCH 04/16] ci: specify runner Co-authored-by: alemi --- .github/workflows/java.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 58e8e63..06be36a 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -39,6 +39,7 @@ jobs: publish: needs: [build] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 From ede4b5eb58a2ddac84ea7279bd35274fc292d0b8 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 01:02:05 +0200 Subject: [PATCH 05/16] ci: run os task --- .github/workflows/java.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 06be36a..39245ea 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -53,6 +53,12 @@ jobs: - uses: gradle/actions/setup-gradle@v4 with: gradle-version: "8.10" + - run: gradle windowsJar + working-directory: dist/java + - run: gradle macosJar + working-directory: dist/java + - run: gradle linuxJar + working-directory: dist/java - run: gradle publish working-directory: dist/java env: From 611766a705db5554c78f427c663af618ac5eac9c Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 15 Oct 2024 14:56:41 +0200 Subject: [PATCH 06/16] debug: log artifacts downloaded --- .github/workflows/java.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 39245ea..31d32b4 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -46,6 +46,8 @@ jobs: with: path: dist/java/artifacts pattern: codemp-java-* + - run: tree + working-directory: dist/java - uses: actions/setup-java@v4 with: distribution: 'temurin' From 9f3177e22ebef242512eb5e9b7a2aa271dd45ace Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 15 Oct 2024 15:31:52 +0200 Subject: [PATCH 07/16] ci(java): merge multiple artifacts for gradle --- .github/workflows/java.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 31d32b4..b0d9c65 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -46,6 +46,7 @@ jobs: with: path: dist/java/artifacts pattern: codemp-java-* + merge-multiple: true - run: tree working-directory: dist/java - uses: actions/setup-java@v4 From 21b76767bd93d3b1e4edadda8d645b3edd82dc64 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 16:30:33 +0200 Subject: [PATCH 08/16] ci: attempt with publications --- dist/java/build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 3daebac..19cdf3f 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -117,6 +117,19 @@ tasks.register('nativeBuild', Jar) { } } +publishing { + publications { + mavenJava(MavenPublication) { + artifact jar + //artifact sourcesJar + //artifact javadocJar + artifact windowsJar + artifact linuxJar + artifact macosJar + } + } +} + import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! From b452cb822f0bb4e2e26fc20c4c82d0c640f20a9b Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 20:32:39 +0200 Subject: [PATCH 09/16] ci(java): attempt to configure java library correctly --- dist/java/build.gradle | 27 ++++++------------- .../code/exceptions/ControllerException.java | 4 +-- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 19cdf3f..c041398 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -70,14 +70,13 @@ configurations { } } -artifacts { - windowsJar(windowsJar) - macosJar(macosJar) - linuxJar(linuxJar) -} - java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 + artifacts { + windowsJar(windowsJar) + macosJar(macosJar) + linuxJar(linuxJar) + } } repositories { @@ -117,24 +116,14 @@ tasks.register('nativeBuild', Jar) { } } -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - //artifact sourcesJar - //artifact javadocJar - artifact windowsJar - artifact linuxJar - artifact macosJar - } - } -} - import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! signAllPublications() coordinates(project.group, rootProject.name, project.version) + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) pom { name = rootProject.name diff --git a/dist/java/src/mp/code/exceptions/ControllerException.java b/dist/java/src/mp/code/exceptions/ControllerException.java index 2061478..f5462d9 100644 --- a/dist/java/src/mp/code/exceptions/ControllerException.java +++ b/dist/java/src/mp/code/exceptions/ControllerException.java @@ -2,8 +2,8 @@ package mp.code.exceptions; /** * An exception that may occur when a {@link mp.code.BufferController} or - * a {@link mp.code.CursorController} perform an illegal operation. - * It may also occur as a result of {@link mp.code.Workspace#event()}. + * a {@link mp.code.CursorController} or {@link mp.code.Workspace} (in the + * receiver part) perform an illegal operation. */ public abstract class ControllerException extends Exception { From 2e583028a6607c3d87310141200c247e5fafa355 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 15 Oct 2024 21:55:23 +0200 Subject: [PATCH 10/16] docs: added missing javadocs --- dist/java/src/mp/code/BufferController.java | 3 +++ dist/java/src/mp/code/CursorController.java | 9 ++++++--- dist/java/src/mp/code/Extensions.java | 2 +- dist/java/src/mp/code/Workspace.java | 2 ++ dist/java/src/mp/code/data/TextChange.java | 3 --- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dist/java/src/mp/code/BufferController.java b/dist/java/src/mp/code/BufferController.java index 99570fa..fe1becd 100644 --- a/dist/java/src/mp/code/BufferController.java +++ b/dist/java/src/mp/code/BufferController.java @@ -70,6 +70,7 @@ public final class BufferController { /** * Tries to send a {@link TextChange} update. + * @param change the update to send * @throws ControllerException if the controller was stopped */ public void send(TextChange change) throws ControllerException { @@ -81,6 +82,8 @@ public final class BufferController { /** * Registers a callback to be invoked whenever a {@link BufferUpdate} occurs. * This will not work unless a Java thread has been dedicated to the event loop. + * @param cb a {@link Consumer} that receives the controller when the change occurs; + * you should probably spawn a new thread in here, to avoid deadlocking * @see Extensions#drive(boolean) */ public void callback(Consumer cb) { diff --git a/dist/java/src/mp/code/CursorController.java b/dist/java/src/mp/code/CursorController.java index 6c2cae1..2a0f5ee 100644 --- a/dist/java/src/mp/code/CursorController.java +++ b/dist/java/src/mp/code/CursorController.java @@ -43,14 +43,15 @@ public final class CursorController { return recv(this.ptr); } - private static native void send(long self, Selection cursor) throws ControllerException; + private static native void send(long self, Selection selection) throws ControllerException; /** * Tries to send a {@link Selection} update. + * @param selection the update to send * @throws ControllerException if the controller was stopped */ - public void send(Selection cursor) throws ControllerException { - send(this.ptr, cursor); + public void send(Selection selection) throws ControllerException { + send(this.ptr, selection); } private static native void callback(long self, Consumer cb); @@ -58,6 +59,8 @@ public final class CursorController { /** * Registers a callback to be invoked whenever a {@link Cursor} update occurs. * This will not work unless a Java thread has been dedicated to the event loop. + * @param cb a {@link Consumer} that receives the controller when the change occurs; + * you should probably spawn a new thread in here, to avoid deadlocking * @see Extensions#drive(boolean) */ public void callback(Consumer cb) { diff --git a/dist/java/src/mp/code/Extensions.java b/dist/java/src/mp/code/Extensions.java index ff4a1b7..327e0f4 100644 --- a/dist/java/src/mp/code/Extensions.java +++ b/dist/java/src/mp/code/Extensions.java @@ -33,7 +33,7 @@ public final class Extensions { *

* You may alternatively call this with true, in a separate and dedicated Java thread; * it will remain active in the background and act as event loop. Assign it like this: - *

new Thread(() -> Extensions.drive(true)).start();

+ *

new Thread(() -> Extensions.drive(true)).start();

* @param block true if it should use the current thread */ public static native void drive(boolean block); diff --git a/dist/java/src/mp/code/Workspace.java b/dist/java/src/mp/code/Workspace.java index 10ae3b1..da9cce7 100644 --- a/dist/java/src/mp/code/Workspace.java +++ b/dist/java/src/mp/code/Workspace.java @@ -196,6 +196,8 @@ public final class Workspace { /** * Registers a callback to be invoked whenever a new {@link Event} is ready to be received. * This will not work unless a Java thread has been dedicated to the event loop. + * @param cb a {@link Consumer} that receives the controller when the change occurs; + * you should probably spawn a new thread in here, to avoid deadlocking * @see Extensions#drive(boolean) */ public void callback(Consumer cb) { diff --git a/dist/java/src/mp/code/data/TextChange.java b/dist/java/src/mp/code/data/TextChange.java index 3c0a0f9..5d13ea9 100644 --- a/dist/java/src/mp/code/data/TextChange.java +++ b/dist/java/src/mp/code/data/TextChange.java @@ -3,9 +3,6 @@ package mp.code.data; import lombok.EqualsAndHashCode; import lombok.RequiredArgsConstructor; import lombok.ToString; -import mp.code.Extensions; - -import java.util.OptionalLong; /** * A data class holding information about a text change. From 5dcfd341d3c87d73777a804a84e04223bc56540e Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 16 Oct 2024 01:07:34 +0200 Subject: [PATCH 11/16] ci(java): try to use publications --- .gitignore | 1 + dist/java/build.gradle | 49 +++++++++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5a6fc9f..dc39325 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ dist/java/.gradle/ dist/java/.project dist/java/.settings/ dist/java/bin/ +dist/java/artifacts/ # intellij insists on creating the wrapper every time even if it's not strictly necessary dist/java/gradle/ diff --git a/dist/java/build.gradle b/dist/java/build.gradle index c041398..0058b24 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -52,6 +52,16 @@ tasks.register('linuxJar', Jar) { } } +tasks.register('multiplatformJar', Jar) { + outputs.upToDateWhen { false } + archiveClassifier = 'all' + from sourceSets.main.runtimeClasspath + from('artifacts') { + include('*') + into('natives/') + } +} + configurations { windowsJar { canBeConsumed = true @@ -68,15 +78,27 @@ configurations { canBeResolved = false extendsFrom implementation, runtimeOnly } + multiplatformJar { + canBeConsumed = true + canBeResolved = false + extendsFrom implementation, runtimeOnly + } } java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 - artifacts { - windowsJar(windowsJar) - macosJar(macosJar) - linuxJar(linuxJar) - } + withSourcesJar() + withJavadocJar() +} + +artifacts { + archives jar + archives sourcesJar + archives javadocJar + windowsJar(windowsJar) + macosJar(macosJar) + linuxJar(linuxJar) + multiplatformJar(multiplatformJar) } repositories { @@ -116,14 +138,25 @@ tasks.register('nativeBuild', Jar) { } } +publishing { + publications { + mavenJava(MavenPublication) { + artifact jar + artifact sourcesJar + artifact javadocJar + artifact windowsJar + artifact linuxJar + artifact macosJar + artifact multiplatformJar + } + } +} + import com.vanniktech.maven.publish.SonatypeHost -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! signAllPublications() coordinates(project.group, rootProject.name, project.version) - configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) pom { name = rootProject.name From d10b34eaf91916bf036ead1be9e8f7e718bfc877 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 16 Oct 2024 01:44:44 +0200 Subject: [PATCH 12/16] ci: try to sign manually --- dist/java/build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 0058b24..9e63738 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java-library' + id 'signing' id "com.vanniktech.maven.publish" version "0.29.0" id 'com.google.osdetector' version '1.7.3' } @@ -152,10 +153,14 @@ publishing { } } +signing { + sign publishing.publications.mavenJava +} + import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! - signAllPublications() + //signAllPublications() coordinates(project.group, rootProject.name, project.version) pom { From 3b653e82057a4fd8dac2261c6a0c7a54a242685d Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 16 Oct 2024 15:21:20 +0200 Subject: [PATCH 13/16] ci(java): try using the base plugin --- dist/java/build.gradle | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 9e63738..69d4097 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -1,7 +1,6 @@ plugins { id 'java-library' - id 'signing' - id "com.vanniktech.maven.publish" version "0.29.0" + id "com.vanniktech.maven.publish.base" version "0.30.0" id 'com.google.osdetector' version '1.7.3' } @@ -153,14 +152,10 @@ publishing { } } -signing { - sign publishing.publications.mavenJava -} - import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! - //signAllPublications() + signAllPublications() coordinates(project.group, rootProject.name, project.version) pom { From 4c1122cf6a40aa9fe82d865792df8d106d4310f0 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 16 Oct 2024 15:40:44 +0200 Subject: [PATCH 14/16] chore: restore auto-publish, don't run full ci on branch --- .github/workflows/java.yml | 1 - dist/java/build.gradle | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index b0d9c65..d5fdfcf 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -4,7 +4,6 @@ on: push: branches: - stable - - fix/java-ci permissions: contents: read diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 69d4097..7615946 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -154,7 +154,7 @@ publishing { import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true) signAllPublications() coordinates(project.group, rootProject.name, project.version) From a159a97724083fd46e885a47029d53ca3c65cbe1 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 16 Oct 2024 15:51:51 +0200 Subject: [PATCH 15/16] chore: remove unneeded build steps Co-authored-by: alemi.dev --- .github/workflows/java.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index d5fdfcf..ab26021 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -55,11 +55,6 @@ jobs: - uses: gradle/actions/setup-gradle@v4 with: gradle-version: "8.10" - - run: gradle windowsJar - working-directory: dist/java - - run: gradle macosJar - working-directory: dist/java - - run: gradle linuxJar working-directory: dist/java - run: gradle publish working-directory: dist/java From 3068773d9610b2fa429b6383f53995f4fa459864 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 16 Oct 2024 16:05:38 +0200 Subject: [PATCH 16/16] docs: update Java README --- dist/README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dist/README.md b/dist/README.md index 317e696..66a935b 100644 --- a/dist/README.md +++ b/dist/README.md @@ -33,14 +33,20 @@ Thus, we also provide pre-made Java glue code, wrapping all native calls and def The Java bindings have no known major quirk. However, here are a list of facts that are useful to know when developing with these: -* Memory management is entirely delegated to the JVM's garbage collector. - * A more elegant solution than `Object.finalize()`, who is deprecated in newer Java versions, may be coming eventually. +* Memory management is entirely delegated to the JVM's garbage collector using the `Cleaner` API. + * Because of this, we require Java 11 as minimum version: `Cleaner` was added in version 9. This should not be a problem, as IDEs tend to run on recent versions, but if there is actual demand for it we may add a Java 8-friendly version using `Object.finalize()` (which is deprecated in modern JDKs). * Exceptions coming from the native side have generally been made checked to imitate Rust's philosophy with `Result`. * `JNIException`s are however unchecked: there is nothing you can do to recover from them, as they usually represent a severe error in the glue code. If they arise, it's probably a bug. ### Using -`codemp` **will be available soon** as an artifact on [Maven Central](https://mvnrepository.com) +`codemp` is available on [Maven Central](https://central.sonatype.com/artifact/mp.code/codemp), with each officially supported OS as an archive classifier. ### Building -This is a [Gradle](https://gradle.org/) project: building requires having both Gradle and Cargo installed, as well as the JDK (any non-abandoned version). -Once you have all the requirements, building is as simple as running `gradle build`: the output is going to be a JAR under `build/libs`, which you can import into your classpath with your IDE of choice. +> [!NOTE] +> The following instructions assume `dist/java` as current working directory. + +This is a [Gradle](https://gradle.org/) project, so you must have install `gradle` (as well as JDK 11 or higher) in order to build it. +- You can build a JAR without bundling the native library with `gradle build`. +- Otherwise, you can compile the project for your current OS and create a JAR that bundles the resulting binary with `gradle nativeBuild`; do note that this second way of building also requires Cargo and the relevant Rust toolchain. + +In both cases, the output is going to be a JAR under `build/libs`, which you can import into your classpath with your IDE of choice.