diff --git a/MPChartLib/build.gradle b/MPChartLib/build.gradle index c21382406f..8fea22e715 100644 --- a/MPChartLib/build.gradle +++ b/MPChartLib/build.gradle @@ -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 { @@ -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://git@github.com/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") - } - } - } -} \ No newline at end of file +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" diff --git a/build.gradle b/build.gradle index 9fc6aee8ac..7d8e4a8ff1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,17 @@ +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" } } @@ -16,9 +19,15 @@ 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() diff --git a/publish-mavencentral.gradle b/publish-mavencentral.gradle new file mode 100644 index 0000000000..2e722aa668 --- /dev/null +++ b/publish-mavencentral.gradle @@ -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 = 'hola@jahir.dev' + } + // 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 +}