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
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,26 @@ plugins {
1. Define multiplatform targets (`macos`, `ios`, `tvos`, `watchos`).
2. Declare a `spm` section with all the necessary package dependencies for each platform.
3. Add package dependencies with URL link, version and name. This name would be used as an import in the Kotlin project.
Plugin supports all package versioning strategies described here: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html
and provides convenient methods to define them:

```
fun fromVersion(version: String)

fun exactVersion(version: String)

fun versionRange(minVersion: String, maxVersion: String)

fun versionClosedRange(minVersion: String, maxVersion: String)

fun upToNextMajor(version: String)

fun upToNextMinor(version: String)

fun branch(branchName: String)

fun revision(ref: String)
```
`build.gradle.kts` example:

```kotlin
Expand All @@ -34,7 +53,7 @@ plugins {
dependencies {
packages(
url = "https://github.com/AFNetworking/AFNetworking.git",
version = "4.0.0",
version = exactVersion("4.0.0"),
name = "AFNetworking"
)
}
Expand Down
2 changes: 1 addition & 1 deletion example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kotlin {
dependencies {
packages(
url = "https://github.com/AFNetworking/AFNetworking.git",
version = "4.0.0",
version = exactVersion("4.0.1"),
name = "AFNetworking"
)
}
Expand Down
2 changes: 1 addition & 1 deletion plugin-build/buildSrc/src/main/java/Coordinates.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object PluginCoordinates {
const val GROUP = "com.github.pagr0m"
const val ARTIFACT = "kotlin.native.spm"
const val VERSION = "0.1.1"
const val VERSION = "0.1.2"

const val ID = "$GROUP.$ARTIFACT"
const val IMPLEMENTATION_CLASS = "$ID.plugin.KotlinSpmPlugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ class DependencyManager {
dependencies.add(dependency)
}

/**
* Version definitions based on:
* https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html
*/
fun fromVersion(version: String) = "from: \"$version\""

fun exactVersion(version: String) = ".exact(\"$version\")"

fun versionRange(minVersion: String, maxVersion: String) = "\"$minVersion\"..<\"$maxVersion\""

fun versionClosedRange(minVersion: String, maxVersion: String) = "\"$minVersion\"...\"$maxVersion\""

fun upToNextMajor(version: String) = ".upToNextMajor(from: \"$version\")"

fun upToNextMinor(version: String) = ".upToNextMinor(from: \"$version\")"

fun branch(branchName: String) = ".branch(\"$branchName\")"

fun revision(ref: String) = ".revision(\"$ref\")"

data class Package(
@Input val url: String,
@Input @Optional val version: String? = null,
Expand All @@ -38,7 +58,7 @@ class DependencyManager {
.package(
name: "$dependencyName",
url: "$url",
from: "$version"
$version
)
""".trimIndent()
}
Expand Down