Skip to content

Commit

Permalink
Downgrade ANTLR version as new version is not compatible with AS (#1488)
Browse files Browse the repository at this point in the history
* Downgrade ANTLR version as new version is not compatible with AS

* Small fixes
  • Loading branch information
sav007 authored Aug 11, 2019
1 parent 0fe6a98 commit 53186de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,10 @@ class ApolloPlugin implements Plugin<Project> {

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 ->
Expand All @@ -96,11 +86,17 @@ class ApolloPlugin implements Plugin<Project> {
}

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) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 53186de

Please sign in to comment.