I have a top level Android Gradle project. There are multiple subprojects nested below this projects (sometimes they are 2 level deep) i.e:
top level project | project1 vendor libraries | lib1 lib2
lint is aborting my build in some of the libraries projects. I can edit each individual library project's build.gradle
to fix the problem with
android { lintOptions { abortOnError false } }
However, I would prefer the following code in the top level build.gradle
script:
subprojects { afterEvaluate { if (getPlugins().hasPlugin('android') || getPlugins().hasPlugin('android-library')) { println name // for debugging android { lintOptions { abortOnError false } } } } }
The conditional statement makes sure to hook only into projects with an android plugin. I could only get this to work using afterEvaluate. However, my build is still failing on lint errors.
Does anyone have have a clean solution to inject these settings from the top level?
UPDATE:
Rearranging the subprojects and afterEvaluate or using allprojects still gives the same following kind of error:
7: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':3rdparty:OrmLiteQueryBuilder:lint'. > [Ljava/util/HashMap$Entry; * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. ============================================================================== BUILD FAILED Total time: 40.528 secs
Stacktrace:
7: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':3rdparty:OrmLiteQueryBuilder:lint'. > [Ljava/util/HashMap$Entry; * Try: Run with --info or --debug option to get more log output. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':3rdparty:OrmLiteQueryBuilder:lint'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter