Skip to content

Commit

Permalink
Add maven script
Browse files Browse the repository at this point in the history
  • Loading branch information
Jintin committed Jan 17, 2023
1 parent bf9ca6d commit c7ae2d2
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = "1.5.21"
repositories {
Expand All @@ -13,6 +14,9 @@ buildscript {
// in the individual module build.gradle files
}
}
plugins {
id 'io.github.gradle-nexus.publish-plugin' version('1.1.0')
}

allprojects {
repositories {
Expand All @@ -24,4 +28,17 @@ allprojects {

task clean(type: Delete) {
delete rootProject.buildDir
}

// Publish to Maven Central
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = System.getenv("OSS_USERNAME")
password = System.getenv("OSS_PASSWORD")
stagingProfileId = System.getenv("OSS_STAGING_PROFILE_ID")
}
}
}
12 changes: 11 additions & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
}

ext {
GROUP_ID = "io.github.jintin" // your project id registered in Sonatype
ARTIFACT_ID = "BindingExtension" // name of your library
VERSION = "1.0.0"
SITE_URL = 'https://github.com/Jintin/BindingExtension'
GIT_URL = 'https://github.com/Jintin/BindingExtension.git'
}

apply from: 'publish.gradle'
67 changes: 67 additions & 0 deletions lib/publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

// If you want to publish your sources as well
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
}

artifacts {
archives androidSourcesJar
}

group = GROUP_ID
version = VERSION

afterEvaluate {
publishing {
publications {
release(MavenPublication) {

groupId GROUP_ID
artifactId ARTIFACT_ID
version VERSION

from components.release
artifact androidSourcesJar

pom {
name = ARTIFACT_ID
description = 'Android ViewBinding extension to provide simpler usage in Activity, Fragment and ViewHolder.'
url = SITE_URL
licenses {
// Your licensing information
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'Jintin'
name = 'Tim Lin'
email = '[email protected]'
}
// More developers if any...
}

scm {
connection = GIT_URL
developerConnection = GIT_URL
url = SITE_URL
}
}
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("OSS_SIGNING_KEY"),
System.getenv("OSS_SIGNING_PASSWORD"),
)
sign publishing.publications
}

0 comments on commit c7ae2d2

Please sign in to comment.