Skip to content

Commit

Permalink
refactor project and build
Browse files Browse the repository at this point in the history
  • Loading branch information
moray95 committed Jul 17, 2024
1 parent 95cae60 commit 8d4f3f6
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 105 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,11 @@ jobs:
java-version: "21"
distribution: graalvm
cache: 'gradle'
- name: Validate version
- name: Publish
run: |
VERSION=${GITHUB_REF#refs/tags/}
if grep -Eq "version\s+=\s+\"${VERSION}\"" ./build.gradle.kts
then
echo "Publishing version '${VERSION}'"
./gradlew publish
else
echo "Detected tag version '${VERSION}' and version from build.gradle.kts does not match."
exit 1
fi
- name: Publish
run: ./gradlew publishToCentralPortal
echo "Publishing version '${VERSION}'"
./gradlew "-Pversion=$VERSION" publishToCentralPortal
env:
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SIGNING_SECRETKEY: ${{ secrets.SIGNING_SECRETKEY }}
Expand Down
121 changes: 27 additions & 94 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,114 +1,47 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

repositories {
mavenCentral()
}
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
`java-gradle-plugin`
id("com.github.ben-manes.versions") version "0.51.0"
id("org.springframework.boot") version "3.3.1" apply false
id("io.spring.dependency-management") version "1.1.6"
id("org.jmailen.kotlinter") version "4.4.0"
kotlin("jvm") version "2.0.0"
id("org.jmailen.kotlinter") version "4.4.1"
id("maven-publish")
id("java-library")
kotlin("jvm") version "1.9.21"
id("net.thebugmc.gradle.sonatype-central-portal-publisher") version "1.2.3"
}

group = "com.valensas"
version = "3.0.0"
java.sourceCompatibility = JavaVersion.VERSION_17
subprojects {
apply(plugin = "maven-publish")
apply(plugin="java-library")
apply(plugin="org.jetbrains.kotlin.jvm")
apply(plugin="org.jmailen.kotlinter")

dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
group = "com.valensas"

gradlePlugin {
val observabilityArtifactsPlugin by plugins.creating {
id = "com.valensas.observability-artifacts"
implementationClass = "com.valensas.observability.plugin.ObservabilityArtifactsPlugin"
repositories {
mavenCentral()
}
}

dependencies {
implementation("org.graalvm.polyglot:polyglot:24.0.1")
compileOnly("io.micrometer:micrometer-tracing-bridge-brave")
compileOnly("org.springframework.boot:spring-boot-starter-actuator")
compileOnly("io.github.openfeign:feign-micrometer:13.3")
compileOnly("org.springframework.boot:spring-boot-starter")
compileOnly("org.springframework.boot:spring-boot-starter-webflux")

testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
java.sourceCompatibility = JavaVersion.VERSION_17
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
}

tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<Test> {
useJUnitPlatform()
}

publishing {
publications {
create<MavenPublication>("plugin") {
groupId = "com.valensas.observability-artifacts"
artifactId = "com.valensas.observability-artifacts"
from(components["java"])
}
create<MavenPublication>("artifact") {
groupId = "com.valensas"
artifactId = "observability"
from(components["java"])
}
tasks.getByName<Jar>("jar") {
archiveClassifier = ""
}
}

tasks.getByName<Jar>("jar") {
archiveClassifier = ""
}


signing {
val keyId = System.getenv("SIGNING_KEYID")
val secretKey = System.getenv("SIGNING_SECRETKEY")
val passphrase = System.getenv("SIGNING_PASSPHRASE")

useInMemoryPgpKeys(keyId, secretKey, passphrase)
dependencies {
implementation(kotlin("stdlib-jdk8"))
}

centralPortal {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")

pom {
name = "Observability"
description = "A simple library to manage observability needs for Spring Boot."
url = "https://valensas.com/"
scm {
url = "https://github.com/Valensas/observability"
}

licenses {
license {
name.set("MIT License")
url.set("https://mit-license.org")
}
}

developers {
developer {
id.set("0")
name.set("Valensas")
email.set("[email protected]")
}
}
}
}
70 changes: 70 additions & 0 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
plugins {
id("org.springframework.boot") version "3.3.1" apply false
id("io.spring.dependency-management") version "1.1.6"
id("net.thebugmc.gradle.sonatype-central-portal-publisher") version "1.2.3"
}

dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}

dependencies {
implementation("org.graalvm.polyglot:polyglot:24.0.2")
compileOnly("io.micrometer:micrometer-tracing-bridge-brave")
compileOnly("org.springframework.boot:spring-boot-starter-actuator")
compileOnly("io.github.openfeign:feign-micrometer:13.3")
compileOnly("org.springframework.boot:spring-boot-starter")
compileOnly("org.springframework.boot:spring-boot-starter-webflux")
}


publishing {
publications {
create("library", MavenPublication::class.java) {
artifactId = "observability"
from(components["java"])
}
}
repositories {
mavenLocal()
}
}

signing {
val keyId = System.getenv("SIGNING_KEYID")
val secretKey = System.getenv("SIGNING_SECRETKEY")
val passphrase = System.getenv("SIGNING_PASSPHRASE")

useInMemoryPgpKeys(keyId, secretKey, passphrase)
}

centralPortal {
name = "observability"
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
pom {
name = "Observability"
description = "A simple library to manage observability needs for Spring Boot."
url = "https://valensas.com/"
scm {
url = "https://github.com/Valensas/observability"
}

licenses {
license {
name.set("MIT License")
url.set("https://mit-license.org")
}
}

developers {
developer {
id.set("0")
name.set("Valensas")
email.set("[email protected]")
}
}
}
}
52 changes: 52 additions & 0 deletions plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
plugins {
`java-gradle-plugin`
id("net.thebugmc.gradle.sonatype-central-portal-publisher") version "1.2.3"
}

group = "com.valensas.observability-artifacts"

gradlePlugin {
plugins {
create("artifacts") {
id = "com.valensas.observability-artifacts"
implementationClass = "com.valensas.observability.plugin.ObservabilityArtifactsPlugin"
}
}
}

signing {
val keyId = System.getenv("SIGNING_KEYID")
val secretKey = System.getenv("SIGNING_SECRETKEY")
val passphrase = System.getenv("SIGNING_PASSPHRASE")

useInMemoryPgpKeys(keyId, secretKey, passphrase)
}

centralPortal {
name = "observability-artifacts.gradle.plugin"
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
pom {
name = "Observability Plugins"
description = "A simple library to manage observability needs for Spring Boot."
url = "https://valensas.com/"
scm {
url = "https://github.com/Valensas/observability"
}

licenses {
license {
name.set("MIT License")
url.set("https://mit-license.org")
}
}

developers {
developer {
id.set("0")
name.set("Valensas")
email.set("[email protected]")
}
}
}
}
6 changes: 6 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}
rootProject.name = "observability"

include("library")
include("plugins")

0 comments on commit 8d4f3f6

Please sign in to comment.