@@ -12,13 +12,17 @@ import java.io.File
1212import java.io.FileOutputStream
1313import javax.inject.Inject
1414import org.gradle.api.file.ConfigurableFileCollection
15+ import org.gradle.api.file.ProjectLayout
1516
1617@CacheableTask
1718abstract class StoneTask : DefaultTask () {
1819
1920 @get:Inject
2021 abstract val exec: ExecOperations
2122
23+ @get:Inject
24+ abstract val layout: ProjectLayout
25+
2226 @get:Input
2327 abstract val stoneConfigs: ListProperty <StoneConfig >
2428
@@ -90,6 +94,13 @@ abstract class StoneTask : DefaultTask() {
9094 }
9195 }
9296
97+ // Order of inputs can affect the output of stone
98+ // Sorting spec files by relative path makes order stable across machines
99+ val projectDirectory = layout.projectDirectory.asFile
100+ val sortedSpecFiles = specFiles.sortedBy {
101+ it.toRelativeString(projectDirectory)
102+ }.map { it.absolutePath }.toTypedArray()
103+
93104 stoneConfigs.get().forEachIndexed { index, stoneConfig ->
94105 val isFirst = index == 0
95106 val append: Boolean = ! isFirst
@@ -100,7 +111,7 @@ abstract class StoneTask : DefaultTask() {
100111
101112 generatorFile.get().asFile,
102113 outputDirectory.absolutePath,
103- * specFiles.map { it.absolutePath }.toTypedArray() ,
114+ * sortedSpecFiles ,
104115 " --" , " --package" , stoneConfig.packageName,
105116 )
106117
0 commit comments