Skip to content

Commit

Permalink
Publish :core to maven central repository (#29)
Browse files Browse the repository at this point in the history
* Publish to MavenCentral

* Change to use com.vanniktech:gradle-maven-publish-plugin

* Update README
  • Loading branch information
lavenderses authored May 18, 2024
1 parent 21bcab3 commit 1d0debb
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ build
/.idea/modules

access.log

.ignore.gradle.properties
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ See AWS AppConfig documentation for what is AWS AppConfig.

First of all, install this library from Maven central repository.

The latest version is in here:
https://central.sonatype.com/artifact/io.github.lavenderses/aws-appconfig-openfeature-provider-java/overview

```gradle
dependencies {
implementation 'io.github.lavenderses:aws-appconfig-openfeature-provider-java:0.3.0'
Expand Down
5 changes: 5 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ gradlePlugin {
id = libs.plugins.aws.appconfig.openfeature.provider.lint.kotlin.get().pluginId
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.KotlinLintPlugin"
}
register(libs.plugins.aws.appconfig.openfeature.provider.publication.get().pluginId) {
id = libs.plugins.aws.appconfig.openfeature.provider.publication.get().pluginId
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.PublicationPlugin"
}
register(libs.plugins.aws.appconfig.openfeature.provider.test.get().pluginId) {
id = libs.plugins.aws.appconfig.openfeature.provider.test.get().pluginId
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.TestPlugin"
Expand All @@ -35,4 +39,5 @@ dependencies {
implementation(libs.ktlint.gradle.plugin)
implementation(libs.lombok.gradle.plugin)
implementation(libs.spotbugs.gradle.plugin)
implementation(libs.gradle.maven.publish.plugin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ import org.gradle.api.Project
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.plugins.JavaTestFixturesPlugin
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension

class BasePlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
group = "io.github.lavenderses"

with(pluginManager) {
// first party plugin
apply(TestPlugin::class.java)
Expand All @@ -26,6 +22,9 @@ class BasePlugin : Plugin<Project> {
apply(libs.findPlugin("kotlin-jvm").get().get().pluginId)
}

group = projectGroupId
version = projectVersion

with(repositories) {
mavenCentral()
}
Expand All @@ -50,12 +49,6 @@ class BasePlugin : Plugin<Project> {
// bom
implementation(platform(libs.findLibrary("aws-bom").get()))
}

tasks.withType<Jar> {
println("aws-app-config-openfeature-provider-java-${project.name}")
group = "io.github.lavenderses"
archiveBaseName.set("aws-app-config-openfeature-provider-java-${project.name}")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ val Project.PROJECT_JDK: JdkVersion

val Project.libs: VersionCatalog get() = extensions.getByType<VersionCatalogsExtension>().named("libs")

val Project.publicationName: String get() = "maven"

val Project.projectGroupId: String get() = "io.github.lavenderses"

val Project.projectVersion: String get() = "0.3.0"

fun DependencyHandler.implementation(dependencyNotation: Any) {
add("implementation", dependencyNotation)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.github.lavenderses.aws_appconfig_openfeature_provider.plugin

import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.tasks.GenerateModuleMetadata
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType

class PublicationPlugin: Plugin<Project> {

override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply(MavenPublishPlugin::class.java)
apply(com.vanniktech.maven.publish.MavenPublishPlugin::class.java)
}

with(extensions.getByType<MavenPublishBaseExtension>()) {
coordinates(projectGroupId, "aws-appconfig-openfeature-provider-java", projectVersion)

publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
signAllPublications()

pom {
inceptionYear.set("2024")
url.set("https://github.com/lavenderses/AWSAppConfig-OpenFeature-provider-java")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://github.com/lavenderses/AWSAppConfig-OpenFeature-provider-java/blob/main/LICENSE")
}
}

developers {
developer {
id.set("lavenderses")
name.set("cat")
email.set(System.getenv("EMAIL"))
}
}

scm {
url.set("https://github.com/lavenderses/AWSAppConfig-OpenFeature-provider-java")
}
}
}

tasks.withType<GenerateModuleMetadata> {
// TODO: Remove kotlinSourcesJar
dependsOn("kotlinSourcesJar", "plainJavadocJar")
}
}
}
}
29 changes: 9 additions & 20 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.projectGroupId
import io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.projectVersion

plugins {
`maven-publish`
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.aws.appconfig.openfeature.provider.java)
alias(libs.plugins.aws.appconfig.openfeature.provider.lint.kotlin)
alias(libs.plugins.aws.appconfig.openfeature.provider.publication)
}

description = "OpenFeature Provider third-party implementation for AWS AppConfig in Java"
Expand All @@ -20,26 +24,11 @@ dependencies {
testFixturesImplementation(libs.jackson.databind)
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "io.github.lavenderses"
artifactId = "aws-appconfig-openfeature-provider-java"
version = "0.1.0"

from(components["java"])
mavenPublishing {
coordinates(projectGroupId, "aws-appconfig-openfeature-provider-java", projectVersion)

pom {
name.set("aws-appconfig-openfeature-provider-java")
description.set("OpenFeature Provider third-party implementation for AWS AppConfig in Java")
url.set("https://github.com/lavenderses/AWSAppConfig-OpenFeature-provider-java")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
pom {
name.set("OpenFeature Provider implementation for AWS AppConfig in Java")
description.set("OpenFeature Provider third-party implementation for AWS AppConfig in Java")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.jetbrains.annotations.Nullable;

/**
* Common interface between AWS AppConfig instance <-> Provider implementation.
* Common interface between AWS AppConfig instance &lt;-&gt; Provider implementation.
* <br/>
* <b>The reason this interface is required</b>
* <br/>
Expand Down
Empty file added gradle.properties
Empty file.
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ aws-appconfig-openfeature-provider-base = { id = "aws-appconfig-openfeature-prov
aws-appconfig-openfeature-provider-java = { id = "aws-appconfig-openfeature-provider-java", version = "unspecified" }
aws-appconfig-openfeature-provider-kotlin = { id = "aws-appconfig-openfeature-provider-kotlin", version = "unspecified" }
aws-appconfig-openfeature-provider-lint-kotlin = { id = "aws-appconfig-openfeature-provider-lint-kotlin", version = "unspecified" }
aws-appconfig-openfeature-provider-publication = { id = "aws-appconfig-openfeature-provider-pubication", version = "unspecified" }
aws-appconfig-openfeature-provider-test = { id = "aws-appconfig-openfeature-provider-test", version = "unspecified" }

[libraries]
Expand Down Expand Up @@ -54,6 +55,7 @@ lombok-gradle-plugin = { module = "io.freefair.gradle:lombok-plugin", version =
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
ktlint-gradle-plugin = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint-gradle" }
spotbugs-gradle-plugin = { module = "com.github.spotbugs.snom:spotbugs-gradle-plugin", version = "6.0.14" }
gradle-maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.28.0" }

# testing
assertk = { module = "com.willowtreeapps.assertk:assertk", version = "0.28.1" }
Expand Down

0 comments on commit 1d0debb

Please sign in to comment.