2

开始包装EAR:_

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-sharing-project-name.html

4

1 回答 1

2

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

rootProject.name = 'foo' 

或任何其他模块也来自这里:

include "foo"
project(":foo").projectDir = file("modules/foo")
于 2019-04-15T13:46:54.640 回答