@@ -9,6 +9,7 @@ import com.apollographql.apollo.compiler.toJson
9
9
import org.gradle.api.DefaultTask
10
10
import org.gradle.api.provider.Property
11
11
import org.gradle.api.tasks.Input
12
+ import org.gradle.api.tasks.InputFile
12
13
import org.gradle.api.tasks.Optional
13
14
import org.gradle.api.tasks.OutputFile
14
15
import org.gradle.api.tasks.TaskAction
@@ -20,11 +21,24 @@ abstract class ApolloConvertSchemaTask: DefaultTask() {
20
21
@get:Option(option = " from" , description = " schema to convert from" )
21
22
abstract val from: Property <String >
22
23
23
- @get:OutputFile
24
+ // Even if this is points to an output file, for the purpose of the task this is seen as an input
25
+ @get:Input
24
26
@get:Option(option = " to" , description = " schema to convert to" )
25
27
abstract val to: Property <String >
26
28
29
+ init {
30
+ /* *
31
+ * This task is really meant to be called from the command line so don't do any up-to-date checks
32
+ * If someone wants to register its own conversion task, it should be easy to do using the
33
+ * compiler APIs directly (see [convert] below)
34
+ * This code actually redundant because the task has no output but adding it make it explicit.
35
+ */
36
+ outputs.upToDateWhen { false }
37
+ outputs.cacheIf { false }
38
+ }
39
+
27
40
private fun File.isIntrospection () = extension == " json"
41
+
28
42
fun convert (from : File , to : File ) {
29
43
check (from.isIntrospection() && ! to.isIntrospection() || ! from.isIntrospection() && to.isIntrospection()) {
30
44
" Cannot convert from ${from.name} to ${to.name} , they are already the same format"
0 commit comments