@@ -11,18 +11,32 @@ import org.apache.tools.ant.taskdefs.condition.Os
1111plugins {
1212 id(" maven-publish" )
1313 id(" signing" )
14+ alias(libs.plugins.nexus.publish)
1415 alias(libs.plugins.android.library)
1516 alias(libs.plugins.download)
1617 id(" publish" )
1718}
1819
19- group = " com.facebook.hermes"
20+ group = " com.facebook.hermes-v2 "
2021
2122version = project.findProperty(" VERSION_NAME" )?.toString()!!
2223
2324val cmakeVersion = System .getenv(" CMAKE_VERSION" ) ? : libs.versions.cmake.get()
2425val cmakePath = " ${getSDKPath()} /cmake/$cmakeVersion "
2526val cmakeBinaryPath = " ${cmakePath} /bin/cmake"
27+ val sonatypeUsername = findProperty(" SONATYPE_USERNAME" )?.toString()
28+ val sonatypePassword = findProperty(" SONATYPE_PASSWORD" )?.toString()
29+
30+ nexusPublishing {
31+ repositories {
32+ sonatype {
33+ username.set(sonatypeUsername)
34+ password.set(sonatypePassword)
35+ nexusUrl.set(uri(" https://ossrh-staging-api.central.sonatype.com/service/local/" ))
36+ snapshotRepositoryUrl.set(uri(" https://central.sonatype.com/repository/maven-snapshots/" ))
37+ }
38+ }
39+ }
2640
2741fun getSDKPath (): String {
2842 val androidSdkRoot = System .getenv(" ANDROID_SDK_ROOT" )
@@ -50,9 +64,12 @@ fun getSDKManagerPath(): String {
5064 }
5165}
5266
53- val buildDir = project.layout.buildDirectory.get().asFile
5467val hermesDir = project.projectDir.parentFile
55- val hermesBuildDir = File (" $buildDir /hermes" )
68+ val hermesBuildDir = File (" $hermesDir /build" )
69+
70+ project.layout.buildDirectory.set(hermesBuildDir)
71+
72+ val buildDir = project.layout.buildDirectory.get().asFile
5673val hermesCOutputBinary = File (" $buildDir /hermes/bin/hermesc" )
5774
5875// This filetree represents the file of the Hermes build that we want as input/output
@@ -77,7 +94,8 @@ val installCMake by
7794 tasks.registering(CustomExecTask ::class ) {
7895 onlyIfProvidedPathDoesNotExists.set(cmakePath)
7996 commandLine(
80- windowsAwareCommandLine(getSDKManagerPath(), " --install" , " cmake;${cmakeVersion} " ))
97+ windowsAwareCommandLine(getSDKManagerPath(), " --install" , " cmake;${cmakeVersion} " )
98+ )
8199 }
82100
83101val configureBuildForHermes by
@@ -99,7 +117,8 @@ val configureBuildForHermes by
99117 " -B" ,
100118 hermesBuildDir.toString(),
101119 " -DJSI_DIR=" + jsiDir.absolutePath,
102- " -DCMAKE_BUILD_TYPE=Debug" )
120+ " -DCMAKE_BUILD_TYPE=Debug" ,
121+ )
103122 if (Os .isFamily(Os .FAMILY_WINDOWS )) {
104123 cmakeCommandLine = cmakeCommandLine + " -GNMake Makefiles"
105124 }
@@ -207,7 +226,8 @@ android {
207226 " -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True" ,
208227 // We intentionally build Hermes with Intl support only. This is to simplify
209228 // the build setup and to avoid overcomplicating the build-type matrix.
210- " -DHERMES_ENABLE_INTL=True" )
229+ " -DHERMES_ENABLE_INTL=True" ,
230+ )
211231
212232 targets(" hermesvm" )
213233 }
@@ -291,3 +311,15 @@ tasks.withType<JavaCompile>().configureEach {
291311 options.compilerArgs.add(" -Xlint:deprecation,unchecked" )
292312 options.compilerArgs.add(" -Werror" )
293313}
314+
315+ tasks.register(" publishAndroidOnlyToMavenTempLocal" ) {
316+ dependsOn(" :publishAllPublicationsToMavenTempLocalRepository" , " :build" )
317+ }
318+
319+ tasks.register(" publishAndroidOnlyToSonatype" ) { dependsOn(" :publishToSonatype" ) }
320+
321+ // We need to override the artifact ID as this project is called `hermes-engine` but
322+ // the maven coordinates are on `hermes-android`.
323+ publishing {
324+ publications { getByName(" release" , MavenPublication ::class ) { artifactId = " hermes-android" } }
325+ }
0 commit comments