Skip to content

Commit

Permalink
chore: work on updating publish scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Apr 1, 2023
1 parent 8d10d23 commit 2413f48
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 120 deletions.
9 changes: 8 additions & 1 deletion build.gradle
Expand Up @@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


Expand All @@ -17,6 +17,13 @@ buildscript {
}
}

plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

apply from: "${rootDir}/scripts/publish-root.gradle"


allprojects {
repositories {
google()
Expand Down
14 changes: 0 additions & 14 deletions gradle.properties
Expand Up @@ -27,17 +27,3 @@ android.useAndroidX=true
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=0.4.1
VERSION_CODE=7
GROUP=com.github.beksomega

POM_DESCRIPTION=A library that adds a looping layout manager for recycler views.
POM_URL=https://github.com/BeksOmega/looping-layout
POM_SCM_URL=https://github.com/BeksOmega/looping-layout
POM_SCM_CONNECTION=scm:git@github.com:BeksOmega/looping-layout.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:BeksOmega/looping-layout.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=BeksOmega
POM_DEVELOPER_NAME=Beka Westberg
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
8 changes: 7 additions & 1 deletion library/build.gradle
@@ -1,7 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply from: 'maven-push.gradle'

android {
compileSdkVersion 33
Expand Down Expand Up @@ -29,3 +28,10 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.3.0'
}

ext {
PUBLISH_GROUP_ID = 'com.github.beksomega'
PUBLISH_VERSION = '0.4.1'
PUBLISH_ARTIFACT_ID = 'loopinglayout'
}

apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
103 changes: 0 additions & 103 deletions library/maven-push.gradle

This file was deleted.

80 changes: 80 additions & 0 deletions scripts/publish-module.gradle
@@ -0,0 +1,80 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
// For Android libraries
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
// For pure Kotlin libraries, in case you have them
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}

artifacts {
archives androidSourcesJar
}

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
// The coordinates of the library
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION

// Two artifacts, the `aar` (or `jar`) and the sources
if (project.plugins.findPlugin("com.android.library")) {
from components.release
} else {
from components.java
}

artifact androidSourcesJar

// Meta data
pom {
name = PUBLISH_ARTIFACT_ID
description = 'A library that adds a looping layout manager for recycler views.'
url = 'https://github.com/BeksOmega/looping-layout'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'BeksOmega'
name = 'Beka Westberg'
email = 'bekawestberg@gmail.com'
}
}

// Version control info
scm {
connection = 'scm:git:github.com/BeksOmega/looping-layout.git'
developerConnection = 'scm:git:ssh://github.com/BeksOmega/looping-layout.git'
url = 'https://github.com/getstream/stream-chat-android/tree/master'
}
}
}
}
}
}

signing {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"],
rootProject.ext["signing.key"],
rootProject.ext["signing.password"],
)
sign publishing.publications
}
33 changes: 33 additions & 0 deletions scripts/publish-root.gradle
@@ -0,0 +1,33 @@
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.key"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''

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')
}

// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
}
}
}

0 comments on commit 2413f48

Please sign in to comment.