-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.gradle.kts
46 lines (40 loc) · 2.52 KB
/
settings.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// This gradle project is part of a conventional Skip app project.
// It invokes the shared build skip plugin logic, which included as part of the skip-unit buildSrc
// When built from Android Studio, it uses the BUILT_PRODUCTS_DIR folder to share the same build outputs as Xcode, otherwise it uses SwiftPM's .build/ folder
pluginManagement {
// local override of BUILT_PRODUCTS_DIR
if (System.getenv("BUILT_PRODUCTS_DIR") == null) {
//System.setProperty("BUILT_PRODUCTS_DIR", "${System.getProperty("user.home")}/Library/Developer/Xcode/DerivedData/MySkipProject-aqywrhrzhkbvfseiqgxuufbdwdft/Build/Products/Debug-iphonesimulator")
}
// the source for the plugin is linked as part of the SkipUnit transpilation
val skipOutput = System.getenv("BUILT_PRODUCTS_DIR") ?: System.getProperty("BUILT_PRODUCTS_DIR")
val outputExt = if (skipOutput != null) ".output" else "" // Xcode saves output in package-name.output; SPM has no suffix
val skipOutputs: File = if (skipOutput != null) {
// BUILT_PRODUCTS_DIR is set when building from Xcode, in which case we will use Xcode's DerivedData plugin output
file(skipOutput).resolve("../../../SourcePackages/plugins/")
} else {
exec {
// create transpiled Kotlin and generate Gradle projects from SwiftPM modules
commandLine("sh", "-c", "xcrun swift build --triple arm64-apple-ios --sdk $(xcrun --sdk iphoneos --show-sdk-path)")
workingDir = file("..")
}
// SPM output folder is a peer of the parent Package.swift
rootDir.resolve("../.build/plugins/outputs/")
}
// load the Skip plugin (part of the skip-unit project), which handles configuring the Android project
// because this path is a symlink, we need to use the canonical path or gradle will mis-interpret it as a different build source
var pluginSource = skipOutputs.resolve("skip-unit${outputExt}/SkipUnit/skipstone/buildSrc/").canonicalFile
if (!pluginSource.isDirectory) {
// check new SwiftPM6 plugin "destination" folder for command-line builds
pluginSource = skipOutputs.resolve("skip-unit${outputExt}/SkipUnit/destination/skipstone/buildSrc/").canonicalFile
}
if (!pluginSource.isDirectory) {
throw GradleException("Missing expected Skip output folder: ${pluginSource}. Run `swift build` in the root folder to create, or specify Xcode environment BUILT_PRODUCTS_DIR.")
}
includeBuild(pluginSource.path) {
name = "skip-plugins"
}
}
plugins {
id("skip-plugin") apply true
}