Skip to content
Open
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
10 changes: 10 additions & 0 deletions sdk/runanywhere-kotlin/build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
`kotlin-dsl`
}

// Ensure reproducible builds
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions {
allWarningsAsErrors.set(false)
}
}
8 changes: 8 additions & 0 deletions sdk/runanywhere-kotlin/build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rootProject.name = "build-logic"

dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* RunAnywhere Shared Build Conventions Plugin
*
* Provides shared build utilities for all SDK modules, including:
* - Module path resolution for composite builds
* - (Future) Common publishing configuration
* - (Future) Shared version catalogs
* - (Future) Common code quality settings
*
* Usage:
* plugins {
* id("runanywhere.conventions")
* }
*
* // Then use the extension functions:
* val onnxPath = resolveModulePath("runanywhere-core-onnx")
*/

/**
* Resolves the correct Gradle module path for a given module name.
*
* Handles multiple scenarios:
* - SDK as root project: path = ":" → ":modules:$moduleName"
* - SDK as subproject: path = ":sdk:runanywhere-kotlin" → ":sdk:runanywhere-kotlin:modules:$moduleName"
* - Composite builds from example apps or Android Studio
*
* @param moduleName The module name (e.g., "runanywhere-core-onnx")
* @return The resolved Gradle module path
*/
fun Project.resolveModulePath(moduleName: String): String {
val basePath = this.path
val computedPath = if (basePath == ":") {
":modules:$moduleName"
} else {
"$basePath:modules:$moduleName"
}

// Try to find the project using rootProject to handle Android Studio sync ordering
val foundProject = rootProject.findProject(computedPath)
if (foundProject != null) {
return computedPath
}

// Fallback: Try just :modules:$moduleName (when SDK is at non-root but modules are siblings)
val simplePath = ":modules:$moduleName"
if (rootProject.findProject(simplePath) != null) {
return simplePath
}

// Return computed path (will fail with clear error if not found)
return computedPath
}
35 changes: 4 additions & 31 deletions sdk/runanywhere-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.ktlint)
id("maven-publish")
signing
id("runanywhere.conventions") // Shared build utilities (module path resolution, etc.)
}

// =============================================================================
Expand Down Expand Up @@ -113,37 +114,9 @@ logger.lifecycle("RunAnywhere SDK: testLocal=$testLocal, nativeLibVersion=$nativ
// =============================================================================
// Project Path Resolution
// =============================================================================
// When included as a subproject in composite builds (e.g., from example app or Android Studio),
// the module path changes. This function constructs the full absolute path for sibling modules
// based on the current project's location in the hierarchy.
//
// Examples:
// - When SDK is root project: path = ":" → module path = ":modules:$moduleName"
// - When SDK is at ":sdk:runanywhere-kotlin": path → ":sdk:runanywhere-kotlin:modules:$moduleName"
fun resolveModulePath(moduleName: String): String {
val basePath = project.path
val computedPath =
if (basePath == ":") {
":modules:$moduleName"
} else {
"$basePath:modules:$moduleName"
}

// Try to find the project using rootProject to handle Android Studio sync ordering
val foundProject = rootProject.findProject(computedPath)
if (foundProject != null) {
return computedPath
}

// Fallback: Try just :modules:$moduleName (when SDK is at non-root but modules are siblings)
val simplePath = ":modules:$moduleName"
if (rootProject.findProject(simplePath) != null) {
return simplePath
}

// Return computed path (will fail with clear error if not found)
return computedPath
}
// Module path resolution is handled by the runanywhere.conventions plugin.
// Use resolveModulePath("runanywhere-core-onnx") to get the correct path in composite builds.
// See: build-logic/src/main/kotlin/runanywhere.conventions.gradle.kts

kotlin {
// Use Java 17 toolchain across targets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ plugins {
alias(libs.plugins.ktlint)
`maven-publish`
signing
id("runanywhere.conventions") // Shared build utilities (module path resolution, etc.)
}

// =============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ plugins {
alias(libs.plugins.ktlint)
`maven-publish`
signing
id("runanywhere.conventions") // Shared build utilities (module path resolution, etc.)
}

// =============================================================================
Expand Down
3 changes: 3 additions & 0 deletions sdk/runanywhere-kotlin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pluginManagement {
// Include build-logic for convention plugins (shared build utilities)
includeBuild("build-logic")

repositories {
google {
content {
Expand Down