Could not get unknown property 'repositoryUrl' for project
Well, this turned out interesting.
The reason
The error pointed to the this line at the React-Native module's release.gradle
:
def getRepositoryUrl() {
return hasProperty('repositoryUrl') ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
Strangely enough, the problem is that hasProperty('repositoryUrl')
returns true
, while property('repositoryUrl')
causes the error.
On gradle 3.1, hasProperty('repositoryUrl')
returns false
.
Apparently in gradle 3.5, hasProperty()
returns true
in cases where the property is indeed missing but still has a getter. In our case the getter is
def getRepositoryUrl() {...}
This is vaguely explained here.
There is however another method of checking for properties, which ignores getters, named findProperty.
The fix
So the fix was to change the following block from release.gradle
:
def getRepositoryUrl() {
return hasProperty('repositoryUrl') ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
def getRepositoryUsername() {
return hasProperty('repositoryUsername') ? property('repositoryUsername') : ''
}
def getRepositoryPassword() {
return hasProperty('repositoryPassword') ? property('repositoryPassword') : ''
}
To this:
def getRepositoryUrl() {
return findProperty('repositoryUrl') != null ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
def getRepositoryUsername() {
return findProperty('repositoryUsername') !=null ? property('repositoryUsername') : ''
}
def getRepositoryPassword() {
return findProperty('repositoryPassword') != null ? property('repositoryPassword') : ''
}
More pains experienced while building the RN module from source here.