Skip to content

Commit 0e329be

Browse files
committed
2.1.3 migrate from Jcenter to MavenCentral
1 parent e49e45c commit 0e329be

File tree

6 files changed

+146
-93
lines changed

6 files changed

+146
-93
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ This lib is a [fork](https://code.google.com/archive/p/android-serialport-api/)
1111
Add the dependency:
1212

1313
```
14+
allprojects {
15+
repositories {
16+
...
17+
jcenter()
18+
mavenCentral() // since 2.1.3
19+
}
20+
}
21+
1422
dependencies {
15-
implementation 'com.licheedev:android-serialport:2.1.2'
23+
implementation 'com.licheedev:android-serialport:2.1.3'
1624
}
1725
```
1826

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ buildscript {
44
repositories {
55
google()
66
jcenter()
7+
mavenCentral()
78
}
89
dependencies {
910
classpath 'com.android.tools.build:gradle:4.0.1'
1011
// NOTE: Do not place your application dependencies here; they belong
1112
// in the individual module build.gradle files
12-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
13-
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
13+
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.32'
1414
}
1515
}
1616

1717
allprojects {
1818
repositories {
1919
google()
2020
jcenter()
21+
mavenCentral()
2122
}
2223
}
2324

@@ -32,5 +33,5 @@ ext {
3233
targetSdkVersion = 29
3334

3435
versionCode = 2
35-
versionName = "2.1.2"
36+
versionName = "2.1.3"
3637
}

maven_publish.gradle

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// 依赖信息
2+
def groupIdDefined = "com.licheedev"
3+
def artifactIdDefined = "android-serialport"
4+
// 如果是测试版,版本号后面加上 -SNAPSHOT
5+
def versionDefined = rootProject.ext.versionName
6+
// 其他信息
7+
def gitUrl = "https://github.com/licheedev/Android-SerialPort-API"
8+
9+
// 配置是否上传
10+
def toUpload = true
11+
12+
//在根build.gradle中加入,最新版本号参考 https://github.com/Kotlin/dokka#using-dokka
13+
//classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.32'
14+
15+
//在module的build.gradle末位加入
16+
//apply from: '../maven_publish.gradle'
17+
18+
if (toUpload) {
19+
apply plugin: 'signing'
20+
apply plugin: 'maven-publish'
21+
apply plugin: 'org.jetbrains.dokka'
22+
23+
//<editor-fold desc="打包源码和javadoc">
24+
// 打包源码
25+
task sourcesJar(type: Jar) {
26+
from android.sourceSets.main.java.srcDirs
27+
classifier = 'sources'
28+
}
29+
30+
task javadoc(type: Javadoc) {
31+
failOnError false
32+
source = android.sourceSets.main.java.sourceFiles
33+
options {
34+
encoding = "utf-8"
35+
charSet 'UTF-8'
36+
}
37+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
38+
classpath += configurations.compile
39+
}
40+
41+
// 打包javadoc
42+
task javadocJar(type: Jar, dependsOn: javadoc) {
43+
classifier = 'javadoc'
44+
from javadoc.destinationDir
45+
}
46+
47+
// 打包包含kotlin源码的javadoc
48+
task kotlinDocJar(type: Jar, dependsOn: dokkaHtml) {
49+
classifier = 'javadoc'
50+
from dokkaHtml.outputDirectory
51+
}
52+
//</editor-fold>
53+
54+
afterEvaluate {
55+
56+
publishing {
57+
publications {
58+
mavenAndroid(MavenPublication) {
59+
from components.release
60+
61+
groupId "$groupIdDefined"
62+
artifactId "$artifactIdDefined"
63+
version "$versionDefined"
64+
// 上传source
65+
artifact sourcesJar
66+
// 上传javadoc
67+
if (project.plugins.hasPlugin('kotlin-android')) {
68+
artifact kotlinDocJar
69+
} else {
70+
artifact javadocJar
71+
}
72+
73+
pom {
74+
name = 'Android-SerialPort-API'
75+
description = 'Android-SerialPort-API'
76+
url = "$gitUrl"
77+
78+
//licenses {
79+
// license {
80+
// name = 'The MIT License'
81+
// url = 'https://opensource.org/licenses/MIT'
82+
// }
83+
//}
84+
85+
licenses {
86+
license {
87+
name = 'The Apache License, Version 2.0'
88+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
89+
}
90+
}
91+
92+
developers {
93+
developer {
94+
id = 'licheedev'
95+
name = 'John Lee'
96+
97+
}
98+
}
99+
scm {
100+
connection = "$gitUrl"
101+
developerConnection = "${gitUrl}.git"
102+
url = "$gitUrl"
103+
}
104+
}
105+
}
106+
}
107+
108+
repositories {
109+
110+
maven {
111+
// 依赖发布地址
112+
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
113+
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
114+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
115+
116+
// 配置账号密码
117+
println "user=${ossrhUsername},key=${ossrhPassword}"
118+
credentials {
119+
username "${ossrhUsername}"
120+
password "${ossrhPassword}"
121+
}
122+
}
123+
}
124+
}
125+
126+
signing {
127+
sign publishing.publications.mavenAndroid
128+
}
129+
}
130+
}

sample/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ dependencies {
2727
})
2828
implementation 'androidx.appcompat:appcompat:1.2.0'
2929
testImplementation 'junit:junit:4.13'
30-
// implementation project(':serialport')
31-
implementation 'com.licheedev:android-serialport:2.1.1'
30+
implementation project(':serialport')
31+
//implementation 'com.licheedev:android-serialport:2.1.3'
3232
}

serialport/bintray.gradle

Lines changed: 0 additions & 86 deletions
This file was deleted.

serialport/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ dependencies {
3737
api "androidx.annotation:annotation:1.1.0"
3838
}
3939

40-
apply from: './bintray.gradle'
40+
apply from: '../maven_publish.gradle'
4141

0 commit comments

Comments
 (0)