【问题标题】:Cannot build gradle project: invalid type code: B3 using Java 11无法构建 gradle 项目:无效类型代码:B3 使用 Java 11
【发布时间】:2019-11-11 17:14:51
【问题描述】:

我正在为该项目使用 Java 11。 Gradle 版本是 5.5。 IntelijIDEA 2019.1.3

所以,当我构建项目时,我得到了错误:

Cause: invalid type code: B3

Stacktrace 告诉我:

org.gradle.internal.exceptions.LocationAwareException: Build file 'D:\project\scripts\build.gradle' line: 21
A problem occurred evaluating project ':scripts'.
    at org.gradle.initialization.exception.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:99)
    at org.gradle.initialization.exception.DefaultExceptionAnalyser.collectFailures(DefaultExceptionAnalyser.java:55)
    at org.gradle.initialization.exception.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
    at org.gradle.initialization.exception.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:29)

命令gradle task dev update 告诉我:

* What went wrong:
A problem occurred evaluating project ':scripts'.
> Could not find method leftShift() for arguments [build_44ncodnspa3jbc57fnmmpuh13$_run_closure1@4c5511e6] on task ':scripts:dev' of type org.gradle.api.DefaultTask.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED

build.gradle 文件中给出错误的代码是:

task("dev") << {
    println "executing dev"
    liquibase {
        activities {
            main {
                changeLogFile changeLog
                classpath "$projectDir/src/main/resources/"
                url 'jdbc:postgresql://localhost:5432/project'
                username 'testName'
                password 'testPassword'
                liquibaseSchemaName 'liquibase'
            }
        }
    }
}

我使用unticking the flag Settings -&gt; Experimental -&gt; Only sync the active variant 的解决方案。

但是我可以通过代码解决问题而不更改 IntelijIDEA 设置吗? 因为syncing the project 作为优化过程很重要。尤其是大型项目。

【问题讨论】:

    标签: java gradle intellij-idea


    【解决方案1】:

    分析找到updated syntax后,稍微改了一下:

    task("dev") {
        doLast {
            println "executing dev"
            liquibase {
                activities {
                    main {
                        changeLogFile changeLog
                        classpath "$projectDir/src/main/resources/"
                        url 'jdbc:postgresql://localhost:5432/project'
                        username 'testName'
                        password 'testPassword'
                        liquibaseSchemaName 'liquibase'
                    }
                }
            }
        }
    }
    

    最终,更新的代码帮助我在不使用 IntelijIDEA 设置的情况下解决了问题。

    gradle task dev update 工作成功。

    【讨论】:

      猜你喜欢
      • 2019-06-27
      • 1970-01-01
      • 2020-01-28
      • 2021-05-25
      • 1970-01-01
      • 2019-03-30
      • 2019-07-16
      • 2016-03-24
      • 1970-01-01
      相关资源
      最近更新 更多