Skip to content

Commit

Permalink
fix(maven-publication): Fix artifactId from base name #63
Browse files Browse the repository at this point in the history
  • Loading branch information
zero88 committed Nov 3, 2023
1 parent 12e99f3 commit a8c93fc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.parallel=true
# Project properties --------------------------
title=PlayIO Gradle Plugin
description=Gradle Plugin for open source and PlayIO application
version=0.2.0
version=0.2.1
semanticVersion=-SNAPSHOT
buildBy=local
buildHash=
Expand Down
54 changes: 28 additions & 26 deletions src/main/kotlin/cloud/playio/gradle/OSSProjectPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,15 @@ class OSSProjectPlugin : Plugin<Project>, PluginConstraint, ProjectConstraint {
.configure { distributionBaseName.set(ossExt.baseName) }

configure<PublishingExtension> {
publications { addMavenPublication(project, ossExt) }
repositories { addGitHubRegistry(project, ossExt) }
project.afterEvaluate { publications { withType<MavenPublication> { addPomMetadata(ossExt) } } }
project.afterEvaluate {
publications {
if (ossExt.publishing.enabled.get()) {
addMavenPublication(project, ossExt)
withType<MavenPublication> { addPomMetadata(ossExt) }
}
}
repositories { addGitHubRegistry(project, ossExt) }
}
}

configure<SigningExtension> {
Expand All @@ -140,35 +146,31 @@ class OSSProjectPlugin : Plugin<Project>, PluginConstraint, ProjectConstraint {
}

private fun PublicationContainer.addMavenPublication(project: Project, ossExt: OSSExtension) {
if (ossExt.publishing.enabled.get()) {
create<MavenPublication>(ossExt.publishing.mavenPublicationName.get()) {
groupId = project.group as String?
artifactId = ossExt.baseName.get()
version = project.version as String?
from(project.components["java"])

versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
create<MavenPublication>(ossExt.publishing.mavenPublicationName.get()) {
groupId = project.group as String?
artifactId = ossExt.baseName.get()
version = project.version as String?
from(project.components["java"])

versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}

private fun RepositoryHandler.addGitHubRegistry(project: Project, ossExt: OSSExtension) {
project.afterEvaluate {
if (ossExt.githubConfig.publishToRegistry.get()) {
maven {
name = "GitHubPackages"
url = project.uri(ossExt.githubConfig.getProjectRegistryUrl())
credentials {
username = prop(project, NexusConfig.USER_KEY)
password = prop(project, NexusConfig.PASSPHRASE_KEY)
}
if (ossExt.githubConfig.publishToRegistry.get()) {
maven {
name = "GitHubPackages"
url = project.uri(ossExt.githubConfig.getProjectRegistryUrl())
credentials {
username = prop(project, NexusConfig.USER_KEY)
password = prop(project, NexusConfig.PASSPHRASE_KEY)
}
}
}
Expand Down

0 comments on commit a8c93fc

Please sign in to comment.