Accessing project.properties before configuring 'publishing' extension causes a strange error

apply plugin: 'maven-publish'

println properties['some.property']

publishing {
    publications {
        maven(MavenPublication) {
        }   
    }   
}

The above script causes the error with the message below when running it with gradle tasks command:

* Where:
Build file '/Users/kt3k/tmp/gradle-test/build.gradle' line: 5

* What went wrong:
A problem occurred evaluating root project 'gradle-test'.
> Cannot configure the 'publishing' extension after it has been accessed.

The error message seems strange because nothing accesses the publishing extension before the line 5 and this is inconvenient when I want to access to properties before configuring publishing block.

Gradle Version: 3.1
Operating System: Mac OS X 10.12 x86_64
JVM: 1.8.0_65 (Oracle Corporation 25.65-b01)

1 Like