Skip to content

Commit

Permalink
Merge pull request #547 from dropbox/MF-5759
Browse files Browse the repository at this point in the history
MF-5759 fix stability of stone task output across different machines
  • Loading branch information
adecker89 authored Aug 22, 2024
2 parents 80ef16a + 9794891 commit 99c78ef
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit 99c78ef

Please sign in to comment.