Skip to content

Commit

Permalink
migrating to maven central soon
Browse files Browse the repository at this point in the history
  • Loading branch information
TutorialsAndroid committed Sep 5, 2023
1 parent f7acf91 commit 6822c2f
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 5 deletions.
18 changes: 14 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'io.github.gradle-nexus.publish-plugin'

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
}

nexusPublishing {
repositories {
sonatype()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
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-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
43 changes: 43 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
group='com.github.TutorialsAndroid'

ext {
PUBLISH_GROUP_ID = 'io.github.tutorialsandroid'
PUBLISH_VERSION = '9.0.0'
PUBLISH_ARTIFACT_ID = 'filepicker'
PUBLISH_DESCRIPTION = 'Android Library to select files/directories from Device Storage'
PUBLISH_URL = 'https://github.com/TutorialsAndroid/FilePicker'
PUBLISH_LICENSE_NAME = 'Apache License'
PUBLISH_LICENSE_URL =
'https://github.com/TutorialsAndroid/FilePicker/blob/master/LICENSE'
PUBLISH_DEVELOPER_ID = 'tutorialsandroid'
PUBLISH_DEVELOPER_NAME = 'Akshay Masram'
PUBLISH_DEVELOPER_EMAIL = 'akshaysunilmasram@yahoo.com'
PUBLISH_SCM_CONNECTION =
'scm:git:github.com/tutorialsandroid/filepicker.git'
PUBLISH_SCM_DEVELOPER_CONNECTION =
'scm:git:ssh://github.com/tutorialsandroid/filepicker.git'
PUBLISH_SCM_URL =
'https://github.com/tutorialsandroid/filepicker/tree/master'
}

android {
compileSdk 34

Expand All @@ -15,7 +36,29 @@ android {
}
}
namespace 'com.developer.filepicker'

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
lint {
abortOnError false
}
}

publishing {
publications {
release(MavenPublication) {
groupId = PUBLISH_GROUP_ID
artifactId = PUBLISH_ARTIFACT_ID
version = PUBLISH_VERSION

from components.findByName('release')
artifact("$buildDir/outputs/aar/library-release.aar")
}
}

tasks.named('publishReleasePublicationToMavenLocal') {
dependsOn tasks.named('bundleReleaseAar')
}
}
77 changes: 77 additions & 0 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
} else {
from sourceSets.main.java.srcDirs
}
}

artifacts {
archives androidSourcesJar
}

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up later
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 {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}

artifact bundleReleaseAar

// Mostly self-explanatory metadata
pom {
name = PUBLISH_ARTIFACT_ID
description = PUBLISH_DESCRIPTION
url = PUBLISH_URL
licenses {
license {
name = PUBLISH_LICENSE_NAME
url = PUBLISH_LICENSE_URL
}
}
developers {
developer {
id = PUBLISH_DEVELOPER_ID
name = PUBLISH_DEVELOPER_NAME
email = PUBLISH_DEVELOPER_EMAIL
}
}

// Version control info - if you're using GitHub, follow the
// format as seen here
scm {
connection = PUBLISH_SCM_CONNECTION
developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION
url = PUBLISH_SCM_URL
}
}
}
}
}
}

ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]

signing {
sign publishing.publications
}
36 changes: 36 additions & 0 deletions scripts/publish-root.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Create variables with empty default values
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
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.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
}

// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}

0 comments on commit 6822c2f

Please sign in to comment.