Skip to content

Commit

Permalink
Merge pull request #28 from MohamedRejeb/0.x
Browse files Browse the repository at this point in the history
Add convention plugins and new targets
  • Loading branch information
MohamedRejeb committed Dec 2, 2023
2 parents 2574f36 + 5cd9302 commit f0c6794
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 76 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Deploy to central

on: workflow_dispatch

permissions:
contents: read

jobs:
build:
uses: ./.github/workflows/gradle.yml
deploy:
needs: build
strategy:
matrix:
include:
- target: publishAllPublicationsToSonatypeRepository
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3
with:
path: |
~/.konan
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Gradle publish
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
with:
arguments: |
${{ matrix.target }}
closeAndReleaseSonatypeStagingRepository
env:
OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
OSSRH_GPG_SECRET_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
76 changes: 4 additions & 72 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
alias(libs.plugins.multiplatform).apply(false)
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinx.kover).apply(false)
}

Expand All @@ -9,80 +10,11 @@ allprojects {
mavenCentral()
}

group = "com.mohamedrejeb.ksoup"
version = "0.3.0"

apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "org.jetbrains.kotlinx.kover")

extensions.configure<PublishingExtension> {
repositories {
maven {
val isSnapshot = version.toString().endsWith("SNAPSHOT")
url = uri(
if (!isSnapshot) "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
else "https://s01.oss.sonatype.org/content/repositories/snapshots"
)

credentials {
username = System.getenv("OssrhUsername")
password = System.getenv("OssrhPassword")
}
}
}

val javadocJar = tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
}

publications {
withType<MavenPublication> {
artifact(javadocJar)

pom {
name.set("Ksoup")
description.set("A lightweight Kotlin Multiplatform library to parse HTML/XML data.")
licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
url.set("https://github.com/MohamedRejeb/Ksoup")
issueManagement {
system.set("Github")
url.set("https://github.com/MohamedRejeb/Ksoup/issues")
}
scm {
connection.set("https://github.com/MohamedRejeb/Ksoup.git")
url.set("https://github.com/MohamedRejeb/Ksoup")
}
developers {
developer {
name.set("Mohamed Rejeb")
email.set("mohamedrejeb445@gmail.com")
}
}
}
}
}
}

val publishing = extensions.getByType<PublishingExtension>()
extensions.configure<SigningExtension> {
useInMemoryPgpKeys(
System.getenv("SigningKeyId"),
System.getenv("SigningKey"),
System.getenv("SigningPassword"),
)

sign(publishing.publications)
}

// TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed
project.tasks.withType(AbstractPublishToMaven::class.java).configureEach {
dependsOn(project.tasks.withType(Sign::class.java))
}
// project.tasks.withType(AbstractPublishToMaven::class.java).configureEach {
// dependsOn(project.tasks.withType(Sign::class.java))
// }

}
7 changes: 7 additions & 0 deletions convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.nexus.publish)
}
21 changes: 21 additions & 0 deletions convention-plugins/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}

dependencyResolutionManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
62 changes: 62 additions & 0 deletions convention-plugins/src/main/kotlin/module.publication.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.`maven-publish`

plugins {
`maven-publish`
signing
}

publishing {
// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
archiveAppendix.set(this@withType.name)
})

// Provide artifacts information required by Maven Central
pom {
name.set("Ksoup")
description.set("A lightweight Kotlin Multiplatform library to parse HTML/XML data.")
url.set("https://github.com/MohamedRejeb/Ksoup")

licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
issueManagement {
system.set("Github")
url.set("https://github.com/MohamedRejeb/Ksoup/issues")
}
scm {
connection.set("https://github.com/MohamedRejeb/Ksoup.git")
url.set("https://github.com/MohamedRejeb/Ksoup")
}
developers {
developer {
id.set("MohamedRejeb")
name.set("Mohamed Rejeb")
email.set("mohamedrejeb445@gmail.com")
}
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("OSSRH_GPG_SECRET_KEY_ID"),
System.getenv("OSSRH_GPG_SECRET_KEY"),
System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD"),
)
sign(publishing.publications)
}

// TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed
project.tasks.withType(AbstractPublishToMaven::class.java).configureEach {
dependsOn(project.tasks.withType(Sign::class.java))
}
22 changes: 22 additions & 0 deletions convention-plugins/src/main/kotlin/root.publication.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id("io.github.gradle-nexus.publish-plugin")
}

allprojects {
group = "com.mohamedrejeb.ksoup"
version = "0.3.0"
}

nexusPublishing {
// Configure maven central repository
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
stagingProfileId.set(System.getenv("OSSRH_STAGING_PROFILE_ID"))
username.set(System.getenv("OSSRH_USERNAME"))
password.set(System.getenv("OSSRH_PASSWORD"))
}
}
}
12 changes: 11 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
[versions]
agp = "8.1.0"
kotlin = "1.9.21"
kotlinx-kover = "0.7.4"

android-minSdk = "21"
android-compileSdk = "34"

nexus-publish = "2.0.0-rc-1"

[libraries]
nexus-publish = { module = "io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin", version.ref = "nexus-publish" }

[plugins]
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinx-kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kotlinx-kover" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
kotlinx-kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kotlinx-kover" }
35 changes: 33 additions & 2 deletions ksoup-entities/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
plugins {
kotlin("multiplatform")
alias(libs.plugins.multiplatform)
alias(libs.plugins.androidLibrary)
id("module.publication")
}

kotlin {
applyDefaultHierarchyTemplate()
explicitApi()


androidTarget {
publishLibraryVariants("release")
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()
jvm {
jvmToolchain(11)
}
js(IR) {
browser()
nodejs()
binaries.executable()
}
iosX64()
iosArm64()
Expand All @@ -20,12 +35,19 @@ kotlin {
tvosArm64()
tvosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
watchosDeviceArm64()
watchosSimulatorArm64()
linuxX64()
linuxArm64()
macosX64()
macosArm64()
mingwX64()
@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasmJs()
@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasmWasi()

sourceSets {
/* Main source sets */
Expand All @@ -43,3 +65,12 @@ kotlin {
}
}
}

android {
namespace = "com.mohamedrejeb.ksoup.entities"
compileSdk = libs.versions.android.compileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
}
Loading

0 comments on commit f0c6794

Please sign in to comment.