gradle: Cannot set the value of read-only property 'module' for root project of type org.gradle.api.Project

10,891

You can change the project name only from settings.gradle file.

rootProject.name = 'foo' 

or any other modules also from here with:

include "foo"
project(":foo").projectDir = file("modules/foo")
Share:
10,891

Related videos on Youtube

Thufir
Author by

Thufir

Updated on May 25, 2022

Comments

  • Thufir
    Thufir about 2 years

    Starting to get somewhere with packaging an 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$ 
    

    How can I set the value for the module property?

    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'
    }
    

    possibly useful:

    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

    • Sundeep Gupta
      Sundeep Gupta over 6 years
      Did you try module 'foo' (removing =)
    • Thufir
      Thufir over 5 years
      pardon, I'm generally trying the gradle kotlin DSL these days.