Disable maven-publish plugin

I’m looking to disable the maven-publish plugin if a property is set.
When the publish runs it is running publishDefaultPublicationToMavenLocalRepository so I’m trying to skip this task.
I have tried:
publishing {
publishDefaultPublicationToMavenLocalRepository .onlyIf { !project.hasProperty(‘EXCLUDE_PROPERTY_FILES’) }
}
and
tasks.withType(publishDefaultPublicationToMavenLocalRepository) {
onlyIf {
!project.hasProperty(‘EXCLUDE_PROPERTY_FILES’)
}
}
but I get the message A problem occurred evaluating project ‘:eqa-apps-edorg-accreditation-extension-properties’.

Could not get unknown property ‘publishDefaultPublicationToMavenLocalRepository’ for project ‘:eqa-apps-edorg-accreditation-extension-properties’ of type org.gradle.api.Project.

I’m using gradle 4.5.1

Any help would be greatly appreciated