Skip to content

Commit 46dd1cf

Browse files
committed
[support] create swiftklib entries properties using ObjectFactory
1 parent af954f3 commit 46dd1cf

File tree

2 files changed

+19
-44
lines changed

2 files changed

+19
-44
lines changed
Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,21 @@
11
package io.github.ttypic.swiftklib.gradle
22

3+
import org.gradle.api.model.ObjectFactory
34
import org.gradle.api.provider.Property
45
import java.io.File
56
import javax.inject.Inject
67

7-
abstract class SwiftKlibEntry @Inject constructor(val name: String) {
8+
abstract class SwiftKlibEntry @Inject constructor(
9+
val name: String,
10+
objects: ObjectFactory,
11+
) {
812

9-
abstract val pathProperty: Property<File>
10-
abstract val packageNameProperty: Property<String>
11-
abstract val minIosProperty: Property<Int>
12-
abstract val minMacosProperty: Property<Int>
13-
abstract val minTvosProperty: Property<Int>
14-
abstract val minWatchosProperty: Property<Int>
13+
val path: Property<File> = objects.property(File::class.java)
14+
val packageName: Property<String> = objects.property(String::class.java)
15+
val minIos: Property<Int> = objects.property(Int::class.java)
16+
val minMacos: Property<Int> = objects.property(Int::class.java)
17+
val minTvos: Property<Int> = objects.property(Int::class.java)
18+
val minWatchos: Property<Int> = objects.property(Int::class.java)
1519

16-
var path: File
17-
get() = pathProperty.get()
18-
set(value) {
19-
pathProperty.set(value)
20-
}
21-
22-
fun packageName(name: String) = packageNameProperty.set(name)
23-
24-
var minIos: Int
25-
get() = minIosProperty.get()
26-
set(value) {
27-
minIosProperty.set(value)
28-
}
29-
30-
var minMacos: Int
31-
get() = minMacosProperty.get()
32-
set(value) {
33-
minMacosProperty.set(value)
34-
}
35-
36-
var minTvos: Int
37-
get() = minTvosProperty.get()
38-
set(value) {
39-
minTvosProperty.set(value)
40-
}
41-
42-
var minWatchos: Int
43-
get() = minWatchosProperty.get()
44-
set(value) {
45-
minWatchosProperty.set(value)
46-
}
20+
fun packageName(name: String) = packageName.set(name)
4721
}

plugin/src/main/kotlin/io/github/ttypic/swiftklib/gradle/SwiftKlibPlugin.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.gradle.tasks.CInteropProcess
1010

1111
const val EXTENSION_NAME = "swiftklib"
1212

13+
@Suppress("unused")
1314
class SwiftKlibPlugin : Plugin<Project> {
1415
override fun apply(target: Project) = with(target) {
1516
val objects: ObjectFactory = project.objects
@@ -36,12 +37,12 @@ class SwiftKlibPlugin : Plugin<Project> {
3637
name,
3738
target,
3839
buildDir,
39-
entry.pathProperty,
40-
entry.packageNameProperty,
41-
entry.minIosProperty,
42-
entry.minMacosProperty,
43-
entry.minTvosProperty,
44-
entry.minWatchosProperty,
40+
entry.path,
41+
entry.packageName,
42+
entry.minIos,
43+
entry.minMacos,
44+
entry.minTvos,
45+
entry.minWatchos,
4546
)
4647
}
4748
}

0 commit comments

Comments
 (0)