Skip to content

Commit b399cfd

Browse files
committed
1 parent 4b379fe commit b399cfd

File tree

3 files changed

+156
-60
lines changed

3 files changed

+156
-60
lines changed

MPChartLib/build.gradle

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
plugins {
22
id 'com.android.library'
3-
id 'maven-publish'
4-
id "com.vanniktech.maven.publish" version "0.22.0"
5-
}
6-
7-
ext {
8-
mGroupId = "info.appdevnext"
9-
mArtifactId = "chart"
10-
mVersionName = getTag()
11-
12-
mLibraryName = "Android Chart"
13-
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"
3+
id 'kotlin-android'
144
}
155

166
android {
@@ -42,52 +32,14 @@ dependencies {
4232
testImplementation 'junit:junit:4.13.2'
4333
}
4434

45-
task androidSourcesJar(type: Jar) {
46-
archiveClassifier.set('sources')
47-
from android.sourceSets.main.java.srcDirs
48-
}
49-
50-
group = "info.mxtracks"
51-
version = "${getTag()}-SNAPSHOT"
52-
println "Build version $version"
35+
//group = "info.mxtracks"
36+
//version = "${getTag()}-SNAPSHOT"
37+
//println "Build version $version"
5338

54-
mavenPublishing {
55-
pom {
56-
name = "Android Chart"
57-
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"
58-
inceptionYear = "2022"
59-
url = "https://github.com/AppDevNext/AndroidChart/"
60-
licenses {
61-
license {
62-
name = "The Apache License, Version 2.0"
63-
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
64-
distribution = "http://www.apache.org/licenses/LICENSE-2.0.txt"
65-
}
66-
}
67-
developers {
68-
developer {
69-
id = "AppDevNext"
70-
name = "AppDevNext"
71-
url = "https://github.com/AppDevNext/"
72-
}
73-
}
74-
scm {
75-
url = "https://github.com/AppDevNext/AndroidChart/"
76-
connection = "scm:git:git://github.com/AppDevNext/AndroidChart.git"
77-
developerConnection = "scm:git:ssh://git@github.com/AppDevNext/AndroidChart.git"
78-
}
79-
}
39+
ext {
40+
PUBLISH_GROUP_ID = "info.mxtracks"
41+
PUBLISH_VERSION = getTag()
42+
PUBLISH_ARTIFACT_ID = 'chart'
43+
}
8044

81-
// Github packages
82-
repositories {
83-
maven {
84-
version = version
85-
name = "GitHubPackages"
86-
url = "https://maven.pkg.github.com/AppDevNext/AndroidChart"
87-
credentials {
88-
username = System.getenv("GITHUBACTOR")
89-
password = System.getenv("GITHUBTOKEN")
90-
}
91-
}
92-
}
93-
}
45+
apply from: "${rootProject.projectDir}/publish-mavencentral.gradle"

build.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
1+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
2+
13
buildscript {
24
ext.kotlin_version = '1.7.22'
3-
45
repositories {
56
google()
67
mavenCentral()
8+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
9+
maven { url 'https://plugins.gradle.org/m2/' }
710
}
811
dependencies {
912
classpath 'com.android.tools.build:gradle:7.3.1'
10-
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1113
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
1215
}
1316
}
1417

1518
allprojects {
1619
repositories {
1720
google()
1821
mavenCentral()
22+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
23+
maven { url 'https://plugins.gradle.org/m2/' }
1924
}
2025
}
2126

27+
task clean(type: Delete) {
28+
delete rootProject.buildDir
29+
}
30+
2231
@SuppressWarnings('unused')
2332
static def getTag() {
2433
def process = "git describe --tags --abbrev=0".execute()

publish-mavencentral.gradle

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
task androidSourcesJar(type: Jar) {
5+
archiveClassifier.set('sources')
6+
if (project.plugins.findPlugin("com.android.library")) {
7+
from android.sourceSets.main.java.srcDirs
8+
from android.sourceSets.main.kotlin.srcDirs
9+
} else {
10+
from sourceSets.main.java.srcDirs
11+
from sourceSets.main.kotlin.srcDirs
12+
}
13+
}
14+
15+
artifacts {
16+
archives androidSourcesJar
17+
// archives javadocJar
18+
}
19+
20+
group = PUBLISH_GROUP_ID
21+
version = PUBLISH_VERSION
22+
23+
ext["signing.keyId"] = ''
24+
ext["signing.password"] = ''
25+
ext["signing.secretKeyRingFile"] = ''
26+
ext["ossrhUsername"] = 'abc'
27+
ext["ossrhPassword"] = 'def'
28+
ext["sonatypeStagingProfileId"] = 'ghi'
29+
30+
File secretPropsFile = project.rootProject.file('local.properties')
31+
if (secretPropsFile.exists()) {
32+
Properties p = new Properties()
33+
p.load(new FileInputStream(secretPropsFile))
34+
p.each { name, value ->
35+
ext[name] = value
36+
}
37+
} else {
38+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
39+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
40+
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
41+
ext["ossrhUsername"] = 'abc' //System.getenv('OSSRH_USERNAME')
42+
ext["ossrhPassword"] = 'abc' //System.getenv('OSSRH_PASSWORD')
43+
ext["sonatypeStagingProfileId"] = "xxx" //System.getenv('SONATYPE_STAGING_PROFILE_ID')
44+
}
45+
46+
publishing {
47+
publications {
48+
release(MavenPublication) {
49+
groupId PUBLISH_GROUP_ID
50+
artifactId PUBLISH_ARTIFACT_ID
51+
version PUBLISH_VERSION
52+
53+
if (project.plugins.findPlugin("com.android.library")) {
54+
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
55+
} else {
56+
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
57+
}
58+
59+
artifact androidSourcesJar
60+
61+
pom {
62+
name = PUBLISH_ARTIFACT_ID
63+
description = 'Test android library'
64+
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish'
65+
licenses {
66+
license {
67+
name = 'License'
68+
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish/blob/sample/LICENSE.md'
69+
}
70+
}
71+
developers {
72+
developer {
73+
id = 'jahirfiquitiva'
74+
name = 'Jahir Fiquitiva'
75+
email = 'hola@jahir.dev'
76+
}
77+
// Other devs...
78+
}
79+
scm {
80+
connection = 'scm:git:github.com/jahirfiquitiva/test-library-maven-publish.git'
81+
developerConnection = 'scm:git:ssh://github.com/jahirfiquitiva/test-library-maven-publish.git'
82+
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish/tree/master'
83+
}
84+
withXml {
85+
def dependenciesNode = asNode().appendNode('dependencies')
86+
87+
project.configurations.implementation.allDependencies.each {
88+
def dependencyNode = dependenciesNode.appendNode('dependency')
89+
dependencyNode.appendNode('groupId', it.group)
90+
dependencyNode.appendNode('artifactId', it.name)
91+
dependencyNode.appendNode('version', it.version)
92+
}
93+
}
94+
}
95+
}
96+
}
97+
repositories {
98+
maven {
99+
name = "sonatype"
100+
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
101+
102+
credentials {
103+
username ossrhUsername
104+
password ossrhPassword
105+
}
106+
}
107+
}
108+
}
109+
110+
/*
111+
nexusStaging {
112+
packageGroup = PUBLISH_GROUP_ID
113+
stagingProfileId = sonatypeStagingProfileId
114+
username = ossrhUsername
115+
password = ossrhPassword
116+
serverUrl = "https://s01.oss.sonatype.org/service/local/"
117+
}
118+
*/
119+
120+
nexusPublishing {
121+
repositories {
122+
sonatype {
123+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
124+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
125+
packageGroup = PUBLISH_GROUP_ID
126+
stagingProfileId = sonatypeStagingProfileId
127+
username = ossrhUsername
128+
password = ossrhPassword
129+
}
130+
}
131+
}
132+
133+
signing {
134+
sign publishing.publications
135+
}

0 commit comments

Comments
 (0)