Skip to content

Commit 40bd1a2

Browse files
author
wangshuwen15222
committed
chore:更新traget=30&&发布到central.sonatype.com
1 parent 5c1e47f commit 40bd1a2

File tree

11 files changed

+87
-94
lines changed

11 files changed

+87
-94
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
/captures
88
.externalNativeBuild
99
.cxx
10-
/repo
10+
/repo
11+
/publish

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ apply plugin: 'com.android.application'
22
apply plugin: 'XRouter'
33

44
android {
5-
compileSdkVersion 29
6-
buildToolsVersion "29.0.3"
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
buildToolsVersion rootProject.ext.buildToolsVersion
77
defaultConfig {
88
applicationId "cn.cheney.test"
9-
minSdkVersion 21
10-
targetSdkVersion 29
9+
minSdkVersion rootProject.ext.minSdkVersion
10+
targetSdkVersion rootProject.ext.targetSdkVersion
1111
versionCode 1
1212
versionName "1.0"
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,14 @@ allprojects {
2525

2626
task clean(type: Delete) {
2727
delete rootProject.buildDir
28+
delete "./repo"
29+
delete "./publish"
30+
}
31+
32+
33+
ext {
34+
compileSdkVersion = 30
35+
buildToolsVersion = '30.0.3'
36+
minSdkVersion = 21
37+
targetSdkVersion = 30
2838
}

gradle.properties

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1717
android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
1919
android.enableJetifier=true
20-
21-
debug = false
22-
pluginVersion = 1.0.8
23-
annotationVersion = 1.0.8
24-
compilerVersion = 1.0.8
25-
coreVersion = 1.0.9
20+
debug=false
21+
pluginVersion=1.0.9
22+
annotationVersion=1.0.9
23+
compilerVersion=1.0.9
24+
coreVersion=1.1.0

m_test/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 29
5-
buildToolsVersion "29.0.3"
6-
4+
compileSdkVersion rootProject.ext.compileSdkVersion
5+
buildToolsVersion rootProject.ext.buildToolsVersion
76

87
defaultConfig {
9-
minSdkVersion 19
10-
targetSdkVersion 29
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
1110
versionCode 1
1211
versionName "1.0"
1312

publish-mavencentral.gradle

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,18 @@ if (isAar) {
1818
}
1919
}
2020

21-
ext["signing.keyId"] = ''
22-
ext["signing.password"] = ''
23-
ext["signing.secretKeyRingFile"] = ''
24-
ext["ossrhUsername"] = ''
25-
ext["ossrhPassword"] = ''
26-
2721
File secretPropsFile = project.rootProject.file('local.properties')
2822
if (secretPropsFile.exists()) {
2923
println "Found secret props file, loading props"
3024
Properties p = new Properties()
3125
p.load(new FileInputStream(secretPropsFile))
32-
p.each { name, value ->
33-
ext[name] = value
26+
p.each { name, value -> ext[name] = value
3427
}
3528
} else {
3629
println "No props file, loading env vars"
3730
}
3831

32+
3933
publishing {
4034
publications {
4135
release(MavenPublication) {
@@ -44,10 +38,10 @@ publishing {
4438
version PUBLISH_VERSION
4539

4640
if (isAar) {
47-
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
41+
afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
4842
artifact androidSourcesJar
4943
} else {
50-
artifact("$buildDir/libs/${project.getName()}.jar")
44+
components.java
5145
artifact sourcesJar
5246
artifact javadocJar
5347
}
@@ -74,14 +68,12 @@ publishing {
7468
scm {
7569
connection = 'scm:git:github.com/wangshuwen1107/XRouter-Android.git'
7670
developerConnection = 'scm:git:ssh://github.com/wangshuwen1107/XRouter-Android.git'
77-
//分支地址:
7871
url = 'https://github.com/wangshuwen1107/XRouter-Android.git/master'
7972
}
8073
// A slightly hacky fix so that your POM will include any transitive dependencies
8174
// that your library builds upon
8275
withXml {
8376
def dependenciesNode = asNode().appendNode('dependencies')
84-
8577
project.configurations.implementation.allDependencies.each {
8678
if (null != it.group && null != it.name && null != it.version) {
8779
def dependencyNode = dependenciesNode.appendNode('dependency')
@@ -99,22 +91,54 @@ publishing {
9991
maven {
10092
// This is an arbitrary name, you may also use "mavencentral" or
10193
// any other name that's descriptive for you
102-
name = "XRouter-Android"
103-
104-
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
105-
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
106-
// You only need this if you want to publish snapshots, otherwise just set the URL
107-
// to the release repo directly
108-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
109-
110-
// The username and password we've fetched earlier
111-
credentials {
112-
username ossrhUsername
113-
password ossrhPassword
114-
}
94+
// name = "XRouter-Android"
95+
url = uri('../repo')
11596
}
11697
}
11798
}
99+
100+
118101
signing {
119102
sign publishing.publications
120103
}
104+
105+
task zipRepo(type: Zip) {
106+
def componentDirPath = "${PUBLISH_GROUP_ID.replace(".", "/")}/$PUBLISH_ARTIFACT_ID/$PUBLISH_VERSION"
107+
108+
archiveBaseName = PUBLISH_ARTIFACT_ID
109+
archiveVersion = PUBLISH_VERSION
110+
destinationDirectory = file("../publish")
111+
112+
from("${rootProject.projectDir}/repo/$componentDirPath") {
113+
into("$componentDirPath")
114+
}
115+
}
116+
117+
118+
task publishSonatype(dependsOn: ['publishReleasePublicationToMavenRepository', 'zipRepo']) {
119+
group = "publishing"
120+
doLast {
121+
def publishZipFile = file("../publish/$PUBLISH_ARTIFACT_ID-$PUBLISH_VERSION" + ".zip")
122+
def uploadToken = Base64.getEncoder().encodeToString("$ossrhUsername:$ossrhPassword".getBytes("UTF-8"))
123+
println "发布 uploadToken=$uploadToken"
124+
println "发布 bundle=${publishZipFile.absolutePath}"
125+
def curlOutput = new ByteArrayOutputStream()
126+
def curlError = new ByteArrayOutputStream()
127+
try {
128+
exec {
129+
commandLine 'curl', '--request', 'POST',
130+
'--header', "Authorization: Bearer $uploadToken",
131+
'--form', "bundle=@${publishZipFile.absolutePath}",
132+
'--form', "publishingType=AUTOMATIC",
133+
//'--form', "publishingType=USER_MANAGED",
134+
'https://central.sonatype.com/api/v1/publisher/upload'
135+
standardOutput = curlOutput
136+
errorOutput = curlError
137+
}
138+
println "发布结果*********: ${curlOutput.toString()}"
139+
} catch (Exception e) {
140+
println "发布失败*********: ${curlError.toString()}"
141+
throw e
142+
}
143+
}
144+
}

xrouter_compiler/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: 'java-library'
33
ext {
44
PUBLISH_GROUP_ID = "io.github.wangshuwen1107"
55
PUBLISH_ARTIFACT_ID = 'xrouter-compiler'
6-
PUBLISH_VERSION = "$coreVersion"
6+
PUBLISH_VERSION = "$compilerVersion"
77
}
88
apply from: "${rootProject.projectDir}/publish-mavencentral.gradle"
99

xrouter_compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor

Lines changed: 0 additions & 1 deletion
This file was deleted.

xrouter_core/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ ext {
88
apply from: "${rootProject.projectDir}/publish-mavencentral.gradle"
99

1010
android {
11-
compileSdkVersion 29
12-
buildToolsVersion "29.0.3"
11+
compileSdkVersion rootProject.ext.compileSdkVersion
12+
buildToolsVersion rootProject.ext.buildToolsVersion
1313

1414
defaultConfig {
15-
minSdkVersion 19
16-
targetSdkVersion 29
15+
minSdkVersion rootProject.ext.minSdkVersion
16+
targetSdkVersion rootProject.ext.targetSdkVersion
1717
versionCode 1
1818
versionName "1.0"
19-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2019
consumerProguardFiles 'consumer-rules.pro'
2120
}
2221

@@ -35,13 +34,14 @@ android {
3534
}
3635

3736

37+
3838
dependencies {
39-
api 'com.alibaba:fastjson:1.2.23'
39+
implementation 'com.alibaba:fastjson:1.2.23'
4040
implementation 'androidx.annotation:annotation:1.1.0'
41-
if(debug == "true"){
42-
api project(":xrouter_annotation")
43-
}else {
44-
api "io.github.wangshuwen1107:xrouter-annotation:$annotationVersion"
41+
if (debug == "true") {
42+
implementation project(":xrouter_annotation")
43+
} else {
44+
implementation "io.github.wangshuwen1107:xrouter-annotation:$annotationVersion"
4545
}
4646
}
4747

xrouter_core/src/androidTest/java/cn/cheney/xrouter/ExampleInstrumentedTest.java

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

xrouter_plugin/build.gradle

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
plugins {
2+
id 'java-library'
23
id 'groovy'
3-
id 'maven'
44
}
55

6+
67
dependencies {
78
implementation gradleApi()
89
implementation localGroovy()
@@ -23,16 +24,3 @@ ext {
2324
PUBLISH_VERSION = "$pluginVersion"
2425
}
2526
apply from: "${rootProject.projectDir}/publish-mavencentral.gradle"
26-
27-
//debug本地调试
28-
uploadArchives {
29-
repositories {
30-
mavenDeployer {
31-
pom.groupId = 'io.github.wangshuwen1107'
32-
pom.artifactId = 'xrouter-plugin'
33-
pom.version = "$pluginVersion"
34-
//发布到本地repo 测试时候用
35-
repository(url: uri('../repo'))
36-
}
37-
}
38-
}

0 commit comments

Comments
 (0)