Following this guide:
https://help.github.com/en/articles/configuring-gradle-for-use-with-github-package-registry
But when I apply the gradle's maven-publish to the submodules, I get the following error:
Could not find method publications() for arguments [build_81s2rz8tveop6ddsgghnyy4gk$_run_closure1$_closure4@395cd54] on project ':cms-data-contract' of type org.gradle.api.Project.
and the task fails
I tried to apply the maven-publish plugin explicitly in that subproject but it did not work. The plugin is applied as can be seen in this log statements:
:25:11.198 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply plugin org.gradle.api.publish.plugins.PublishingPlugin to project ':cms-data-contract'' started 14:25:11.198 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Apply plugin org.gradle.api.publish.plugins.PublishingPlugin to project ':cms-data-contract'' 14:25:11.198 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply plugin org.gradle.api.publish.plugins.PublishingPlugin to project ':cms-data-contract'' completed
and
14:22:51.786 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Register task :cms-data-contract:publishAllPublicationsToGitHubPackagesRepository' started 14:22:51.787 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Register task :cms-data-contract:publishAllPublicationsToGitHubPackagesRepository' 14:22:51.787 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Register task :cms-data-contract:publishAllPublicationsToGitHubPackagesRepository' completed
I am using the following:
plugins {
id("maven-publish")
}
subprojects {
apply plugin: "maven-publish"
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GPR_USER"))
password = project.findProperty("gpr.key") ?: System.getenv("GPR_API_KEY"))
}
}
}
publications {
gpr(MavenPublication) {
from(components.java)
}
}
}
}
The guide is suggesting to use:
plugins {
id("maven-publish") apply false
}
but that fails with an exception
I should be able to publish the artefact to the github registry