【问题标题】:Could not get unknown property 'compile' for configuration container无法获取配置容器的未知属性 \'compile\'
【发布时间】:2022-11-03 02:22:15
【问题描述】:

需要帮助:我正在尝试将 gradle 版本升级到 7.4.2 但看到以下错误

  • 出了什么问题: 评估根项目“服务”时出现问题。 无法为 org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer 类型的配置容器获取未知属性“编译”。

它来自以下代码行

war{

    archiveName 'xyz-svc-clt.war'
    
    manifest{
        attributes "Weblogic-Application-Version":  getBuildVersion(),
                   "Built-By": "${env.USERNAME}",
                   "Built-On": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), 
                   "Class-Path": configurations.compile.collect { it.getName() }.join(' ')
        
    }
    
    if (isDev() == false){
        rootSpec.exclude("**/*_log4j.xml")
        rootSpec.exclude("**/*.properties")
    }   
    
    from('src/main/resources/'){
        include 'handler-chain.xml'
        into 'WEB-INF/classes/com/abc/xyz/service/xyzService/'      
    }
    
    from('src/main/resources/'){
        include 'handler-chain.xml'
        into 'WEB-INF/classes/com/abc/xyz/service/xyzService/notification/'
    }   
}

我查看了类似的问题并尝试了不同的解决方案,但对我没有任何帮助。在添加以下行后修改了configurations.compile到configurations.implementation,但它不起作用。

project.configurations.implementation.setCanBeResolved(true)

我的代码中还有以下插件

apply plugin: 'java'
apply plugin: 'war'

【问题讨论】:

  • 最有可能与插件部分有关;确保定义了 java 或 war。
  • 我已经添加了两个插件 apply plugin: 'java' apply plugin: 'war'

标签: java gradle gradlew


【解决方案1】:

以下更改对我有用

war{

    archiveName 'xyz-svc-clt.war'
    
    manifest{
        attributes "Weblogic-Application-Version":  getBuildVersion(),
                   "Built-By": "${env.USERNAME}",
                   "Built-On": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), 
                   "Class-Path": configurations.compileClasspath.collect { it.getName() }.join(' ')
        
    }
    
    if (isDev() == false){
        rootSpec.exclude("**/*_log4j.xml")
        rootSpec.exclude("**/*.properties")
    }   
    
    from('src/main/resources/'){
        include 'handler-chain.xml'
        into 'WEB-INF/classes/com/abc/xyz/service/xyzService/'      
    }
    
    from('src/main/resources/'){
        include 'handler-chain.xml'
        into 'WEB-INF/classes/com/abc/xyz/service/xyzService/notification/'
    }   
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-10
    • 2021-01-30
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多