Skip to content

Commit af4f3ba

Browse files
committed
feat(bulk-model-sync-gradle): configuration options for sync with subtree-skipping
1 parent 1ee1f81 commit af4f3ba

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,17 @@ class ModelSyncGradlePlugin : Plugin<Project> {
7777
) {
7878
val baseDir = project.layout.buildDirectory.dir("model-sync").get().asFile.apply { mkdirs() }
7979
val jsonDir = baseDir.resolve(syncDirection.name).apply { mkdir() }
80-
val sourceTask = when (syncDirection.source) {
80+
val source = syncDirection.source
81+
82+
val sourceTask = when (source) {
8183
is LocalSource -> registerTasksForLocalSource(syncDirection, previousTask, jsonDir)
82-
is ServerSource -> registerTasksForServerSource(syncDirection, project, previousTask, jsonDir)
84+
is ServerSource -> {
85+
if (source.baseRevision != null) {
86+
previousTask
87+
} else {
88+
registerTasksForServerSource(syncDirection, project, previousTask, jsonDir)
89+
}
90+
}
8391
else -> error("Unknown sync direction source")
8492
}
8593

@@ -196,9 +204,10 @@ class ModelSyncGradlePlugin : Plugin<Project> {
196204
val localTarget = syncDirection.target as LocalTarget
197205
val importName = "${syncDirection.name}ImportIntoMps"
198206
val resolvedDependencies = mpsDependencies.resolvedConfiguration.files
207+
val hasBaseRevision = (syncDirection.source as? ServerSource)?.baseRevision != null
199208
val config = MPSRunnerConfig(
200209
mainClassName = "org.modelix.mps.model.sync.bulk.MPSBulkSynchronizer",
201-
mainMethodName = "importRepository",
210+
mainMethodName = if (hasBaseRevision) "importRepositoryFromModelServer" else "importRepository",
202211
classPathElements = resolvedDependencies.toList(),
203212
mpsHome = localTarget.mpsHome,
204213
workDir = jsonDir,
@@ -209,6 +218,10 @@ class ModelSyncGradlePlugin : Plugin<Project> {
209218
"-Dmodelix.mps.model.sync.bulk.input.modules.prefixes=${syncDirection.includedModulePrefixes.joinToString(",")}",
210219
"-Dmodelix.mps.model.sync.bulk.repo.path=${localTarget.repositoryDir?.absolutePath}",
211220
"-Dmodelix.mps.model.sync.bulk.input.continueOnError=${syncDirection.continueOnError}",
221+
"-Dmodelix.mps.model.sync.bulk.server.repository=${(syncDirection.source as ServerSource).repositoryId}".takeIf { hasBaseRevision },
222+
"-Dmodelix.mps.model.sync.bulk.server.url=${(syncDirection.source as ServerSource).url}".takeIf { hasBaseRevision },
223+
"-Dmodelix.mps.model.sync.bulk.server.version.hash=${(syncDirection.source as ServerSource).revision}".takeIf { hasBaseRevision },
224+
"-Dmodelix.mps.model.sync.bulk.server.version.base.hash=${(syncDirection.source as ServerSource).baseRevision}".takeIf { hasBaseRevision },
212225
"-Xmx${localTarget.mpsHeapSize}",
213226
localTarget.mpsDebugPort?.let { "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=$it" },
214227
),

bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/config/ModelSyncGradleSettings.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ data class ServerSource(
153153
override var branchName: String? = null,
154154
override var requestTimeoutSeconds: Int = DEFAULT_REQUEST_TIMEOUT_SECONDS,
155155
var revision: String? = null,
156+
var baseRevision: String? = null,
156157
) : ServerEndpoint {
157158
override fun getValidationErrors(): List<String> {
158159
val errors = mutableListOf<String>()

docs/global/modules/core/pages/reference/component-bulk-model-sync-gradle.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ mpsBuild {
117117
=== ServerSource/-Target configuration
118118
[WARNING]
119119
--
120-
In the future you will be required to specify a `repositoryId` along the`revision`.
120+
In the future you will be required to specify a `repositoryId` along the `revision`.
121121
--
122122
[%header, cols="1,1,2"]
123123
|===
@@ -144,6 +144,10 @@ If the target branch does not exist on the model-server, it will be created.
144144
|Source model-server revision. Can be used instead of `repositoryId` and `branchName`.
145145
Only available in ServerSource.
146146

147+
|`baseRevision`
148+
|String
149+
|Source model-server base revision. If specified, only the subtrees that changed between `baseRevision` and `revision` will be synchronized. Only available in ServerSource.
150+
147151
|`requestTimeoutSeconds`
148152
|Integer
149153
|The request timeout measured in seconds to apply when performing HTTP requests towards the model-server.

0 commit comments

Comments
 (0)