项目目录的顶级禁用皮棉abortOnError在Android的

项目目录的顶级禁用皮棉abortOnError在Android的

本文介绍了如何从多项目目录的顶级禁用皮棉abortOnError在Android的摇篮插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个顶级的Andr​​oid摇篮工程。有嵌套低于该项目(有时他们是2级深),即多个子项目:

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

皮棉正在中止我的生成中的一些库项目。我可以编辑每个库项目的 build.gradle 来修复与

android {
   lintOptions {
      abortOnError false
   }
}

不过,我想preFER在顶层以下code build.gradle 脚本:

subprojects {

    afterEvaluate {
        if (getPlugins().hasPlugin('android') ||
            getPlugins().hasPlugin('android-library')) {

            println name // for debugging

            android {
                lintOptions {
                    abortOnError false
                }
            }
        }

    }
}

条件语句确保挂钩只与一个Android插件项目。我只能得到这个使用afterEvaluate工作。然而,我的构建仍然失败对皮棉的错误。

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?

更新:

重新排列的子项目和afterEvaluate或使用allprojects仍然给出以下同一种错误:

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

堆栈跟踪:

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.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:286)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
Caused by: java.lang.NoClassDefFoundError: [Ljava/util/HashMap$Entry;
        at com.android.build.gradle.internal.dsl.LintOptionsImpl$1.$getStaticMetaClass(LintOptionsImpl.groovy)
        at com.android.build.gradle.internal.dsl.LintOptionsImpl$1.<init>(LintOptionsImpl.groovy)
        at com.android.build.gradle.internal.dsl.LintOptionsImpl.syncTo(LintOptionsImpl.groovy:450)
        at com.android.build.gradle.internal.dsl.LintOptionsImpl$syncTo.call(Unknown Source)
        at com.android.build.gradle.tasks.Lint.lintAllVariants(Lint.groovy:105)
        at com.android.build.gradle.tasks.Lint$lintAllVariants.callCurrent(Unknown Source)
        at com.android.build.gradle.tasks.Lint.lint(Lint.groovy:63)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:530)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:513)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 13 more
Caused by: java.lang.ClassNotFoundException: java.util.HashMap$Entry
        ... 28 more

==============================================================================

BUILD FAILED

Total time: 2 mins 20.757 secs

我可以用 -x皮棉选项运行摇篮构建成功,但要建立一个没有使用命令行选项

I can run gradle build successfully with the -x lint option but want to build without using the commandline options.

推荐答案

我也遇到了类似的情况,但不是仅仅直接修改DSL,我叫配置就可以了,而不是:

I too faced a similar situation, but instead of just modifying the DSL directly, I called configure on it instead:

configure(android.lintOptions) {
    abortOnError false
}

这样一来,我可以禁用 abortOnError 我想要的子项目。底线,您的的子项目块应该是这样的:

As a result, I was able to disable abortOnError for my desired subprojects. Bottom line, your subproject block should look like this:

subprojects {

    afterEvaluate {
        if (getPlugins().hasPlugin('android') ||
            getPlugins().hasPlugin('android-library')) {

            println name // for debugging

            configure(android.lintOptions) {
                abortOnError false
            }
        }

    }
}

这篇关于如何从多项目目录的顶级禁用皮棉abortOnError在Android的摇篮插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 20:26