Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MF-5759 fix stability of stone task output across different machines #547

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import java.io.File
import java.io.FileOutputStream
import javax.inject.Inject
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.ProjectLayout

@CacheableTask
abstract class StoneTask : DefaultTask() {

@get:Inject
abstract val exec: ExecOperations

@get:Inject
abstract val layout: ProjectLayout

@get:Input
abstract val stoneConfigs: ListProperty<StoneConfig>

Expand Down Expand Up @@ -90,6 +94,13 @@ abstract class StoneTask : DefaultTask() {
}
}

// Order of inputs can affect the output of stone
// Sorting spec files by relative path makes order stable across machines
val projectDirectory = layout.projectDirectory.asFile
val sortedSpecFiles = specFiles.sortedBy {
it.toRelativeString(projectDirectory)
}.map { it.absolutePath }.toTypedArray()

stoneConfigs.get().forEachIndexed { index, stoneConfig ->
val isFirst = index == 0
val append: Boolean = !isFirst
Expand All @@ -100,7 +111,7 @@ abstract class StoneTask : DefaultTask() {

generatorFile.get().asFile,
outputDirectory.absolutePath,
*specFiles.map { it.absolutePath }.toTypedArray(),
*sortedSpecFiles,
"--", "--package", stoneConfig.packageName,
)

Expand Down
Loading