Skip to content

Commit 0a5b077

Browse files
committed
update build gradle
1 parent 32a601f commit 0a5b077

File tree

3 files changed

+24
-70
lines changed

3 files changed

+24
-70
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ name: Build and Publish
33
on:
44
push:
55
tags:
6-
- '*'
6+
- 'v*'
77

88
permissions:
99
contents: read
1010

1111
jobs:
12-
build-natives:
13-
name: Build Native Library - ${{ matrix.arch }}
14-
runs-on: ${{ matrix.os }}
15-
strategy:
16-
matrix:
17-
include:
18-
- os: ubuntu-latest
19-
arch: linux-x64
12+
build-and-publish:
13+
name: Build and Publish to Maven Central
14+
runs-on: ubuntu-latest
2015

2116
steps:
2217
- name: Checkout code
@@ -36,59 +31,20 @@ jobs:
3631
- name: Grant execute permission for gradlew
3732
run: chmod +x gradlew
3833

39-
- name: Compile native library
40-
run: ./gradlew compileFlecsNative copyFlecsNative -PNATIVE_ARCH=${{ matrix.arch }}
41-
42-
- name: Upload native library artifact
43-
uses: actions/upload-artifact@v4
44-
with:
45-
name: natives-${{ matrix.arch }}
46-
path: build/natives/${{ matrix.arch }}/libflecs.so
47-
retention-days: 1
48-
49-
publish-maven-central:
50-
name: Publish to Maven Central
51-
needs: build-natives
52-
runs-on: ubuntu-latest
53-
54-
steps:
55-
- name: Checkout code
56-
uses: actions/checkout@v4
57-
58-
- name: Set up JDK 25
59-
uses: actions/setup-java@v4
60-
with:
61-
java-version: '25'
62-
distribution: 'temurin'
63-
64-
- name: Download all native artifacts
65-
uses: actions/download-artifact@v4
66-
with:
67-
pattern: natives-*
68-
path: downloaded-natives
34+
- name: Build project with natives
35+
run: ./gradlew build -PNATIVE_ARCH=linux-x64 -x test
6936

70-
- name: Organize natives in build directory
37+
- name: Verify JAR contents
7138
run: |
72-
mkdir -p build/natives/linux-x64
73-
cp downloaded-natives/natives-linux-x64/libflecs.so build/natives/linux-x64/
74-
ls -R build/natives/
75-
76-
- name: Grant execute permission for gradlew
77-
run: chmod +x gradlew
78-
79-
- name: Build project
80-
run: ./gradlew build -PNATIVE_ARCH=linux-x64 -x test
39+
VERSION=${GITHUB_REF_NAME#v}
40+
echo "Verifying JAR for version $VERSION..."
41+
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/linux-x64/libflecs.so" && echo "✓ Native library found" || echo "✗ Native NOT found"
42+
jar tf build/libs/flecs-java-$VERSION.jar | grep "META-INF/services/javax.annotation.processing.Processor" && echo "✓ Processor found" || echo "✗ Processor NOT found"
8143
8244
- name: Publish to Maven Central
8345
env:
8446
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
8547
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
8648
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
8749
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
88-
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -PNATIVE_ARCH=linux-x64
89-
90-
- name: Verify JAR contents
91-
run: |
92-
VERSION=${GITHUB_REF_NAME#v}
93-
echo "Verifying JAR contents..."
94-
jar tf build/libs/flecs-java-$VERSION.jar | grep natives || echo "Warning: No natives found in JAR"
50+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -PNATIVE_ARCH=linux-x64

build.gradle.kts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ plugins {
1010
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
1111
}
1212

13-
group = "com.github.elebras1"
14-
version = System.getenv("GITHUB_REF_NAME") ?: project.findProperty("version") as String? ?: "0.1-SNAPSHOT"
13+
group = "io.github.elebras1"
14+
version = System.getenv("GITHUB_REF_NAME")?.removePrefix("v") ?: project.findProperty("version") as String? ?: "0.1-SNAPSHOT"
1515

1616
repositories {
1717
mavenCentral()
@@ -121,7 +121,7 @@ val compileFlecsNative by tasks.registering(Exec::class) {
121121
}
122122

123123
val generateFlecsBindings by tasks.registering(Exec::class) {
124-
description = "Generate Java FFM bindings using jextract"
124+
description = "Generate Java FFM bindings using jextract (maintainer-only task, run when updating Flecs version)"
125125
group = "flecs"
126126

127127
dependsOn(compileFlecsNative)
@@ -229,7 +229,8 @@ tasks.jar {
229229
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
230230

231231
from(compileProcessor.get().destinationDirectory)
232-
from(copyProcessorResources)
232+
233+
from(copyProcessorResources.get().destinationDir)
233234

234235
from(configurations.runtimeClasspath.get().map {
235236
if (it.isDirectory) it else zipTree(it)
@@ -254,7 +255,6 @@ val cleanFlecs by tasks.registering(Delete::class) {
254255
group = "flecs"
255256

256257
delete(flecsDir)
257-
delete(generatedSourcesDir)
258258
delete(layout.buildDirectory.dir("natives"))
259259
}
260260

@@ -266,11 +266,15 @@ tasks.withType<JavaExec> {
266266
jvmArgs("--enable-native-access=ALL-UNNAMED")
267267
}
268268

269+
tasks.named("sourcesJar") {
270+
dependsOn(copyFlecsNative, tasks.compileJava)
271+
}
272+
269273
configure<io.github.gradlenexus.publishplugin.NexusPublishExtension> {
270274
repositories {
271275
sonatype {
272-
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
273-
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
276+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
277+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
274278
username.set(System.getenv("OSSRH_USERNAME"))
275279
password.set(System.getenv("OSSRH_PASSWORD"))
276280
}
@@ -280,7 +284,7 @@ configure<io.github.gradlenexus.publishplugin.NexusPublishExtension> {
280284
publishing {
281285
publications {
282286
create<MavenPublication>("maven") {
283-
groupId = "com.github.elebras1"
287+
groupId = "io.github.elebras1"
284288
artifactId = "flecs-java"
285289
version = project.version.toString()
286290

jitpack.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)