@@ -31,9 +31,68 @@ configurations {
3131 integrationTestRuntimeOnly. extendsFrom testRuntimeOnly
3232}
3333
34+ ext. nativeJar = file(" native/surrealdb-${ version} .jar" )
35+
36+ // Fail fast, but only when the task graph contains a task that needs the file
37+ gradle. taskGraph. whenReady { graph ->
38+ boolean needsNativeJar = graph. allTasks. any { t ->
39+ t. name in [' publish' , ' publishToMavenLocal' ] ||
40+ (t. name. startsWith(' generate' ) && t. name. endsWith(' Publication' ))
41+ }
42+
43+
44+
45+ if (needsNativeJar && ! nativeJar. exists()) {
46+ throw new GradleException (
47+ " Native JAR not found at '${ nativeJar} '. " +
48+ " Build/copy it to native/ before running publishing tasks."
49+ )
50+ }
51+ }
52+
53+
54+
55+ // ---------------------------------------------------------------------------
56+ // 2. Task that stages (copies) the external JAR into build/libs
57+ // ---------------------------------------------------------------------------
58+ tasks. register(' stageNativeJar' , Copy ) {
59+ description = ' Copies the externally built JAR (with native libs) into build/libs.'
60+ group = ' build'
61+
62+ from nativeJar
63+ into " $buildDir /libs"
64+ rename { " surrealdb-${ version} .jar" } // the file name expected by publish/sign
65+ }
66+
67+ // ---------------------------------------------------------------------------
68+ // 3. Make sure every task that cares about the JAR sees the staged version.
69+ // • jar is still executed (keeps components.java happy), but the copy task
70+ // will overwrite its output afterwards.
71+ // ---------------------------------------------------------------------------
72+ tasks. named(' jar' ) {
73+ finalizedBy ' stageNativeJar' // run jar first, then overwrite
74+ }
75+
76+ // All publish-to-Maven tasks must wait for the staged JAR
77+ tasks. withType(PublishToMavenRepository ). configureEach {
78+ dependsOn ' stageNativeJar'
79+ }
80+ // Metadata / POM generation tasks must wait as well
81+ tasks. matching { it. name. startsWith(' generate' ) && it. name. endsWith(' Publication' ) }
82+ .configureEach { dependsOn ' stageNativeJar' }
83+
84+ // The generated signing task is created after evaluation; use task rules
85+ tasks. matching { it. name == ' signMavenJavaPublication' }. configureEach {
86+ dependsOn ' stageNativeJar'
87+ }
88+
89+
3490dependencies {
3591 testImplementation ' org.junit.jupiter:junit-jupiter:5.10.2'
36- integrationTestImplementation files(" build/libs/surrealdb-1.0.0-beta.1.jar" )
92+ // classes produced by src/main/java
93+ integrationTestImplementation sourceSets. main. output
94+ // the staged, native-enabled JAR
95+ integrationTestImplementation files(" native/surrealdb-${ version} .jar" )
3796}
3897
3998jacoco {
@@ -63,10 +122,6 @@ jacocoTestCoverageVerification {
63122 }
64123}
65124
66- artifacts {
67- archives javadocJar, sourcesJar
68- }
69-
70125tasks. register(' createCombinedReport' ) {
71126 dependsOn jacocoTestReport
72127 dependsOn javadoc
@@ -103,10 +158,13 @@ tasks.register('createCombinedReport') {
103158 }
104159}
105160
161+
106162tasks. register(' integrationTest' , Test ) {
163+ dependsOn ' stageNativeJar'
107164 useJUnitPlatform()
108165 testClassesDirs = sourceSets. integrationTest. output. classesDirs
109166 classpath = sourceSets. integrationTest. runtimeClasspath
167+ // use target/release for a release build
110168 testLogging {
111169 showStandardStreams = true
112170 events " passed" , " skipped" , " failed" , " standardOut" , " standardError"
@@ -136,16 +194,16 @@ publishing {
136194 password = System . getenv(" GITHUB_TOKEN" )
137195 }
138196 }
139- // maven {
140- // name = "OSSRH"
141- // def releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
142- // def snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
143- // url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
144- // credentials {
145- // username = System.getenv("MAVEN_USERNAME")
146- // password = System.getenv("MAVEN_PASSWORD")
147- // }
148- // }
197+ maven {
198+ name = " OSSRH"
199+ def releasesRepoUrl = uri(" https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" )
200+ def snapshotsRepoUrl = uri(" https://s01.oss.sonatype.org/content/repositories/snapshots/" )
201+ url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
202+ credentials {
203+ username = System . getenv(" MAVEN_USERNAME" )
204+ password = System . getenv(" MAVEN_PASSWORD" )
205+ }
206+ }
149207 }
150208
151209 publications {
0 commit comments