Skip to content

Commit 6ecbff6

Browse files
committed
refactor(bulk-model-sync-gradle): simplify property declarations
1 parent 1c9e0d4 commit 6ecbff6

File tree

3 files changed

+38
-44
lines changed

3 files changed

+38
-44
lines changed

bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import kotlinx.coroutines.runBlocking
2020
import org.gradle.api.DefaultTask
2121
import org.gradle.api.file.DirectoryProperty
2222
import org.gradle.api.file.RegularFileProperty
23-
import org.gradle.api.model.ObjectFactory
2423
import org.gradle.api.provider.Property
2524
import org.gradle.api.provider.SetProperty
2625
import org.gradle.api.tasks.Input
@@ -36,32 +35,31 @@ import org.modelix.model.client2.ModelClientV2PlatformSpecificBuilder
3635
import org.modelix.model.lazy.RepositoryId
3736
import org.modelix.model.sync.bulk.ModelExporter
3837
import org.modelix.model.sync.bulk.isModuleIncluded
39-
import javax.inject.Inject
4038
import kotlin.time.Duration.Companion.seconds
4139

42-
abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : DefaultTask() {
40+
abstract class ExportFromModelServer : DefaultTask() {
4341

44-
@Input
45-
val url: Property<String> = of.property(String::class.java)
42+
@get:Input
43+
abstract val url: Property<String>
4644

47-
@Input
48-
@Optional
49-
val repositoryId: Property<String> = of.property(String::class.java)
45+
@get:Input
46+
@get:Optional
47+
abstract val repositoryId: Property<String>
5048

5149
@get:InputFile
52-
val revisionFile: RegularFileProperty = of.fileProperty()
50+
abstract val revisionFile: RegularFileProperty
5351

54-
@OutputDirectory
55-
val outputDir: DirectoryProperty = of.directoryProperty()
52+
@get:OutputDirectory
53+
abstract val outputDir: DirectoryProperty
5654

57-
@Input
58-
val includedModules: SetProperty<String> = of.setProperty(String::class.java)
55+
@get:Input
56+
abstract val includedModules: SetProperty<String>
5957

60-
@Input
61-
val includedModulePrefixes: SetProperty<String> = of.setProperty(String::class.java)
58+
@get:Input
59+
abstract val includedModulePrefixes: SetProperty<String>
6260

63-
@Input
64-
val requestTimeoutSeconds: Property<Int> = of.property(Int::class.java)
61+
@get:Input
62+
abstract val requestTimeoutSeconds: Property<Int>
6563

6664
@TaskAction
6765
fun export() = runBlocking {

bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package org.modelix.model.sync.bulk.gradle.tasks
1919
import kotlinx.coroutines.runBlocking
2020
import org.gradle.api.DefaultTask
2121
import org.gradle.api.file.DirectoryProperty
22-
import org.gradle.api.model.ObjectFactory
2322
import org.gradle.api.provider.MapProperty
2423
import org.gradle.api.provider.Property
2524
import org.gradle.api.provider.SetProperty
@@ -39,38 +38,37 @@ import org.modelix.model.operations.OTBranch
3938
import org.modelix.model.sync.bulk.ModelImporter
4039
import org.modelix.model.sync.bulk.importFilesAsRootChildren
4140
import org.modelix.model.sync.bulk.isModuleIncluded
42-
import javax.inject.Inject
4341
import kotlin.time.Duration.Companion.seconds
4442

45-
abstract class ImportIntoModelServer @Inject constructor(of: ObjectFactory) : DefaultTask() {
43+
abstract class ImportIntoModelServer : DefaultTask() {
4644

47-
@InputDirectory
48-
@PathSensitive(PathSensitivity.RELATIVE)
49-
val inputDir: DirectoryProperty = of.directoryProperty()
45+
@get:InputDirectory
46+
@get:PathSensitive(PathSensitivity.RELATIVE)
47+
abstract val inputDir: DirectoryProperty
5048

51-
@Input
52-
val repositoryId: Property<String> = of.property(String::class.java)
49+
@get:Input
50+
abstract val repositoryId: Property<String>
5351

54-
@Input
55-
val branchName: Property<String> = of.property(String::class.java)
52+
@get:Input
53+
abstract val branchName: Property<String>
5654

57-
@Input
58-
val url: Property<String> = of.property(String::class.java)
55+
@get:Input
56+
abstract val url: Property<String>
5957

60-
@Input
61-
val includedModules: SetProperty<String> = of.setProperty(String::class.java)
58+
@get:Input
59+
abstract val includedModules: SetProperty<String>
6260

63-
@Input
64-
val includedModulePrefixes: SetProperty<String> = of.setProperty(String::class.java)
61+
@get:Input
62+
abstract val includedModulePrefixes: SetProperty<String>
6563

66-
@Input
67-
val continueOnError: Property<Boolean> = of.property(Boolean::class.java)
64+
@get:Input
65+
abstract val continueOnError: Property<Boolean>
6866

69-
@Input
70-
val requestTimeoutSeconds: Property<Int> = of.property(Int::class.java)
67+
@get:Input
68+
abstract val requestTimeoutSeconds: Property<Int>
7169

72-
@Input
73-
val metaProperties: MapProperty<String, String> = of.mapProperty(String::class.java, String::class.java)
70+
@get:Input
71+
abstract val metaProperties: MapProperty<String, String>
7472

7573
@TaskAction
7674
fun import() = runBlocking {

bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ValidateSyncSettings.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.modelix.model.sync.bulk.gradle.tasks
1818

1919
import org.gradle.api.DefaultTask
20-
import org.gradle.api.model.ObjectFactory
2120
import org.gradle.api.provider.Property
2221
import org.gradle.api.tasks.CacheableTask
2322
import org.gradle.api.tasks.Input
@@ -28,18 +27,17 @@ import org.modelix.model.sync.bulk.gradle.config.ModelSyncGradleSettings
2827
import org.modelix.model.sync.bulk.gradle.config.ServerSource
2928
import org.modelix.model.sync.bulk.gradle.config.ServerTarget
3029
import org.modelix.model.sync.bulk.gradle.config.SyncDirection
31-
import javax.inject.Inject
3230

3331
/**
3432
* Instead of throwing exceptions for single configuration errors,
3533
* this task collects all configuration errors and puts them into a single exception,
3634
* so the user can see all steps that must be taken at a glance.
3735
*/
3836
@CacheableTask
39-
abstract class ValidateSyncSettings @Inject constructor(of: ObjectFactory) : DefaultTask() {
37+
abstract class ValidateSyncSettings : DefaultTask() {
4038

41-
@Input
42-
val settings: Property<ModelSyncGradleSettings> = of.property(ModelSyncGradleSettings::class.java)
39+
@get:Input
40+
abstract val settings: Property<ModelSyncGradleSettings>
4341

4442
private val errorMsgBuilder = StringBuilder()
4543

0 commit comments

Comments
 (0)