Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add withSourcesJar for the single variant releases #291

Merged
merged 6 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,4 @@ plugins {
alias(libs.plugins.dokka)
}

apply(from = "${rootDir}/scripts/publish-root.gradle.kts")

// Set up Sonatype repository
nexusPublishing {
this.repositories {
sonatype {
stagingProfileId.set(rootProject.extra.get("sonatypeStagingProfileId") as? String)
username.set(rootProject.extra.get("ossrhUsername") as? String)
password.set(rootProject.extra.get("ossrhPassword") as? String)
version = rootProject.extra.get("rootVersionName")
}
}
}
apply(from = "${rootDir}/scripts/publish-root.gradle")
5 changes: 1 addition & 4 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'org.jetbrains.dokka'

task androidSourcesJar(type: Jar) {
tasks.register('androidSourcesJar', Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}
Expand Down Expand Up @@ -46,7 +44,6 @@ afterEvaluate {
from components.java
}

artifact androidSourcesJar
artifact javadocJar

pom {
Expand Down
45 changes: 45 additions & 0 deletions scripts/publish-root.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import com.github.skydoves.landscapist.Configuration

// Create variables with empty default values
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.key"] = ''
ext["snapshot"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
} else {
// Use system environment variables
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.key"] = System.getenv('SIGNING_KEY')
ext["snapshot"] = System.getenv('SNAPSHOT')
}

if (snapshot) {
ext["rootVersionName"] = Configuration.snapshotVersionName
} else {
ext["rootVersionName"] = Configuration.versionName
}

// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
version = rootVersionName
}
}
}
18 changes: 0 additions & 18 deletions scripts/publish-root.gradle.kts

This file was deleted.