From 581419bfed4ecbb4bfec5f5d5f31395ed7227fec Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 01:58:54 +0200 Subject: [PATCH 01/21] ci: ci java branch --- .github/workflows/java.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index d52a5da..a95e1d4 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -4,6 +4,7 @@ on: push: branches: - stable + - java-ci permissions: contents: read From d2b5e413c53d940f996517cbf5faeaecc180fcdf Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 02:40:55 +0200 Subject: [PATCH 02/21] ci(java): basic gradle publish setup --- .github/workflows/java.yml | 6 +++ dist/java/build.gradle | 58 +++++++++++++++------------ dist/java/src/mp/code/Extensions.java | 12 ++++-- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index a95e1d4..af6314a 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -40,5 +40,11 @@ jobs: with: name: codemp-java-${{ matrix.platform.target }} path: dist/java/build/libs + - run: gradle publish + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + MAVEN_CENTRAL_GPG_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }} + MAVEN_CENTRAL_GPG_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }} # TODO add a publish step to maven central diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 9496a40..2abb0fb 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -1,12 +1,12 @@ plugins { id 'java-library' id 'maven-publish' + id 'signing' id 'com.github.johnrengelman.shadow' version '8.1.1' - id 'com.palantir.git-version' version '3.1.0' } group = 'mp.code' -version = versionDetails().lastTag.substring(1) +version = '0.0.1-SNAPSHOT' java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 @@ -61,43 +61,49 @@ build.finalizedBy shadowJar publishing { publications { mavenJava(MavenPublication) { - artifactId = 'my-library' + artifactId = rootProject.name + version = project.version from components.java - versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') - } - usage('java-runtime') { - fromResolutionResult() - } - } pom { - name = 'My Library' - description = 'A concise description of my library' - url = 'http://www.example.com/library' - properties = [ - myProp: "value", - "prop.with.dots": "anotherValue" - ] + name = 'codemp' + description = 'A collaborative editor plugin ecosystem' + url = 'https://code.mp' licenses { license { - name = 'The Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + name = 'The GNU General Public License v3.0' + url = 'https://www.gnu.org/licenses/gpl-3.0.txt' } } developers { developer { - id = 'johnd' - name = 'John Doe' - email = 'john.doe@example.com' + id = 'zaaarf' + email = 'zaaarf@codemp.dev' } } scm { - connection = 'scm:git:git://example.com/my-library.git' - developerConnection = 'scm:git:ssh://example.com/my-library.git' - url = 'http://example.com/my-library/' + connection = 'scm:git:git://github.com/hexedtech/codemp.git' + developerConnection = 'scm:git:ssh://github.com/hexedtech/codemp.git' + url = 'https://github.com/hexedtech/codemp/' } } } } + repositories { + maven { + name = "centralManualTesting" + url "https://central.sonatype.com/api/v1/publisher/deployments/download/" + credentials { + username = System.getenv('MAVEN_CENTRAL_USERNAME') + password = System.getenv('MAVEN_CENTRAL_PASSWORD') + } + } + mavenCentral() + } } + +signing { + def signingKey = System.getenv('MAVEN_CENTRAL_GPG_SECRET_KEY') + def signingPassword = System.getenv('MAVEN_CENTRAL_GPG_PASSWORD') + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications.mavenJava +} \ No newline at end of file diff --git a/dist/java/src/mp/code/Extensions.java b/dist/java/src/mp/code/Extensions.java index c6cddfa..34c2984 100644 --- a/dist/java/src/mp/code/Extensions.java +++ b/dist/java/src/mp/code/Extensions.java @@ -41,10 +41,16 @@ public final class Extensions { static synchronized void loadLibraryIfNotPresent() { if(loaded) return; try { - String filename = System.getProperty("os.name").startsWith("Windows") - ? "/natives/codemp.dll" - : "/natives/libcodemp.so"; + String os = System.getProperty("os.name").toLowerCase(); + + String filename; + if(os.startsWith("windows")) { + filename = "/natives/codemp.dll"; + } else if(os.startsWith("mac")) { + filename = "/natives/libcodemp.dylib";; + } else filename = "/natives/libcodemp.so"; cz.adamh.utils.NativeUtils.loadLibraryFromJar(filename); + loaded = true; } catch(IOException e) { throw new RuntimeException(e); From b65dc1ca45fa050356cdb6eec484c9e54d210464 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 02:44:19 +0200 Subject: [PATCH 03/21] ci(java): run gradle publish in right wd --- .github/workflows/java.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index af6314a..5e5de1a 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -41,6 +41,7 @@ jobs: name: codemp-java-${{ matrix.platform.target }} path: dist/java/build/libs - run: gradle publish + working-directory: dist/java env: MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} From 24ef0db72700afc5cf01c1d4833c805695ca8314 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 04:09:51 +0200 Subject: [PATCH 04/21] ci(java): try with gradle-maven-publish-plugin --- .github/workflows/java.yml | 12 +++-- dist/java/build.gradle | 89 ++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 58 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 5e5de1a..67ecbe4 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -40,12 +40,10 @@ jobs: with: name: codemp-java-${{ matrix.platform.target }} path: dist/java/build/libs - - run: gradle publish + - run: gradle publishAllPublicationsToMavenCentralRepository working-directory: dist/java env: - MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} - MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} - MAVEN_CENTRAL_GPG_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }} - MAVEN_CENTRAL_GPG_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }} - - # TODO add a publish step to maven central + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + 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 }} diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 2abb0fb..09ea44b 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java-library' id 'maven-publish' - id 'signing' + id "com.vanniktech.maven.publish" version "0.29.0" id 'com.github.johnrengelman.shadow' version '8.1.1' } @@ -12,6 +12,42 @@ java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 } +import com.vanniktech.maven.publish.SonatypeHost + +mavenPublishing { + publishToMavenCentral(SonatypeHost.DEFAULT) + // publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + + signAllPublications() + + coordinates("mp.code", "codemp", "0.0.1-SNAPSHOT") + + pom { + name = "codemp" + description = "a collaborative editor plugin ecosystem" + inceptionYear = "2022" + url = "https://code.mp/" + licenses { + license { + name = "The GNU General Public License v3.0" + url = "https://www.gnu.org/licenses/gpl-3.0.txt" + distribution = "https://www.gnu.org/licenses/gpl-3.0.txt" + } + } + developers { + developer { + id = "zaaarf" + name = "zaaarf" + } + } + scm { + url = "https://github.com/hexedtech/codemp/" + connection = "scm:git:git://github.com/hexedtech/codemp.git" + developerConnection = "scm:git:ssh://git@github.com/hexedtech/codemp.git" + } + } +} + repositories { mavenCentral() maven { url 'https://jitpack.io' } @@ -40,6 +76,7 @@ def rustDir = projectDir.toPath() .resolve('target') .resolve('release') .toFile() + processResources { outputs.upToDateWhen { false } // no caching from(rustDir) { @@ -57,53 +94,3 @@ tasks.register('cargoBuild', Exec) { processResources.dependsOn cargoBuild build.finalizedBy shadowJar - -publishing { - publications { - mavenJava(MavenPublication) { - artifactId = rootProject.name - version = project.version - from components.java - pom { - name = 'codemp' - description = 'A collaborative editor plugin ecosystem' - url = 'https://code.mp' - licenses { - license { - name = 'The GNU General Public License v3.0' - url = 'https://www.gnu.org/licenses/gpl-3.0.txt' - } - } - developers { - developer { - id = 'zaaarf' - email = 'zaaarf@codemp.dev' - } - } - scm { - connection = 'scm:git:git://github.com/hexedtech/codemp.git' - developerConnection = 'scm:git:ssh://github.com/hexedtech/codemp.git' - url = 'https://github.com/hexedtech/codemp/' - } - } - } - } - repositories { - maven { - name = "centralManualTesting" - url "https://central.sonatype.com/api/v1/publisher/deployments/download/" - credentials { - username = System.getenv('MAVEN_CENTRAL_USERNAME') - password = System.getenv('MAVEN_CENTRAL_PASSWORD') - } - } - mavenCentral() - } -} - -signing { - def signingKey = System.getenv('MAVEN_CENTRAL_GPG_SECRET_KEY') - def signingPassword = System.getenv('MAVEN_CENTRAL_GPG_PASSWORD') - useInMemoryPgpKeys(signingKey, signingPassword) - sign publishing.publications.mavenJava -} \ No newline at end of file From 7693e5225407f2ef893ac648b80411902cc12d75 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 04:16:13 +0200 Subject: [PATCH 05/21] ci(java): try other portal not sure which one is central and which one is OSSRH? --- dist/java/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 09ea44b..86b2663 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -15,8 +15,8 @@ java { import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - publishToMavenCentral(SonatypeHost.DEFAULT) - // publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + // publishToMavenCentral(SonatypeHost.DEFAULT) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) signAllPublications() From 1ff2b318387277702d0e9f37e130876274320969 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 04:20:40 +0200 Subject: [PATCH 06/21] ci(java): try publish on snapshot repos --- dist/java/build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 86b2663..c00201b 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -15,8 +15,9 @@ java { import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - // publishToMavenCentral(SonatypeHost.DEFAULT) - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + publishToMavenCentral(SonatypeHost.S01) // for snapshots + // publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) // central repository + // publishToMavenCentral(SonatypeHost.DEFAULT) // ???? signAllPublications() From c329fa49cb1fa28c60a05f3a4823b921ce55109e Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 04:34:14 +0200 Subject: [PATCH 07/21] ci(java): does publishing to central work? packages take some time to appear, 10~30 mins i read? so idk ill find out tomorrow if this worked --- .github/workflows/java.yml | 2 +- dist/java/build.gradle | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 67ecbe4..de9f339 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -40,7 +40,7 @@ jobs: with: name: codemp-java-${{ matrix.platform.target }} path: dist/java/build/libs - - run: gradle publishAllPublicationsToMavenCentralRepository + - run: gradle publish working-directory: dist/java env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} diff --git a/dist/java/build.gradle b/dist/java/build.gradle index c00201b..35ca37a 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -6,7 +6,7 @@ plugins { } group = 'mp.code' -version = '0.0.1-SNAPSHOT' +version = '0.0.1' java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 @@ -15,13 +15,13 @@ java { import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - publishToMavenCentral(SonatypeHost.S01) // for snapshots - // publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) // central repository + // publishToMavenCentral(SonatypeHost.S01) // for snapshots + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) // central repository // publishToMavenCentral(SonatypeHost.DEFAULT) // ???? signAllPublications() - coordinates("mp.code", "codemp", "0.0.1-SNAPSHOT") + coordinates("mp.code", "codemp", "0.0.1") pom { name = "codemp" From 35f3604dcc1f44e453b937d3fde8fd9657336cf3 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 04:37:22 +0200 Subject: [PATCH 08/21] docs: add maven badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 487eeca..9bbd34b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![Crates.io Version](https://img.shields.io/crates/v/codemp)](https://crates.io/crates/codemp) [![NPM Version](https://img.shields.io/npm/v/codemp)](https://npmjs.org/package/codemp) [![PyPI Version](https://img.shields.io/pypi/v/codemp)](https://pypi.org/project/codemp) +[![Maven Central Version](https://img.shields.io/maven-central/v/mp.code/codemp)](https://central.sonatype.com/artifact/mp.code/codemp) [![LuaRocks Version](https://img.shields.io/luarocks/v/alemi/codemp)](https://luarocks.org/modules/alemi/codemp) > `codemp` is a **collaborative** text editing solution to work remotely. From 92a48db7509507a8d5706141adfccb0d2e75c27b Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 04:38:24 +0200 Subject: [PATCH 09/21] docs: updated readme.md with maven link --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9bbd34b..f319c4f 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,10 @@ Just `cargo add codemp` and check the docs for some examples. ### From supported languages We provide first-class bindings for: - - [![JavaScript](https://github.com/hexedtech/codemp/actions/workflows/javascript.yml/badge.svg)](./dist/README.md#javascript) available from `npm` as [`codemp`](https://npmjs.org/package/codemp) - - [![Python](https://github.com/hexedtech/codemp/actions/workflows/python.yml/badge.svg)](./dist/README.md#python) available from `PyPI` as [`codemp`](https://pypi.org/project/codemp) - - [![Lua](https://github.com/hexedtech/codemp/actions/workflows/lua.yml/badge.svg)](./dist/README.md#lua) available from `LuaRocks` as [`codemp`](https://luarocks.org/modules/alemi/codemp) - - [![Java](https://github.com/hexedtech/codemp/actions/workflows/java.yml/badge.svg)](./dist/README.md#java) available on `MavenCentral` **SOON** + - [![JavaScript](https://github.com/hexedtech/codemp/actions/workflows/javascript.yml/badge.svg)](./dist/README.md#javascript) available from **npm** as [`codemp`](https://npmjs.org/package/codemp) + - [![Python](https://github.com/hexedtech/codemp/actions/workflows/python.yml/badge.svg)](./dist/README.md#python) available from **PyPI** as [`codemp`](https://pypi.org/project/codemp) + - [![Lua](https://github.com/hexedtech/codemp/actions/workflows/lua.yml/badge.svg)](./dist/README.md#lua) available from **LuaRocks** as [`codemp`](https://luarocks.org/modules/alemi/codemp) + - [![Java](https://github.com/hexedtech/codemp/actions/workflows/java.yml/badge.svg)](./dist/README.md#java) available on **MavenCentral** as [`codemp`](https://central.sonatype.com/artifact/mp.code/codemp) As a design philosophy, our binding APIs attempt to perfectly mimic their Rust counterparts, so the main documentation can still be referenced as source of truth. Refer to specific language documentation for specifics, differences and quirks. From a26f57d249538c87fd896a03d931644720cd0520 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 13:21:13 +0200 Subject: [PATCH 10/21] ci(java): require java 11 --- .github/workflows/java.yml | 4 ++++ dist/java/build.gradle | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index de9f339..8b9552a 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -31,6 +31,10 @@ jobs: - uses: arduino/setup-protoc@v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + - 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 diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 35ca37a..f803a44 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -9,36 +9,36 @@ group = 'mp.code' version = '0.0.1' java { - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 } import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - // publishToMavenCentral(SonatypeHost.S01) // for snapshots + //publishToMavenCentral(SonatypeHost.S01) // for snapshots publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) // central repository - // publishToMavenCentral(SonatypeHost.DEFAULT) // ???? + // publishToMavenCentral(SonatypeHost.DEFAULT) // default signAllPublications() - coordinates("mp.code", "codemp", "0.0.1") + coordinates(project.group, rootProject.name, project.version) pom { - name = "codemp" - description = "a collaborative editor plugin ecosystem" + name = rootProject.name + description = "A collaborative editor plugin ecosystem" inceptionYear = "2022" url = "https://code.mp/" licenses { license { name = "The GNU General Public License v3.0" url = "https://www.gnu.org/licenses/gpl-3.0.txt" - distribution = "https://www.gnu.org/licenses/gpl-3.0.txt" } } developers { developer { id = "zaaarf" name = "zaaarf" + email = "zaaarf@codemp.dev" } } scm { From 3e68897f5f9dd4708c8f7d19252dfcf6e3ca16a8 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 13:57:07 +0200 Subject: [PATCH 11/21] ci(java): os classifier --- dist/java/build.gradle | 103 +++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index f803a44..8644483 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -1,8 +1,10 @@ +import com.vanniktech.maven.publish.SonatypeHost + plugins { id 'java-library' - id 'maven-publish' id "com.vanniktech.maven.publish" version "0.29.0" id 'com.github.johnrengelman.shadow' version '8.1.1' + id 'com.google.osdetector' version '1.7.3' } group = 'mp.code' @@ -10,9 +12,57 @@ version = '0.0.1' java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 + withSourcesJar() + withJavadocJar() } -import com.vanniktech.maven.publish.SonatypeHost +repositories { + mavenCentral() + maven { url 'https://jitpack.io' } +} + +sourceSets { + main.java.srcDirs = ['src/'] +} + +dependencies { + implementation 'com.github.adamheinrich:native-utils:master-SNAPSHOT' + compileOnly 'org.projectlombok:lombok:1.18.34' + annotationProcessor 'org.projectlombok:lombok:1.18.34' +} + +shadowJar { + jar.archiveClassifier = archiveClassifier = osdetector.classifier + dependencies { + include(dependency('com.github.adamheinrich:native-utils:master-SNAPSHOT')) + } +} + +def rustDir = projectDir.toPath() + .parent + .parent + .resolve('target') + .resolve('release') + .toFile() + +processResources { + outputs.upToDateWhen { false } // no caching + from(rustDir) { + include('*.dll') + include('*.so') + include('*dylib') + into('natives/') + } +} + +tasks.register('cargoBuild', Exec) { + workingDir '.' + commandLine 'cargo', 'build', '--release', '--features=java' +} + +processResources.dependsOn cargoBuild +build.finalizedBy shadowJar + mavenPublishing { //publishToMavenCentral(SonatypeHost.S01) // for snapshots @@ -47,51 +97,4 @@ mavenPublishing { developerConnection = "scm:git:ssh://git@github.com/hexedtech/codemp.git" } } -} - -repositories { - mavenCentral() - maven { url 'https://jitpack.io' } -} - -sourceSets { - main.java.srcDirs = ['src/'] -} - -dependencies { - implementation 'com.github.adamheinrich:native-utils:master-SNAPSHOT' - compileOnly 'org.projectlombok:lombok:1.18.34' - annotationProcessor 'org.projectlombok:lombok:1.18.34' -} - -shadowJar { - archiveClassifier.set('') - dependencies { - include(dependency('com.github.adamheinrich:native-utils:master-SNAPSHOT')) - } -} - -def rustDir = projectDir.toPath() - .parent - .parent - .resolve('target') - .resolve('release') - .toFile() - -processResources { - outputs.upToDateWhen { false } // no caching - from(rustDir) { - include('*.dll') - include('*.so') - include('*dylib') - into('natives/') - } -} - -tasks.register('cargoBuild', Exec) { - workingDir '.' - commandLine 'cargo', 'build', '--release', '--features=java' -} - -processResources.dependsOn cargoBuild -build.finalizedBy shadowJar +} \ No newline at end of file From 062f10b68aa8f8284aa4840fb3cdbe5379895e50 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 14:11:02 +0200 Subject: [PATCH 12/21] ci(java): produce artifact with no classifier without native --- dist/java/build.gradle | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 8644483..75e71fd 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -31,11 +31,9 @@ dependencies { annotationProcessor 'org.projectlombok:lombok:1.18.34' } -shadowJar { - jar.archiveClassifier = archiveClassifier = osdetector.classifier - dependencies { - include(dependency('com.github.adamheinrich:native-utils:master-SNAPSHOT')) - } +tasks.register('cargoBuild', Exec) { + workingDir '.' + commandLine 'cargo', 'build', '--release', '--features=java' } def rustDir = projectDir.toPath() @@ -44,8 +42,8 @@ def rustDir = projectDir.toPath() .resolve('target') .resolve('release') .toFile() - -processResources { +shadowJar { + dependsOn cargoBuild outputs.upToDateWhen { false } // no caching from(rustDir) { include('*.dll') @@ -53,17 +51,15 @@ processResources { include('*dylib') into('natives/') } + + archiveClassifier = osdetector.classifier + dependencies { + include(dependency('com.github.adamheinrich:native-utils:master-SNAPSHOT')) + } } -tasks.register('cargoBuild', Exec) { - workingDir '.' - commandLine 'cargo', 'build', '--release', '--features=java' -} - -processResources.dependsOn cargoBuild build.finalizedBy shadowJar - mavenPublishing { //publishToMavenCentral(SonatypeHost.S01) // for snapshots publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) // central repository From bab4fa6ea30dca8e5b7515e934c04899d1e7c021 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 14:14:29 +0200 Subject: [PATCH 13/21] ci(java): skip generation of src and javadoc jar --- dist/java/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 75e71fd..12abedf 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -12,8 +12,6 @@ version = '0.0.1' java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 - withSourcesJar() - withJavadocJar() } repositories { From 64c272f0af59dba8f19f092c5134cdbe9eb9fac3 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 14:54:54 +0200 Subject: [PATCH 14/21] chore(java): dropped shadow, NativeUtils as class file --- dist/java/build.gradle | 25 +-- dist/java/src/mp/code/BufferController.java | 2 +- dist/java/src/mp/code/Client.java | 2 +- dist/java/src/mp/code/CursorController.java | 2 +- dist/java/src/mp/code/Extensions.java | 22 +-- dist/java/src/mp/code/NativeUtils.java | 160 ++++++++++++++++++++ dist/java/src/mp/code/Workspace.java | 2 +- 7 files changed, 171 insertions(+), 44 deletions(-) create mode 100644 dist/java/src/mp/code/NativeUtils.java diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 12abedf..1cdc1d2 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -1,14 +1,11 @@ -import com.vanniktech.maven.publish.SonatypeHost - plugins { id 'java-library' id "com.vanniktech.maven.publish" version "0.29.0" - id 'com.github.johnrengelman.shadow' version '8.1.1' id 'com.google.osdetector' version '1.7.3' } group = 'mp.code' -version = '0.0.1' +version = '0.0.2' java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 @@ -16,7 +13,6 @@ java { repositories { mavenCentral() - maven { url 'https://jitpack.io' } } sourceSets { @@ -24,7 +20,6 @@ sourceSets { } dependencies { - implementation 'com.github.adamheinrich:native-utils:master-SNAPSHOT' compileOnly 'org.projectlombok:lombok:1.18.34' annotationProcessor 'org.projectlombok:lombok:1.18.34' } @@ -34,13 +29,15 @@ 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() -shadowJar { +processResources { dependsOn cargoBuild outputs.upToDateWhen { false } // no caching from(rustDir) { @@ -49,22 +46,12 @@ shadowJar { include('*dylib') into('natives/') } - - archiveClassifier = osdetector.classifier - dependencies { - include(dependency('com.github.adamheinrich:native-utils:master-SNAPSHOT')) - } } -build.finalizedBy shadowJar - +import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - //publishToMavenCentral(SonatypeHost.S01) // for snapshots - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) // central repository - // publishToMavenCentral(SonatypeHost.DEFAULT) // default - + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true) signAllPublications() - coordinates(project.group, rootProject.name, project.version) pom { diff --git a/dist/java/src/mp/code/BufferController.java b/dist/java/src/mp/code/BufferController.java index df08a8b..220a339 100644 --- a/dist/java/src/mp/code/BufferController.java +++ b/dist/java/src/mp/code/BufferController.java @@ -122,6 +122,6 @@ public final class BufferController { } static { - Extensions.loadLibraryIfNotPresent(); + NativeUtils.loadLibraryIfNeeded(); } } diff --git a/dist/java/src/mp/code/Client.java b/dist/java/src/mp/code/Client.java index e9b715e..1d20a92 100644 --- a/dist/java/src/mp/code/Client.java +++ b/dist/java/src/mp/code/Client.java @@ -152,6 +152,6 @@ public final class Client { } static { - Extensions.loadLibraryIfNotPresent(); + NativeUtils.loadLibraryIfNeeded(); } } diff --git a/dist/java/src/mp/code/CursorController.java b/dist/java/src/mp/code/CursorController.java index 2b1f36d..7d2ce6a 100644 --- a/dist/java/src/mp/code/CursorController.java +++ b/dist/java/src/mp/code/CursorController.java @@ -99,6 +99,6 @@ public final class CursorController { } static { - Extensions.loadLibraryIfNotPresent(); + NativeUtils.loadLibraryIfNeeded(); } } diff --git a/dist/java/src/mp/code/Extensions.java b/dist/java/src/mp/code/Extensions.java index 34c2984..6bd12a3 100644 --- a/dist/java/src/mp/code/Extensions.java +++ b/dist/java/src/mp/code/Extensions.java @@ -37,27 +37,7 @@ public final class Extensions { */ public static native void setupTracing(String path, boolean debug); - private static boolean loaded = false; - static synchronized void loadLibraryIfNotPresent() { - if(loaded) return; - try { - String os = System.getProperty("os.name").toLowerCase(); - - String filename; - if(os.startsWith("windows")) { - filename = "/natives/codemp.dll"; - } else if(os.startsWith("mac")) { - filename = "/natives/libcodemp.dylib";; - } else filename = "/natives/libcodemp.so"; - cz.adamh.utils.NativeUtils.loadLibraryFromJar(filename); - - loaded = true; - } catch(IOException e) { - throw new RuntimeException(e); - } - } - static { - Extensions.loadLibraryIfNotPresent(); + NativeUtils.loadLibraryIfNeeded(); } } diff --git a/dist/java/src/mp/code/NativeUtils.java b/dist/java/src/mp/code/NativeUtils.java new file mode 100644 index 0000000..9253d7d --- /dev/null +++ b/dist/java/src/mp/code/NativeUtils.java @@ -0,0 +1,160 @@ +/* + * Class NativeUtils is published under the The MIT License: + * + * Copyright (c) 2012 Adam Heinrich + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package mp.code; + +import java.io.*; +import java.nio.file.FileSystemNotFoundException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.ProviderNotFoundException; +import java.nio.file.StandardCopyOption; +import java.util.Objects; + +/** + * A simple library class which helps with loading dynamic libraries stored in the + * JAR archive. These libraries usually contain implementation of some methods in + * native code (using JNI - Java Native Interface). + * @see http://adamheinrich.com/blog/2012/how-to-load-native-jni-library-from-jar + * @see https://github.com/adamheinrich/native-utils + */ +class NativeUtils { + + /** + * The minimum length a prefix for a file has to have according to {@link File#createTempFile(String, String)}}. + */ + private static final int MIN_PREFIX_LENGTH = 3; + + /** + * Prefix of the temporary folder where the native is stored. + */ + public static final String NATIVE_FOLDER_PATH_PREFIX = "nativeutils"; + + /** + * Temporary directory which will contain the DLLs. + */ + private static File temporaryDir; + + /** + * Private constructor - this class will never be instanced + */ + private NativeUtils() {} + + /** + * Loads library from current JAR archive. + * The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after + * exiting. + * Method uses String as filename because the pathname is "abstract", not system-dependent. + * @param path The path of file inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext + * @throws IOException If temporary file creation or read/write operation fails + * @throws IllegalArgumentException If source file (param path) does not exist + * @throws IllegalArgumentException If the path is not absolute or if the filename is shorter than three characters + * (restriction of {@link File#createTempFile(java.lang.String, java.lang.String)}). + * @throws FileNotFoundException If the file could not be found inside the JAR. + */ + @SuppressWarnings("ResultOfMethodCallIgnored") + private static void loadLibraryFromJar(String path) throws IOException { + if(null == path || !path.startsWith("/")) { + throw new IllegalArgumentException("The path has to be absolute (start with '/')."); + } + + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Check if the filename is okay + if(filename == null || filename.length() < MIN_PREFIX_LENGTH) { + throw new IllegalArgumentException("The filename has to be at least 3 characters long."); + } + + // Prepare temporary file + if(temporaryDir == null) { + temporaryDir = createTempDirectory(); + temporaryDir.deleteOnExit(); + } + + File temp = new File(temporaryDir, filename); + + try(InputStream is = NativeUtils.class.getResourceAsStream(path)) { + Files.copy(Objects.requireNonNull(is), temp.toPath(), StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + temp.delete(); + throw e; + } catch (NullPointerException e) { + temp.delete(); + throw new FileNotFoundException("File " + path + " was not found inside JAR."); + } + + try { + System.load(temp.getAbsolutePath()); + } finally { + if(isPosixCompliant()) { + // Assume POSIX compliant file system, can be deleted after loading + temp.delete(); + } else { + // Assume non-POSIX, and don't delete until last file descriptor closed + temp.deleteOnExit(); + } + } + } + + private static boolean isPosixCompliant() { + try { + return FileSystems.getDefault() + .supportedFileAttributeViews() + .contains("posix"); + } catch (FileSystemNotFoundException | ProviderNotFoundException | SecurityException e) { + return false; + } + } + + private static File createTempDirectory() throws IOException { + String tempDir = System.getProperty("java.io.tmpdir"); + File generatedDir = new File(tempDir, NativeUtils.NATIVE_FOLDER_PATH_PREFIX + System.nanoTime()); + + if(!generatedDir.mkdir()) + throw new IOException("Failed to create temp directory " + generatedDir.getName()); + + return generatedDir; + } + + private static boolean loaded = false; + static synchronized void loadLibraryIfNeeded() { + if(loaded) return; + try { + String os = System.getProperty("os.name").toLowerCase(); + + String filename; + if(os.startsWith("windows")) { + filename = "/natives/codemp.dll"; + } else if(os.startsWith("mac")) { + filename = "/natives/libcodemp.dylib";; + } else filename = "/natives/libcodemp.so"; + loadLibraryFromJar(filename); + + loaded = true; + } catch(IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/dist/java/src/mp/code/Workspace.java b/dist/java/src/mp/code/Workspace.java index 419a193..c833030 100644 --- a/dist/java/src/mp/code/Workspace.java +++ b/dist/java/src/mp/code/Workspace.java @@ -177,7 +177,7 @@ public final class Workspace { } static { - Extensions.loadLibraryIfNotPresent(); + NativeUtils.loadLibraryIfNeeded(); } /** From 8ac24d3078110e16ffca3e1d638511cff643d9f8 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 18 Sep 2024 15:36:11 +0200 Subject: [PATCH 15/21] feat(java): use Cleaner instead of finalize() --- dist/java/src/mp/code/BufferController.java | 5 +---- dist/java/src/mp/code/Client.java | 5 +---- dist/java/src/mp/code/CursorController.java | 5 +---- dist/java/src/mp/code/Extensions.java | 5 ++++- dist/java/src/mp/code/Workspace.java | 5 +---- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/dist/java/src/mp/code/BufferController.java b/dist/java/src/mp/code/BufferController.java index 220a339..0ae455f 100644 --- a/dist/java/src/mp/code/BufferController.java +++ b/dist/java/src/mp/code/BufferController.java @@ -17,6 +17,7 @@ public final class BufferController { BufferController(long ptr) { this.ptr = ptr; + Extensions.CLEANER.register(this, () -> free(ptr)); } private static native String get_name(long self); @@ -116,10 +117,6 @@ public final class BufferController { } private static native void free(long self); - @Override - protected void finalize() { - free(this.ptr); - } static { NativeUtils.loadLibraryIfNeeded(); diff --git a/dist/java/src/mp/code/Client.java b/dist/java/src/mp/code/Client.java index 1d20a92..12bd9c3 100644 --- a/dist/java/src/mp/code/Client.java +++ b/dist/java/src/mp/code/Client.java @@ -22,6 +22,7 @@ public final class Client { Client(long ptr) { this.ptr = ptr; + Extensions.CLEANER.register(this, () -> free(ptr)); } /** @@ -146,10 +147,6 @@ public final class Client { } private static native void free(long self); - @Override - protected void finalize() { - free(this.ptr); - } static { NativeUtils.loadLibraryIfNeeded(); diff --git a/dist/java/src/mp/code/CursorController.java b/dist/java/src/mp/code/CursorController.java index 7d2ce6a..ee3d238 100644 --- a/dist/java/src/mp/code/CursorController.java +++ b/dist/java/src/mp/code/CursorController.java @@ -16,6 +16,7 @@ public final class CursorController { CursorController(long ptr) { this.ptr = ptr; + Extensions.CLEANER.register(this, () -> free(ptr)); } private static native Cursor try_recv(long self) throws ControllerException; @@ -93,10 +94,6 @@ public final class CursorController { } private static native void free(long self); - @Override - protected void finalize() { - free(this.ptr); - } static { NativeUtils.loadLibraryIfNeeded(); diff --git a/dist/java/src/mp/code/Extensions.java b/dist/java/src/mp/code/Extensions.java index 6bd12a3..93e141a 100644 --- a/dist/java/src/mp/code/Extensions.java +++ b/dist/java/src/mp/code/Extensions.java @@ -1,6 +1,6 @@ package mp.code; -import java.io.IOException; +import java.lang.ref.Cleaner; /** * A class holding utility functions, as well as functions which are specific @@ -8,6 +8,9 @@ import java.io.IOException; * broader CodeMP API. */ public final class Extensions { + /** A {@link Cleaner} handling freeing of memory for library objects. */ + static final Cleaner CLEANER = Cleaner.create(); + /** * Hashes the given {@link String} using CodeMP's hashing algorithm (xxh3). * @param input the string to hash diff --git a/dist/java/src/mp/code/Workspace.java b/dist/java/src/mp/code/Workspace.java index c833030..3828995 100644 --- a/dist/java/src/mp/code/Workspace.java +++ b/dist/java/src/mp/code/Workspace.java @@ -22,6 +22,7 @@ public final class Workspace { Workspace(long ptr) { this.ptr = ptr; + Extensions.CLEANER.register(this, () -> free(ptr)); } private static native String get_workspace_id(long self); @@ -171,10 +172,6 @@ public final class Workspace { } private static native void free(long self); - @Override - protected void finalize() { - free(this.ptr); - } static { NativeUtils.loadLibraryIfNeeded(); From 542ff294748d8659b2bc03ce354a1876759368a8 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 15:46:39 +0200 Subject: [PATCH 16/21] docs: updated README.md added table with supported languages and releases --- README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f319c4f..b77c4e9 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,11 @@ [![Actions Status](https://github.com/hexedtech/codemp/actions/workflows/test.yml/badge.svg)](https://github.com/hexedtech/codemp/actions) [![docs.rs Status](https://img.shields.io/docsrs/codemp)](https://docs.rs/codemp/) -[![Gitter Chat](https://img.shields.io/gitter/room/hexedtech/codemp)](https://gitter.im/hexedtech/codemp) [![Crates.io Version](https://img.shields.io/crates/v/codemp)](https://crates.io/crates/codemp) -[![NPM Version](https://img.shields.io/npm/v/codemp)](https://npmjs.org/package/codemp) -[![PyPI Version](https://img.shields.io/pypi/v/codemp)](https://pypi.org/project/codemp) -[![Maven Central Version](https://img.shields.io/maven-central/v/mp.code/codemp)](https://central.sonatype.com/artifact/mp.code/codemp) -[![LuaRocks Version](https://img.shields.io/luarocks/v/alemi/codemp)](https://luarocks.org/modules/alemi/codemp) +[![Gitter Chat](https://img.shields.io/gitter/room/hexedtech/codemp)](https://gitter.im/hexedtech/codemp) +[![GitHub last commit](https://img.shields.io/github/last-commit/hexedtech/codemp)](https://github.com/hexedtech/codemp/commits/dev/) +[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/hexedtech/codemp/v0.6.2)](https://github.com/hexedtech/codemp/releases/tag/v0.6.2) +[![Crates.io License](https://img.shields.io/crates/l/codemp)](https://github.com/hexedtech/codemp/blob/dev/LICENSE) > `codemp` is a **collaborative** text editing solution to work remotely. @@ -56,11 +55,17 @@ Adding a dependency on `codemp` is **easy**: Just `cargo add codemp` and check the docs for some examples. ### From supported languages -We provide first-class bindings for: - - [![JavaScript](https://github.com/hexedtech/codemp/actions/workflows/javascript.yml/badge.svg)](./dist/README.md#javascript) available from **npm** as [`codemp`](https://npmjs.org/package/codemp) - - [![Python](https://github.com/hexedtech/codemp/actions/workflows/python.yml/badge.svg)](./dist/README.md#python) available from **PyPI** as [`codemp`](https://pypi.org/project/codemp) - - [![Lua](https://github.com/hexedtech/codemp/actions/workflows/lua.yml/badge.svg)](./dist/README.md#lua) available from **LuaRocks** as [`codemp`](https://luarocks.org/modules/alemi/codemp) - - [![Java](https://github.com/hexedtech/codemp/actions/workflows/java.yml/badge.svg)](./dist/README.md#java) available on **MavenCentral** as [`codemp`](https://central.sonatype.com/artifact/mp.code/codemp) +We provide first-class bindings for these other programming languages: + + +| | Build Status | Package | Build Instructions | +| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | +| JavaScript | [![JavaScript Build](https://github.com/hexedtech/codemp/actions/workflows/javascript.yml/badge.svg)](https://github.com/hexedtech/codemp/actions/workflows/javascript.yml) | [![NPM Version](https://img.shields.io/npm/v/codemp)](https://npmjs.org/package/codemp) | [README](./dist/README.md#javascript) | +| Python | [![Python Build](https://github.com/hexedtech/codemp/actions/workflows/python.yml/badge.svg)](https://github.com/hexedtech/codemp/actions/workflows/python.yml) | [![PyPI Version](https://img.shields.io/pypi/v/codemp)](https://pypi.org/project/codemp) | [README](./dist/README.md#python) | +| Java | [![Java Build](https://github.com/hexedtech/codemp/actions/workflows/java.yml/badge.svg)](https://github.com/hexedtech/codemp/actions/workflows/java.yml) | [![LuaRocks Version](https://img.shields.io/luarocks/v/alemi/codemp)](https://luarocks.org/modules/alemi/codemp) | [README](./dist/README.md#java) | +| Lua | [![Lua Build](https://github.com/hexedtech/codemp/actions/workflows/lua.yml/badge.svg)](https://github.com/hexedtech/codemp/actions/workflows/lua.yml) | [![Maven Central Version](https://img.shields.io/maven-central/v/mp.code/codemp)](https://central.sonatype.com/artifact/mp.code/codemp) | [README](./dist/README.md#lua) | + + As a design philosophy, our binding APIs attempt to perfectly mimic their Rust counterparts, so the main documentation can still be referenced as source of truth. Refer to specific language documentation for specifics, differences and quirks. From acfcae22bc69b0e7e8d1d7acb917cace87fa8f3c Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 15:49:03 +0200 Subject: [PATCH 17/21] ci(java): dont create the gradle module metadata its wrong and not really useful, will look into generating it again in the future --- dist/java/build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 1cdc1d2..bf94381 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -48,9 +48,12 @@ processResources { } } +generateMetadataFileForBinaryAndSourcesPublication.enabled = false +generateMetadataFileForBinaryPublication.enabled = false + import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) signAllPublications() coordinates(project.group, rootProject.name, project.version) @@ -78,4 +81,4 @@ mavenPublishing { developerConnection = "scm:git:ssh://git@github.com/hexedtech/codemp.git" } } -} \ No newline at end of file +} From 9a15b46fee8a7cb55a71461bf2e671f941a03b56 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 15:49:56 +0200 Subject: [PATCH 18/21] chore(java): bump version --- dist/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index bf94381..ee33531 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'mp.code' -version = '0.0.2' +version = '0.0.3' java { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 From 7a5b61067010d001a3f5bb7a7b65fd31cc7c29b2 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 15:53:36 +0200 Subject: [PATCH 19/21] fix(java): stackoverflow lied or many gradle changes too often? --- dist/java/build.gradle | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/java/build.gradle b/dist/java/build.gradle index ee33531..044499a 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -48,8 +48,13 @@ processResources { } } -generateMetadataFileForBinaryAndSourcesPublication.enabled = false -generateMetadataFileForBinaryPublication.enabled = false +generateMetadataFileForBinaryAndSourcesPublication.configure { + enabled = false +} + +generateMetadataFileForBinaryPublication.configure { + enabled = false +} import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { From 8c6e70cbe82caecced77fc790f770cc886d1d1e7 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 15:58:34 +0200 Subject: [PATCH 20/21] ci(java): try skipping module from cli args while building, those tasks dont exist so it fails building --- .github/workflows/java.yml | 2 +- dist/java/build.gradle | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 8b9552a..ecd8693 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -44,7 +44,7 @@ jobs: with: name: codemp-java-${{ matrix.platform.target }} path: dist/java/build/libs - - run: gradle publish + - run: gradle publish -x generateMetadataFileForBinaryAndSourcesPublication -x generateMetadataFileForBinaryPublication working-directory: dist/java env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} diff --git a/dist/java/build.gradle b/dist/java/build.gradle index 044499a..c0a3b87 100644 --- a/dist/java/build.gradle +++ b/dist/java/build.gradle @@ -48,14 +48,6 @@ processResources { } } -generateMetadataFileForBinaryAndSourcesPublication.configure { - enabled = false -} - -generateMetadataFileForBinaryPublication.configure { - enabled = false -} - import com.vanniktech.maven.publish.SonatypeHost mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) From 31b8bb1843add82f9c044f27fcdffdc6ca0075fc Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 18 Sep 2024 16:01:56 +0200 Subject: [PATCH 21/21] ci(java): give up you win for 0.7 gradle, but im going to try again --- .github/workflows/java.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index ecd8693..fe9c6cd 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -4,7 +4,6 @@ on: push: branches: - stable - - java-ci permissions: contents: read @@ -44,7 +43,7 @@ jobs: with: name: codemp-java-${{ matrix.platform.target }} path: dist/java/build/libs - - run: gradle publish -x generateMetadataFileForBinaryAndSourcesPublication -x generateMetadataFileForBinaryPublication + - run: gradle publish working-directory: dist/java env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}