Override to set sonatype nexus URL/credentials

Hello - We are following this document - Maven Publish Plugin where we are using this " ./gradlew publish" and it is failing with below “element” error, please help to provide the answer on how to override and set the value of credentials (defined in ~/.gradle/gradle.properties.kts). Yes, we are using “kotlin”.

e: /mnt/jenkins/hk/pgjdbc/pgjdbc/build.gradle.kts:395:40: Expecting an element
e: /mnt/jenkins/hk/pgjdbc/pgjdbc/build.gradle.kts:391:34: Property delegate must have a 'getValue(Nothing?, KProperty<>)’ method. None of the following functions is suitable:
public abstract operator fun getValue(receiver: Any?, property: KProperty<
>): ??? defined in org.gradle.kotlin.dsl.PropertyDelegate
e: /mnt/jenkins/hk/pgjdbc/pgjdbc/build.gradle.kts:392:34: Property delegate must have a 'getValue(Nothing?, KProperty<>)’ method. None of the following functions is suitable:
public abstract operator fun getValue(receiver: Any?, property: KProperty<
>): ??? defined in org.gradle.kotlin.dsl.PropertyDelegate
e: /mnt/jenkins/hk/pgjdbc/pgjdbc/build.gradle.kts:394:27: Unresolved reference: nexusUsername
e: /mnt/jenkins/hk/pgjdbc/pgjdbc/build.gradle.kts:398:18: Unresolved reference: basic
e: /mnt/jenkins/hk/pgjdbc/pgjdbc/build.gradle.kts:398:24: Function invocation ‘BasicAuthentication(…)’ expected
e: /mnt/jenkins/hk/pgjdbc/pgjdbc/build.gradle.kts:398:24: No value passed for parameter ‘function’

Below is the piece of the script using…

publishing {
repositories {
maven {
val releasesRepoUrl = “http://example.com:8081/content/repositories/releases
val snapshotsRepoUrl = “http://example.com:8081/content/repositories/snapshots
url = uri(if (version.toString().endsWith(“SNAPSHOT”)) snapshotsRepoUrl else releasesRepoUrl)
val nexusUsername:string by project
val nexusPassword:string by project
credentials {
username nexusUsername
password nexusPassword
}
authentication {
basic(BasicAuthentication)
}
}
}
}

You are mixing Kotlin and Groovy DSL.
If you open this in a proper IDE like IntelliJ, it should also show that it is not valid.
Should probably be

publishing {
    repositories {
        maven {
            val releasesRepoUrl = "http://example.com:8081/content/repositories/releases"
            val snapshotsRepoUrl = "http://example.com:8081/content/repositories/snapshots"
            url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
            val nexusUsername: String by project
            val nexusPassword: String by project
            credentials {
                username = nexusUsername
                password = nexusPassword
            }
            authentication {
                create<BasicAuthentication>("basic")
            }
        }
    }
}