diff --git a/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift b/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift index e0b7e5f0..a7cb323a 100644 --- a/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift +++ b/skipstone/Sources/SkipBuild/Commands/ExportCommand.swift @@ -311,7 +311,12 @@ 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 { let aarBuildOutputFolder = skipOutputFolder.appending(components: [depModuleName, "build", "outputs", "aar"]) if !fs.isDirectory(aarBuildOutputFolder) {