Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
pull_request:
branches:
- main
workflow_dispatch:
inputs:
run_optional_task:
description: 'Publish?'
required: false
default: 'false'

jobs:

Expand Down Expand Up @@ -280,7 +286,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: surrealdb
path: build/libs/surrealdb-1.0.0-beta.1.jar
path: build/libs/surrealdb-1.0.0-SNAPSHOT.jar

- name: Linux Integration Test
run: ./gradlew -i integrationTest
Expand All @@ -306,14 +312,14 @@ jobs:
- name: Gradle
run: chmod +x gradlew

- name: Create directory build/libs
run: mkdir -p build/libs
- name: Create directory native
run: mkdir -p native

- name: Download JAR
uses: actions/download-artifact@v4
with:
name: surrealdb
path: build/libs
path: native

- name: Tests
run: ./gradlew -i integrationTest
Expand All @@ -322,7 +328,7 @@ jobs:
needs:
- aggregated-jar
- integration-tests
if: github.ref == 'refs/heads/main'
if: github.event_name == 'workflow_dispatch' && github.event.inputs.run_optional_task == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -336,11 +342,14 @@ jobs:
distribution: 'temurin'
java-version: 22

- name: Create directory native
run: mkdir -p native

- name: Download JAR
uses: actions/download-artifact@v4
with:
name: surrealdb
path: build/libs
path: native

- name: Publish Jar (Maven)
run: ./gradlew publish
Expand All @@ -349,13 +358,4 @@ jobs:
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_KEY_PASS: ${{ secrets.SIGNING_KEY_PASS }}

- name: Publish release package
uses: softprops/action-gh-release@v2
if: github.event_name == 'release' && github.event.action == 'created'
with:
name: "Release ${{ github.ref_name }}"
files: |
LICENSE
build/libs/*.jar
SIGNING_KEY_PASS: ${{ secrets.SIGNING_KEY_PASS }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ hs_err_*.log
/out/

# Ignore specific Gradle caches and logs
.gradle/
.gradle/
/native
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Gradle:

```groovy
ext {
surrealdbVersion = "1.0.0-SNAPSHOT"
surrealdbVersion = "1.0.0-beta.1"
}

dependencies {
Expand All @@ -80,7 +80,7 @@ Maven:
<dependency>
<groupId>com.surrealdb</groupId>
<artifactId>surrealdb</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0-beta.1</version>
</dependency>
```

Expand Down
90 changes: 74 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'com.surrealdb'
version '1.0.0-beta.1'
version '1.0.0-SNAPSHOT'

repositories {
mavenCentral()
Expand All @@ -31,9 +31,68 @@ configurations {
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}

ext.nativeJar = file("native/surrealdb-${version}.jar")

// Fail fast, but only when the task graph contains a task that needs the file
gradle.taskGraph.whenReady { graph ->
boolean needsNativeJar = graph.allTasks.any { t ->
t.name in ['publish', 'publishToMavenLocal'] ||
(t.name.startsWith('generate') && t.name.endsWith('Publication'))
}



if (needsNativeJar && !nativeJar.exists()) {
throw new GradleException(
"Native JAR not found at '${nativeJar}'. " +
"Build/copy it to native/ before running publishing tasks."
)
}
}



// ---------------------------------------------------------------------------
// 2. Task that stages (copies) the external JAR into build/libs
// ---------------------------------------------------------------------------
tasks.register('stageNativeJar', Copy) {
description = 'Copies the externally built JAR (with native libs) into build/libs.'
group = 'build'

from nativeJar
into "$buildDir/libs"
rename { "surrealdb-${version}.jar" } // the file name expected by publish/sign
}

// ---------------------------------------------------------------------------
// 3. Make sure every task that cares about the JAR sees the staged version.
// • jar is still executed (keeps components.java happy), but the copy task
// will overwrite its output afterwards.
// ---------------------------------------------------------------------------
tasks.named('jar') {
finalizedBy 'stageNativeJar' // run jar first, then overwrite
}

// All publish-to-Maven tasks must wait for the staged JAR
tasks.withType(PublishToMavenRepository).configureEach {
dependsOn 'stageNativeJar'
}
// Metadata / POM generation tasks must wait as well
tasks.matching { it.name.startsWith('generate') && it.name.endsWith('Publication') }
.configureEach { dependsOn 'stageNativeJar' }

// The generated signing task is created after evaluation; use task rules
tasks.matching { it.name == 'signMavenJavaPublication' }.configureEach {
dependsOn 'stageNativeJar'
}


dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
integrationTestImplementation files("build/libs/surrealdb-1.0.0-beta.1.jar")
// classes produced by src/main/java
integrationTestImplementation sourceSets.main.output
// the staged, native-enabled JAR
integrationTestImplementation files("native/surrealdb-${version}.jar")
}

jacoco {
Expand Down Expand Up @@ -63,10 +122,6 @@ jacocoTestCoverageVerification {
}
}

artifacts {
archives javadocJar, sourcesJar
}

tasks.register('createCombinedReport') {
dependsOn jacocoTestReport
dependsOn javadoc
Expand Down Expand Up @@ -103,10 +158,13 @@ tasks.register('createCombinedReport') {
}
}


tasks.register('integrationTest', Test) {
dependsOn 'stageNativeJar'
useJUnitPlatform()
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
// use target/release for a release build
testLogging {
showStandardStreams = true
events "passed", "skipped", "failed", "standardOut", "standardError"
Expand Down Expand Up @@ -136,16 +194,16 @@ publishing {
password = System.getenv("GITHUB_TOKEN")
}
}
// maven {
// name = "OSSRH"
// def releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
// def snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
// credentials {
// username = System.getenv("MAVEN_USERNAME")
// password = System.getenv("MAVEN_PASSWORD")
// }
// }
maven {
name = "OSSRH"
def releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
def snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}

publications {
Expand Down