简体   繁体   English

gradle 无法为项目'获取未知属性'战争'<project name> ' 类型为 org.gradle.api.Project</project>

[英]gradle Could not get unknown property 'war' for project '<project name>' of type org.gradle.api.Project

I have a gradle build with Java sub-projects and had a jacoco task defined in the root build.gradle which I'm moving to the sub-projects that only use it.我有一个带有 Java 子项目的 gradle 构建,并在根 build.gradle 中定义了一个 jacoco 任务,我将移至仅使用它的子项目。

By doing that though I am hitting an issue in the ear deploymentDescriptor task where and there are multiple webModule definitions.通过这样做,尽管我在 ear deploymentDescriptor 任务中遇到了一个问题,其中有多个 webModule 定义。 The error I'm seeing in the IDE and gradle command line is:我在 IDE 和 gradle 命令行中看到的错误是:

A problem occurred evaluating project ':deployear'.
> Could not get unknown property 'war' for project ':sub-project-two' of type org.gradle.api.Project.

My ear build.gradle contains我的耳朵 build.gradle 包含

apply plugin: 'ear'

ear {
    archiveName = 'web-application.ear'
    appDirName 'src/main/application'
    libDirName 'APP-INF/lib'

    deploymentDescriptor {
        fileName = "application.xml"
        version = "1"
        description = "My Web Application"
        initializeInOrder = true
        displayName = "Web Application"
        webModule(project(":sub-project-one").war.archiveName, "context-root/one")
        webModule(project(":sub-project-two").war.archiveName, "context-root/two")
    }
}

If I comment out webModule(project(":sub-project-two").war.archiveName, "context-root/two") then the project builds successfully.如果我注释掉 webModule(project(":sub-project-two").war.archiveName, "context-root/two") 那么项目构建成功。 Both sub-project-one and sub-project-one have java and war plugins applied.子项目一和子项目一都应用了 java 和战争插件。

Is there a reason why moving a jacoco dependency from a parent build.gradle to some sub-project build.gradle files would generate this error?是否有理由将 jacoco 依赖项从父 build.gradle 移动到某些子项目 build.gradle 文件会产生此错误?

Found a work around.找到了解决方法。

In my deployear sub-project I added在我的 deployear 子项目中,我添加了

apply plugin: 'ear'
evaluationDependsOn(':sub-project-two')

and that forced the deployear sub-project to evaluate the sub-project-two project prior to running the ear task.这迫使 deployear 子项目在运行 ear 任务之前评估 sub-project-two 项目。 I thought the same could be done with changing the ordering in the parent settings.gradle but that didn't work for me.我认为通过更改父设置中的排序也可以做到这一点。gradle 但这对我不起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Studio:“无法获得类型为 org.gradle.api.Project 的项目的未知属性‘VERSION_NAME’” - Android Studio : “Could not get unknown property 'VERSION_NAME' for project of type org.gradle.api.Project” 无法为 org.gradle.api.Project 类型的根项目“[redacted]”获取未知属性“artifactory_contextUrl” - Could not get unknown property 'artifactory_contextUrl' for root project '[redacted]' of type org.gradle.api.Project 无法为类型为 org.gradle.api.Project 的项目“:app”获取未知属性“localProperties” - Could not get unknown property 'localProperties' for project ':app' of type org.gradle.api.Project 错误:无法获取类型为 org.gradle.api.Project 的项目“:app”的未知属性“appcompat” - ERROR: Could not get unknown property 'appcompat' for project ':app' of type org.gradle.api.Project 无法为org.gradle.api.Project类型的根项目“MyApplication3”获取未知属性“删除” - Could not get unknown property 'Delete' for root project 'MyApplication3' of type org.gradle.api.Project 无法获得类型为org.gradle.api.Project的项目&#39;:app&#39;的未知属性&#39;VERSION_CODE&#39; - Could not get unknown property 'VERSION_CODE' for project ':app' of type org.gradle.api.Project 无法为类型org.gradle.api.Project的项目&#39;:app&#39;设置未知属性&#39;localProperties&#39; - Could not set unknown property 'localProperties' for project ':app' of type org.gradle.api.Project IntelliJ 无法为 org.gradle.api.Project 类型的根项目“Blue Bot”设置未知属性“mainClassName” - IntelliJ Could not set unknown property 'mainClassName' for root project 'Blue Bot' of type org.gradle.api.Project 无法为org.gradle.api.Project类型的项目':core'设置未知属性'transitive' - Could not set unknown property 'transitive' for project ':core' of type org.gradle.api.Project 由 groovy.lang.MissingPropertyException 引起 Could not get unknown property 'android' for project ':lib1' of type org.gradle.api.Project - Caused by groovy.lang.MissingPropertyException Could not get unknown property 'android' for project ':lib1' of type org.gradle.api.Project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM