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

Library maven publish #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
70 changes: 11 additions & 59 deletions MPChartLib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
plugins {
id 'com.android.library'
id 'maven-publish'
id "com.vanniktech.maven.publish" version "0.22.0"
}

ext {
mGroupId = "info.appdevnext"
mArtifactId = "chart"
mVersionName = getTag()

mLibraryName = "Android Chart"
mLibraryDescription = "A powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations"
id 'kotlin-android'
}

android {
Expand Down Expand Up @@ -42,52 +32,14 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
}

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

group = "info.mxtracks"
version = "${getTag()}"
println "Build version $version"
//group = "info.mxtracks"
//version = "${getTag()}-SNAPSHOT"
//println "Build version $version"

mavenPublishing {
pom {
name = "Android Chart"
description = "A powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations"
inceptionYear = "2022"
url = "https://github.com/AppDevNext/AndroidChart/"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "AppDevNext"
name = "AppDevNext"
url = "https://github.com/AppDevNext/"
}
}
scm {
url = "https://github.com/AppDevNext/AndroidChart/"
connection = "scm:git:git://github.com/AppDevNext/AndroidChart.git"
developerConnection = "scm:git:ssh://[email protected]/AppDevNext/AndroidChart.git"
}
}

// Github packages
repositories {
maven {
version = version+"-SNAPSHOT"
name = "GitHubPackages"
url = "https://maven.pkg.github.com/AppDevNext/AndroidChart"
credentials {
username = System.getenv("GITHUBACTOR")
password = System.getenv("GITHUBTOKEN")
}
}
}
}
ext {
PUBLISH_GROUP_ID = "info.mxtracks"
PUBLISH_VERSION = getTag()+"-t3"
PUBLISH_ARTIFACT_ID = 'chart'
}
println "Build version $PUBLISH_VERSION"
apply from: "${rootProject.projectDir}/publish-mavencentral.gradle"
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
apply plugin: 'io.github.gradle-nexus.publish-plugin'

buildscript {
ext.kotlin_version = '1.7.22'

repositories {
google()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}

allprojects {
repositories {
google()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://plugins.gradle.org/m2/' }
}
}

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

@SuppressWarnings('unused')
static def getTag() {
def process = "git describe --tags --abbrev=0".execute()
Expand Down
119 changes: 119 additions & 0 deletions publish-mavencentral.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
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
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}

artifacts {
archives androidSourcesJar
// archives javadocJar
}

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

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')
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')

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

if (project.plugins.findPlugin("com.android.library")) {
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
} else {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}

artifact androidSourcesJar

pom {
name = PUBLISH_ARTIFACT_ID
description = 'Test android library'
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish'
licenses {
license {
name = 'License'
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish/blob/sample/LICENSE.md'
}
}
developers {
developer {
id = 'jahirfiquitiva'
name = 'Jahir Fiquitiva'
email = '[email protected]'
}
// Other devs...
}
scm {
connection = 'scm:git:github.com/jahirfiquitiva/test-library-maven-publish.git'
developerConnection = 'scm:git:ssh://github.com/jahirfiquitiva/test-library-maven-publish.git'
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish/tree/master'
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')

project.configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
repositories {
maven {
name = "sonatype"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"

credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}

/*
nexusStaging {
packageGroup = PUBLISH_GROUP_ID
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
serverUrl = "https://s01.oss.sonatype.org/service/local/"
}
*/

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

signing {
sign publishing.publications
}