Skip to content

Commit

Permalink
2.1.3 migrate from Jcenter to MavenCentral
Browse files Browse the repository at this point in the history
  • Loading branch information
licheedev committed Jun 1, 2021
1 parent e49e45c commit 0e329be
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 93 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ This lib is a [fork](https://code.google.com/archive/p/android-serialport-api/)
Add the dependency:

```
allprojects {
repositories {
...
jcenter()
mavenCentral() // since 2.1.3
}
}
dependencies {
implementation 'com.licheedev:android-serialport:2.1.2'
implementation 'com.licheedev:android-serialport:2.1.3'
}
```

Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.32'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand All @@ -32,5 +33,5 @@ ext {
targetSdkVersion = 29

versionCode = 2
versionName = "2.1.2"
versionName = "2.1.3"
}
130 changes: 130 additions & 0 deletions maven_publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// 依赖信息
def groupIdDefined = "com.licheedev"
def artifactIdDefined = "android-serialport"
// 如果是测试版,版本号后面加上 -SNAPSHOT
def versionDefined = rootProject.ext.versionName
// 其他信息
def gitUrl = "https://github.com/licheedev/Android-SerialPort-API"

// 配置是否上传
def toUpload = true

//在根build.gradle中加入,最新版本号参考 https://github.com/Kotlin/dokka#using-dokka
//classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.32'

//在module的build.gradle末位加入
//apply from: '../maven_publish.gradle'

if (toUpload) {
apply plugin: 'signing'
apply plugin: 'maven-publish'
apply plugin: 'org.jetbrains.dokka'

//<editor-fold desc="打包源码和javadoc">
// 打包源码
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
options {
encoding = "utf-8"
charSet 'UTF-8'
}
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}

// 打包javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

// 打包包含kotlin源码的javadoc
task kotlinDocJar(type: Jar, dependsOn: dokkaHtml) {
classifier = 'javadoc'
from dokkaHtml.outputDirectory
}
//</editor-fold>

afterEvaluate {

publishing {
publications {
mavenAndroid(MavenPublication) {
from components.release

groupId "$groupIdDefined"
artifactId "$artifactIdDefined"
version "$versionDefined"
// 上传source
artifact sourcesJar
// 上传javadoc
if (project.plugins.hasPlugin('kotlin-android')) {
artifact kotlinDocJar
} else {
artifact javadocJar
}

pom {
name = 'Android-SerialPort-API'
description = 'Android-SerialPort-API'
url = "$gitUrl"

//licenses {
// license {
// name = 'The MIT License'
// url = 'https://opensource.org/licenses/MIT'
// }
//}

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id = 'licheedev'
name = 'John Lee'
email = '[email protected]'
}
}
scm {
connection = "$gitUrl"
developerConnection = "${gitUrl}.git"
url = "$gitUrl"
}
}
}
}

repositories {

maven {
// 依赖发布地址
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

// 配置账号密码
println "user=${ossrhUsername},key=${ossrhPassword}"
credentials {
username "${ossrhUsername}"
password "${ossrhPassword}"
}
}
}
}

signing {
sign publishing.publications.mavenAndroid
}
}
}
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ dependencies {
})
implementation 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.13'
// implementation project(':serialport')
implementation 'com.licheedev:android-serialport:2.1.1'
implementation project(':serialport')
//implementation 'com.licheedev:android-serialport:2.1.3'
}
86 changes: 0 additions & 86 deletions serialport/bintray.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion serialport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ dependencies {
api "androidx.annotation:annotation:1.1.0"
}

apply from: './bintray.gradle'
apply from: '../maven_publish.gradle'

0 comments on commit 0e329be

Please sign in to comment.