From 5702673993bae657d1bacece33664a1855f349c1 Mon Sep 17 00:00:00 2001 From: Pierluigi Cifani Date: Mon, 30 Nov 2026 14:47:16 +0100 Subject: [PATCH 1/2] Do not export the test-only SkipUnit AAR skipstone wires SkipUnit as testImplementation/androidTestImplementation, so no exported module depends on it at runtime. Exporting it anyway put a test library into consumers' release builds without its dependencies (JUnit, androidx.test, TestParameterInjector), which R8 reports as missing classes. Co-Authored-By: Claude Opus 5.5 --- skipstone/Sources/SkipBuild/Commands/ExportCommand.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift b/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift index e0b7e5f0..1b976a1d 100644 --- a/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift +++ b/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift @@ -313,6 +313,11 @@ Build and export the Skip modules defined in the Package.swift, with libraries e let depModuleNames = try fs.getDirectoryContents(skipOutputFolder).sorted() for depModuleName in depModuleNames { + if depModuleName == "SkipUnit" { + // test-only: skipstone wires SkipUnit as testImplementation/androidTestImplementation, + // so no exported module needs it at runtime and its test dependencies are not bundled + continue + } let aarBuildOutputFolder = skipOutputFolder.appending(components: [depModuleName, "build", "outputs", "aar"]) if !fs.isDirectory(aarBuildOutputFolder) { // ignore non-module output folders (e.g., "gradle") From 6c68290cc2a9f51d866cec2d0bf0acd9f81e1129 Mon Sep 17 00:00:00 2001 From: Pierluigi Cifani Date: Mon, 30 Nov 2026 14:58:59 +0100 Subject: [PATCH 2/2] Export only modules on the runtime classpath instead of special-casing SkipUnit Ask Gradle for the exported module's RuntimeClasspath and copy only the AARs of that module and the project modules it resolves. Test-only modules such as SkipUnit, which skipstone wires as testImplementation/androidTestImplementation, are left out without naming them. Co-Authored-By: Claude Opus 5.5 --- .../Sources/SkipBuild/Commands/ExportCommand.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift b/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift index 1b976a1d..a7cb323a 100644 --- a/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift +++ b/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift @@ -311,13 +311,13 @@ Build and export the Skip modules defined in the Package.swift, with libraries e let aarOutputFolder = !nested ? outputFolderAbsolute : outputFolderAbsolute.appending(components: [variant.rawValue, "aar"]) try fs.createDirectory(aarOutputFolder, recursive: true) - let depModuleNames = try fs.getDirectoryContents(skipOutputFolder).sorted() + // export only the module and the project modules on its runtime classpath, so test-only + // modules (wired as testImplementation/androidTestImplementation) are not bundled + let runtimeDeps = try await run(with: out, "Resolve runtime modules for \(moduleName)", ["gradle", "-q", ":\(moduleName):dependencies", "--configuration", "\(variant.rawValue)RuntimeClasspath"] + gradleArgs, environment: env).get() + let runtimeModuleNames = Set([moduleName] + runtimeDeps.stdout.matches(of: try Regex(#"project '?:([^'\s]+)"#)).compactMap { $0[1].substring.map(String.init) }) + + let depModuleNames = try fs.getDirectoryContents(skipOutputFolder).sorted().filter(runtimeModuleNames.contains) for depModuleName in depModuleNames { - if depModuleName == "SkipUnit" { - // test-only: skipstone wires SkipUnit as testImplementation/androidTestImplementation, - // so no exported module needs it at runtime and its test dependencies are not bundled - continue - } let aarBuildOutputFolder = skipOutputFolder.appending(components: [depModuleName, "build", "outputs", "aar"]) if !fs.isDirectory(aarBuildOutputFolder) { // ignore non-module output folders (e.g., "gradle")