diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/GraphQLDocumentParser.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/GraphQLDocumentParser.kt index 207f83c0974..210452a9cac 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/GraphQLDocumentParser.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/GraphQLDocumentParser.kt @@ -50,7 +50,7 @@ class GraphQLDocumentParser(val schema: Schema) { throw RuntimeException("Failed to read GraphQL file `$this`", e) } - val tokenStream = GraphQLLexer(CharStreams.fromString(document)) + val tokenStream = GraphQLLexer(ANTLRInputStream(document)) .apply { removeErrorListeners() } .let { CommonTokenStream(it) } @@ -577,7 +577,7 @@ private class GraphQLDocumentParseException( companion object { private fun preview(graphQLFilePath: String, document: String, parseException: ParseException): String { val documentLines = document.lines() - return "\nFailed to parse GraphQL file $graphQLFilePath (${parseException.line}:${parseException.position}) ${parseException.message}" + + return "\nFailed to parse GraphQL file $graphQLFilePath (${parseException.line}:${parseException.position})\n${parseException.message}" + "\n----------------------------------------------------\n" + parseException.let { error -> val prefix = if (error.line - 2 >= 0) { diff --git a/apollo-gradle-plugin/src/main/groovy/com/apollographql/apollo/gradle/ApolloPlugin.groovy b/apollo-gradle-plugin/src/main/groovy/com/apollographql/apollo/gradle/ApolloPlugin.groovy index 6c10a05d2ae..7118f6d6839 100644 --- a/apollo-gradle-plugin/src/main/groovy/com/apollographql/apollo/gradle/ApolloPlugin.groovy +++ b/apollo-gradle-plugin/src/main/groovy/com/apollographql/apollo/gradle/ApolloPlugin.groovy @@ -73,20 +73,10 @@ class ApolloPlugin implements Plugin { if (isAndroidProject()) { getVariants().all { BaseVariant variant -> - if (useExperimentalCodegen) { - ApolloExperimentalCodegenTask codegenTask = createExperimentalCodegenTask(variant.name, variant.sourceSets) - apolloClassGenTask.dependsOn(codegenTask) - } else { - addVariantTasks(variant, apolloIRGenTask, apolloClassGenTask, variant.sourceSets) - } + addVariantTasks(variant, apolloIRGenTask, apolloClassGenTask, variant.sourceSets) } project.android.testVariants.each { BaseVariant tv -> - if (useExperimentalCodegen) { - ApolloExperimentalCodegenTask codegenTask = createExperimentalCodegenTask(tv.name, tv.sourceSets) - apolloClassGenTask.dependsOn(codegenTask) - } else { - addVariantTasks(tv, apolloIRGenTask, apolloClassGenTask, tv.sourceSets) - } + addVariantTasks(tv, apolloIRGenTask, apolloClassGenTask, tv.sourceSets) } } else { getSourceSets().all { SourceSet sourceSet -> @@ -96,11 +86,17 @@ class ApolloPlugin implements Plugin { } private void addVariantTasks(BaseVariant variant, Task apolloIRGenTask, Task apolloClassGenTask, Collection sourceSets) { - AbstractTask variantIRTask = createApolloIRGenTask(variant.name, sourceSets) - ApolloClassGenerationTask variantClassTask = createApolloClassGenTask(variant.name) - variant.registerJavaGeneratingTask(variantClassTask, variantClassTask.outputDir.asFile.get()) - apolloIRGenTask.dependsOn(variantIRTask) - apolloClassGenTask.dependsOn(variantClassTask) + if (useExperimentalCodegen) { + ApolloExperimentalCodegenTask codegenTask = createExperimentalCodegenTask(variant.name, variant.sourceSets) + variant.registerJavaGeneratingTask(codegenTask, codegenTask.outputDir.asFile.get()) + apolloClassGenTask.dependsOn(codegenTask) + } else { + AbstractTask variantIRTask = createApolloIRGenTask(variant.name, sourceSets) + ApolloClassGenerationTask variantClassTask = createApolloClassGenTask(variant.name) + variant.registerJavaGeneratingTask(variantClassTask, variantClassTask.outputDir.asFile.get()) + apolloIRGenTask.dependsOn(variantIRTask) + apolloClassGenTask.dependsOn(variantClassTask) + } } private void addSourceSetTasks(SourceSet sourceSet, Task apolloIRGenTask, Task apolloClassGenTask) { diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index b09c1c7cfe8..c7f936edfca 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -1,6 +1,6 @@ def versions = [ apolloVersion : '1.0.3-SNAPSHOT', - antlr4 : '4.7.2', + antlr4 : '4.5.3', cacheVersion : '2.0.2', okHttpVersion : '3.12.2', kotlinVersion : '1.3.30',