jakarta-ee - gradle:无法为 org.gradle.api.Project 类型的根项目设置只读属性 'module' 的值

标签 jakarta-ee gradle build ear application.xml

开始使用 somewhere 和 EAR 获取 packaging:

thufir@doge:~/NetBeansProjects/gradleEAR$ 
thufir@doge:~/NetBeansProjects/gradleEAR$ gradle clean ear

FAILURE: Build failed with an exception.

* Where:
Build file '/home/thufir/NetBeansProjects/gradleEAR/build.gradle' line: 32

* What went wrong:
A problem occurred evaluating root project 'gradleEAR'.
> Cannot set the value of read-only property 'module' for root project 'gradleEAR' of type org.gradle.api.Project.

* 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: 11.862 secs
thufir@doge:~/NetBeansProjects/gradleEAR$ 

如何设置 module 属性的值?
plugins {
    id 'com.gradle.build-scan' version '1.8' 
    id 'java'
    id 'application'
    id 'ear'
}

mainClassName = 'net.bounceme.doge.json.Main'

buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}

repositories {
    jcenter()
}

ear {
    manifest {
        attributes 'foo': 'bar'
    }

    deploymentDescriptor {  
                applicationName = "gradleEAR"
                initializeInOrder = true
                displayName = "gradleEAR"
                description = "Trial App EAR for Gradle documentation"
                libraryDirectory = "WEB-INF/lib"
                module = "foo"
/*
                webModule("TrialApp.war", "TrialApp")  
*/
    }

}






jar {
    manifest {
        attributes 'Main-Class': 'net.bounceme.doge.json.Main'
    }
}

task fatJar(type: Jar) {
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': '3.4.0'
        attributes 'Main-Class': 'net.bounceme.doge.json.Main'
    }
}

dependencies {
    compile group: 'javax.json', name: 'javax.json-api', version: '1.1'
    compile group: 'org.glassfish', name: 'javax.json', version: '1.1'
    compileOnly 'javax:javaee-api:7.0'
}

可能有用:

https://discuss.gradle.org/t/set-project-name-property-in-a-test/4333

http://mrhaki.blogspot.ca/2009/11/gradle-goodness-changing-project-name.html

最佳答案

您只能从 settings.gradle 文件中更改项目名称。

rootProject.name = 'foo' 

或任何其他模块也来自这里:
include "foo"
project(":foo").projectDir = file("modules/foo")

关于jakarta-ee - gradle:无法为 org.gradle.api.Project 类型的根项目设置只读属性 'module' 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45829987/

相关文章:

python-3.x - 在 GitLab 中创建一个 pyqt 构建

java - 我们什么时候需要将源附加到 jar

java - 如何在 Hibernate 中进行 SELECT 查询包括子查询 COUNT(*)

spring-boot - 使用gradle BOM和spring-boot(多模块应用程序)哪种方式更好

jar - 如何在Gradle编译依赖项中将jar包含在磁盘上

spring-boot - 在build.gradle.kts中添加后无法导入类

angular - 未知选项 : '--target' , 未知选项: '--environment' ;尝试在 prod 中构建 ng 应用程序时

java - 项目迁移到新目录 - 保留 Git 历史记录

java - 如何阻止目录结构在 J2EE 应用程序中可见

java - EAR 正在打包 WAR 和 JAR 项目的两个副本