Skip to content

Commit

Permalink
Change Maven publishing to use the new Gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
vbabenkoru committed Nov 17, 2023
1 parent 318385c commit c20942d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 67 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {

android {
compileSdkVersion 33
buildToolsVersion '30.0.3'
buildToolsVersion '33.0.2'

namespace 'com.iterable.iterableapi.testapp'
testNamespace 'iterable.com.iterableapi'
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.6.21'
ext.mavenPublishEnabled = true
repositories {
google()
jcenter()
Expand Down
23 changes: 7 additions & 16 deletions iterableapi-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

publishing {
multipleVariants {
allVariants()
withJavadocJar()
}
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -39,24 +46,8 @@ dependencies {
}

ext {
publishedGroupId = 'com.iterable'
libraryName = 'iterableapi-ui'
artifact = 'iterableapi-ui'

libraryDescription = 'Iterable Android SDK - UI'

siteUrl = 'https://github.com/Iterable/iterable-android-sdk'
gitUrl = 'https://github.com/Iterable/iterable-android-sdk.git'

libraryVersion = '3.4.17'

developerId = 'davidtruong'
developerName = 'David Truong'
developerEmail = '[email protected]'

licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}

if (hasProperty("mavenPublishEnabled")) {
Expand Down
25 changes: 8 additions & 17 deletions iterableapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'checkstyle'

android {
compileSdkVersion 33
buildToolsVersion '30.0.3'
buildToolsVersion '33.0.2'

namespace 'com.iterable.iterableapi'
testNamespace 'iterable.com.iterableapi'
Expand All @@ -24,6 +24,13 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

publishing {
multipleVariants {
allVariants()
withJavadocJar()
}
}

buildTypes {
release {
minifyEnabled false
Expand Down Expand Up @@ -75,24 +82,8 @@ dependencies {
}

ext {
publishedGroupId = 'com.iterable'
libraryName = 'iterableapi'
artifact = 'iterableapi'

libraryDescription = 'Iterable Android SDK'

siteUrl = 'https://github.com/Iterable/iterable-android-sdk'
gitUrl = 'https://github.com/Iterable/iterable-android-sdk.git'

libraryVersion = '3.4.17'

developerId = 'davidtruong'
developerName = 'David Truong'
developerEmail = '[email protected]'

licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}

if (hasProperty("mavenPublishEnabled")) {
Expand Down
68 changes: 36 additions & 32 deletions maven-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

Properties properties = new Properties()
Expand Down Expand Up @@ -43,70 +43,74 @@ def getRepositoryPassword() {
}

def keyID = properties.getProperty("signing.keyId")
def password = properties.getProperty("signing.password")
def signing_password = properties.getProperty("signing.password")
def keyRingLocation = properties.getProperty("signing.secretKeyRingFile")
def nexus_username = properties.getProperty("NEXUS_USERNAME")
def nexus_password = properties.getProperty("NEXUS_PASSWORD")

ext."signing.keyId" = keyID
ext."signing.secretKeyRingFile" = keyRingLocation
ext."signing.password" = password
ext."signing.password" = signing_password

afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

pom.groupId = GROUP
pom.artifactId = libraryName
pom.version = libraryVersion

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: nexus_username, password: nexus_password)
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
publishing {
publications {
release(MavenPublication) {
groupId = GROUP
artifactId = libraryName
version = libraryVersion

afterEvaluate {
from components.release
}

pom.project {
name libraryName
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
pom {
name = libraryName
packaging = POM_PACKAGING
description = POM_DESCRIPTION
url = POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
distribution = POM_LICENCE_DIST
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
}
}
}
}
repositories {
maven {
name = "OSSRH"
url = getReleaseRepositoryUrl()
credentials {
username = nexus_username
password = nexus_password
}
}
}
}

signing {
// required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
required true
sign configurations.archives
sign publishing.publications.release
}


task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/inbox-customization/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 33
buildToolsVersion "30.0.3"
buildToolsVersion "33.0.2"
defaultConfig {
applicationId "com.iterable.inbox_customization"
minSdkVersion 16
Expand Down

0 comments on commit c20942d

Please sign in to comment.