Skip to content

Commit

Permalink
Add missing artifactory publishing plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wong committed Sep 10, 2024
1 parent 134727e commit a585175
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 39 deletions.
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ okhttp = "4.12.0"
retrofit = "2.11.0"
moshi = "1.15.1"
agp = "8.6.0"
jfrog-artifactory = "5.1.10"

appcompatV7 = "28.0.0"
constraintLayout = "2.0.4"
Expand All @@ -17,6 +18,7 @@ kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"}
pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "pluginPublish"}
androidApplication = { id = "com.android.application", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
jfrog-artifactory = { id = "com.jfrog.artifactory", version.ref = "jfrog-artifactory" }

[libraries]
junit = "junit:junit:4.13.2"
Expand Down
1 change: 1 addition & 0 deletions plugin-build/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.pluginPublish) apply false
alias(libs.plugins.jfrog.artifactory) apply false
}

allprojects {
Expand Down
115 changes: 76 additions & 39 deletions plugin-build/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,67 +1,104 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
`java-gradle-plugin`
alias(libs.plugins.pluginPublish)
kotlin("jvm")
`java-gradle-plugin`
alias(libs.plugins.pluginPublish) // For Gradle Plugin Portal
alias(libs.plugins.jfrog.artifactory) // For our internal Artifactory
}

dependencies {
implementation(kotlin("stdlib"))
implementation(gradleApi())
implementation(kotlin("stdlib"))
implementation(gradleApi())

implementation(libs.agp)
implementation(libs.agp)

implementation(libs.coroutines)
implementation(libs.okhttp)
implementation(libs.retrofit)
implementation(libs.retrofitConverterScalars)
implementation(libs.moshi)
implementation(libs.moshiKotlin)
implementation(libs.moshiAdapters)
implementation(libs.coroutines)
implementation(libs.okhttp)
implementation(libs.retrofit)
implementation(libs.retrofitConverterScalars)
implementation(libs.moshi)
implementation(libs.moshiKotlin)
implementation(libs.moshiAdapters)

testImplementation(libs.junit)
testImplementation(libs.junit)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

gradlePlugin {
plugins {
create(property("ID").toString()) {
id = property("ID").toString()
implementationClass = property("IMPLEMENTATION_CLASS").toString()
version = property("VERSION").toString()
description = property("DESCRIPTION").toString()
displayName = property("DISPLAY_NAME").toString()
tags = listOf("android", "linth")
}
}
plugins {
create(property("ID").toString()) {
id = property("ID").toString()
implementationClass = property("IMPLEMENTATION_CLASS").toString()
version = property("VERSION").toString()
description = property("DESCRIPTION").toString()
displayName = property("DISPLAY_NAME").toString()
tags = listOf("android", "linth")
}
}
}

gradlePlugin {
website.set(property("WEBSITE").toString())
vcsUrl.set(property("VCS_URL").toString())
website.set(property("WEBSITE").toString())
vcsUrl.set(property("VCS_URL").toString())
}

tasks.create("setupPluginUploadFromEnvironment") {
doLast {
val key = System.getenv("GRADLE_PUBLISH_KEY")
val secret = System.getenv("GRADLE_PUBLISH_SECRET")
doLast {
val key = System.getenv("GRADLE_PUBLISH_KEY")
val secret = System.getenv("GRADLE_PUBLISH_SECRET")

if (key == null || secret == null) {
throw GradleException("gradlePublishKey and/or gradlePublishSecret are not defined environment variables")
}
if (key == null || secret == null) {
throw GradleException("gradlePublishKey and/or gradlePublishSecret are not defined environment variables")
}

System.setProperty("gradle.publish.key", key)
System.setProperty("gradle.publish.secret", secret)
}
}

System.setProperty("gradle.publish.key", key)
System.setProperty("gradle.publish.secret", secret)
// MAVEN PUBLISHING

publishing {
publications {
register<MavenPublication>("mavenJava") {
from(components.getByName("java"))
artifactId = property("ID").toString()
groupId = property("GROUP").toString()
version = property("VERSION").toString()
}
}
}

artifactory {
setContextUrl(project.property("ubiqueMavenRootUrl")?.toString())
publish {
repository {
repoKey = project.property("ubiqueMavenRepoName")?.toString()
username = project.property("ubiqueMavenUser")?.toString()
password = project.property("ubiqueMavenPass")?.toString()
}

defaults {
publications("mavenJava")
setPublishArtifacts(true)
setProperties(
mapOf(
"build.status" to this.project.status.toString()
)
)
setPublishPom(true)
setPublishIvy(false)
}
}
}

0 comments on commit a585175

Please sign in to comment.