Skip to content

Commit f584055

Browse files
committed
1 parent 4b379fe commit f584055

File tree

3 files changed

+147
-60
lines changed

3 files changed

+147
-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://[email protected]/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: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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"] = System.getenv('SIGNING_KEY_ID')
24+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
25+
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
26+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
27+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
28+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
29+
30+
File secretPropsFile = new File(ext["signing.secretKeyRingFile"])
31+
if (secretPropsFile.exists()) {
32+
println("${secretPropsFile.path} exists")
33+
} else
34+
println("${secretPropsFile.path} not exists")
35+
println("")
36+
37+
publishing {
38+
publications {
39+
release(MavenPublication) {
40+
groupId PUBLISH_GROUP_ID
41+
artifactId PUBLISH_ARTIFACT_ID
42+
version PUBLISH_VERSION
43+
44+
if (project.plugins.findPlugin("com.android.library")) {
45+
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
46+
} else {
47+
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
48+
}
49+
50+
artifact androidSourcesJar
51+
52+
pom {
53+
name = PUBLISH_ARTIFACT_ID
54+
description = 'Test android library'
55+
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish'
56+
licenses {
57+
license {
58+
name = 'License'
59+
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish/blob/sample/LICENSE.md'
60+
}
61+
}
62+
developers {
63+
developer {
64+
id = 'jahirfiquitiva'
65+
name = 'Jahir Fiquitiva'
66+
67+
}
68+
// Other devs...
69+
}
70+
scm {
71+
connection = 'scm:git:github.com/jahirfiquitiva/test-library-maven-publish.git'
72+
developerConnection = 'scm:git:ssh://github.com/jahirfiquitiva/test-library-maven-publish.git'
73+
url = 'https://github.com/jahirfiquitiva/test-library-maven-publish/tree/master'
74+
}
75+
withXml {
76+
def dependenciesNode = asNode().appendNode('dependencies')
77+
78+
project.configurations.implementation.allDependencies.each {
79+
def dependencyNode = dependenciesNode.appendNode('dependency')
80+
dependencyNode.appendNode('groupId', it.group)
81+
dependencyNode.appendNode('artifactId', it.name)
82+
dependencyNode.appendNode('version', it.version)
83+
}
84+
}
85+
}
86+
}
87+
}
88+
repositories {
89+
maven {
90+
name = "sonatype"
91+
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
92+
93+
credentials {
94+
username ossrhUsername
95+
password ossrhPassword
96+
}
97+
}
98+
}
99+
}
100+
101+
/*
102+
nexusStaging {
103+
packageGroup = PUBLISH_GROUP_ID
104+
stagingProfileId = sonatypeStagingProfileId
105+
username = ossrhUsername
106+
password = ossrhPassword
107+
serverUrl = "https://s01.oss.sonatype.org/service/local/"
108+
}
109+
*/
110+
111+
nexusPublishing {
112+
repositories {
113+
sonatype {
114+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
115+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
116+
packageGroup = PUBLISH_GROUP_ID
117+
stagingProfileId = sonatypeStagingProfileId
118+
username = ossrhUsername
119+
password = ossrhPassword
120+
}
121+
}
122+
}
123+
124+
signing {
125+
sign publishing.publications
126+
}

0 commit comments

Comments
 (0)