Liberty Tom
11/17/2024, 9:09 AMpublish.gradle.kts
in my root project.
apply(plugin = "maven-publish")
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
repositories {
maven {
url = uri(extra["NEXUS_MAVEN_REPO_URL"] as String)
isAllowInsecureProtocol = true
credentials {
username = extra["NEXUS_MAVEN_USERNAME"] as String
password = extra["NEXUS_MAVEN_PASSWORD"] as String
}
}
}
}
Then i include it in my module build.gradle.kts
like below
apply("../publish.gradle.kts")
Then i sync the project, it shows the below error, so how to fix it? The gradle version is 8.7
Expression 'publishing' cannot be invoked as a function. The function 'invoke()' is not found
Chrimaeon
11/17/2024, 9:38 AMChrimaeon
11/17/2024, 9:39 AMChrimaeon
11/17/2024, 9:42 AMVampire
11/17/2024, 10:14 AMpublishing { ... }
. Those you only get in build scripts and precompiled script plugins, and only for plugins that are applied in the recommended plugins { ... }
block, and only for things those plugins add unconditionally.
So yeah, a convention plugin in buildSrc
or - what I prefer - in an included build, for example implemented as precompiled script plugin is the proper way to reuse build logic.