Skip to content

Commit

Permalink
Require explicit enabling of publishing (#331)
Browse files Browse the repository at this point in the history
Prevents testutils (and potential future projects) from being published, also moves publishing config to AFTER the kotlin block to fix jellyfin-core-android POM and jellyfin-core Dokka
  • Loading branch information
nielsvanvelzen authored Oct 17, 2021
1 parent a5780c4 commit 5a6b949
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 44 deletions.
22 changes: 0 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,9 @@ apiValidation {

subprojects {
// Enable required plugins
apply<SigningPlugin>()
apply<MavenPublishPlugin>()
apply<io.gitlab.arturbosch.detekt.DetektPlugin>()
apply<org.jetbrains.dokka.gradle.DokkaPlugin>()

// Run block after creating project specific configuration
afterEvaluate {
// Add signing config
configure<SigningExtension> {
val signingKey = getProperty("signing.key")
val signingPassword = getProperty("signing.password") ?: ""

if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
val publishing: PublishingExtension by project
sign(publishing.publications)
}
}

// Add POM to projects that use publishing
configure<PublishingExtension> {
publications.withType<MavenPublication>().forEach(MavenPublication::defaultPom)
}
}

// Detekt linting
detekt {
buildUponDefaultConfig = true
Expand Down
34 changes: 34 additions & 0 deletions buildSrc/src/main/kotlin/Publishing.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin

fun Project.enablePublishing(init: PublishingExtension.() -> Unit = {}) {
apply<SigningPlugin>()
apply<MavenPublishPlugin>()

extensions.getByType<PublishingExtension>().init()

// Run block after creating project specific configuration
afterEvaluate {
// Add signing config
configure<SigningExtension> {
val signingKey = getProperty("signing.key")
val signingPassword = getProperty("signing.password") ?: ""

if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
val publishing: PublishingExtension by project
sign(publishing.publications)
}
}

// Add POM to projects that use publishing
configure<PublishingExtension> {
publications.withType<MavenPublication>().forEach(MavenPublication::defaultPom)
}
}
}
16 changes: 9 additions & 7 deletions jellyfin-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ kotlin {
}
}

val javadocJar by tasks.creating(Jar::class) {
dependsOn(tasks.getByName("dokkaHtml"))
archiveClassifier.set("javadoc")
from("$buildDir/dokka/html")
}
enablePublishing {
val javadocJar by tasks.creating(Jar::class) {
dependsOn(tasks.getByName("dokkaHtml"))
archiveClassifier.set("javadoc")
from("$buildDir/dokka/html")
}

publishing.publications.withType<MavenPublication> {
artifact(javadocJar)
publications.withType<MavenPublication> {
artifact(javadocJar)
}
}
17 changes: 9 additions & 8 deletions jellyfin-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ android {
}
}

val javadocJar by tasks.creating(Jar::class) {
// FIXME: Dokka is failing for this module - temporarily disabled
// dependsOn(tasks.getByName("dokkaHtml"))
archiveClassifier.set("javadoc")
// from("$buildDir/dokka/html")
}
enablePublishing {
val javadocJar by tasks.creating(Jar::class) {
dependsOn(tasks.getByName("dokkaHtml"))
archiveClassifier.set("javadoc")
from("$buildDir/dokka/html")
}

publishing.publications.withType<MavenPublication> {
artifact(javadocJar)
publications.withType<MavenPublication> {
artifact(javadocJar)
}
}
16 changes: 9 additions & 7 deletions jellyfin-model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ kotlin {
}
}

val javadocJar by tasks.creating(Jar::class) {
dependsOn(tasks.getByName("dokkaHtml"))
archiveClassifier.set("javadoc")
from("$buildDir/dokka/html")
}
enablePublishing {
val javadocJar by tasks.creating(Jar::class) {
dependsOn(tasks.getByName("dokkaHtml"))
archiveClassifier.set("javadoc")
from("$buildDir/dokka/html")
}

publishing.publications.withType<MavenPublication> {
artifact(javadocJar)
publications.withType<MavenPublication> {
artifact(javadocJar)
}
}

0 comments on commit 5a6b949

Please sign in to comment.