Skip to content

Commit ac153c1

Browse files
author
wangshuwen15222
committed
chore:重新整理上传工具~~
1 parent 40bd1a2 commit ac153c1

File tree

2 files changed

+64
-60
lines changed

2 files changed

+64
-60
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
1919
android.enableJetifier=true
2020
debug=false
21-
pluginVersion=1.0.9
21+
pluginVersion=1.1.0
2222
annotationVersion=1.0.9
2323
compilerVersion=1.0.9
2424
coreVersion=1.1.0

publish-mavencentral.gradle

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -29,70 +29,73 @@ if (secretPropsFile.exists()) {
2929
println "No props file, loading env vars"
3030
}
3131

32+
def configurePublication = { MavenPublication publication ->
33+
groupId PUBLISH_GROUP_ID
34+
artifactId PUBLISH_ARTIFACT_ID
35+
version PUBLISH_VERSION
3236

33-
publishing {
34-
publications {
35-
release(MavenPublication) {
36-
groupId PUBLISH_GROUP_ID
37-
artifactId PUBLISH_ARTIFACT_ID
38-
version PUBLISH_VERSION
37+
def uploadJar = "mavenJava" == publication.name
38+
if (uploadJar) {
39+
from components.java
40+
artifact sourcesJar
41+
artifact javadocJar
42+
} else {
43+
artifact tasks.getByName("bundleReleaseAar")
44+
artifact androidSourcesJar
45+
}
3946

40-
if (isAar) {
41-
afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
42-
artifact androidSourcesJar
43-
} else {
44-
components.java
45-
artifact sourcesJar
46-
artifact javadocJar
47+
pom {
48+
name = PUBLISH_ARTIFACT_ID
49+
description = 'XRouter-Android'
50+
url = 'https://github.com/wangshuwen1107/XRouter-Android.git'
51+
licenses {
52+
license {
53+
//协议类型,一般默认Apache License2.0的话不用改:
54+
name = 'The Apache License, Version 2.0'
55+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
4756
}
48-
49-
pom {
50-
name = PUBLISH_ARTIFACT_ID
51-
description = 'XRouter-Android'
52-
url = 'https://github.com/wangshuwen1107/XRouter-Android.git'
53-
licenses {
54-
license {
55-
//协议类型,一般默认Apache License2.0的话不用改:
56-
name = 'The Apache License, Version 2.0'
57-
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
58-
}
59-
}
60-
developers {
61-
developer {
62-
id = 'wangshuwen1107'
63-
name = 'wangshuwen1107'
64-
email = 'wnwn7375@outlook.com'
65-
}
66-
}
67-
// Version control info, if you're using GitHub, follow the format as seen here
68-
scm {
69-
connection = 'scm:git:github.com/wangshuwen1107/XRouter-Android.git'
70-
developerConnection = 'scm:git:ssh://github.com/wangshuwen1107/XRouter-Android.git'
71-
url = 'https://github.com/wangshuwen1107/XRouter-Android.git/master'
72-
}
73-
// A slightly hacky fix so that your POM will include any transitive dependencies
74-
// that your library builds upon
75-
withXml {
76-
def dependenciesNode = asNode().appendNode('dependencies')
77-
project.configurations.implementation.allDependencies.each {
78-
if (null != it.group && null != it.name && null != it.version) {
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-
}
57+
}
58+
developers {
59+
developer {
60+
id = 'wangshuwen1107'
61+
name = 'wangshuwen1107'
62+
email = 'wnwn7375@outlook.com'
63+
}
64+
}
65+
scm {
66+
connection = 'scm:git:github.com/wangshuwen1107/XRouter-Android.git'
67+
developerConnection = 'scm:git:ssh://github.com/wangshuwen1107/XRouter-Android.git'
68+
url = 'https://github.com/wangshuwen1107/XRouter-Android.git/master'
69+
}
70+
withXml {
71+
if (!uploadJar) {
72+
def dependenciesNode = asNode().appendNode('dependencies')
73+
project.configurations.implementation.allDependencies.each {
74+
if (null != it.group && null != it.name && null != it.version) {
75+
def dependencyNode = dependenciesNode.appendNode('dependency')
76+
dependencyNode.appendNode('groupId', it.group)
77+
dependencyNode.appendNode('artifactId', it.name)
78+
dependencyNode.appendNode('version', it.version)
8479
}
8580
}
8681
}
8782
}
8883
}
89-
repositories {
90-
// The repository to publish to, Sonatype/MavenCentral
91-
maven {
92-
// This is an arbitrary name, you may also use "mavencentral" or
93-
// any other name that's descriptive for you
94-
// name = "XRouter-Android"
95-
url = uri('../repo')
84+
}
85+
86+
afterEvaluate {
87+
publishing {
88+
publications {
89+
if (isAar) {
90+
release(MavenPublication, configurePublication)
91+
} else {
92+
mavenJava(MavenPublication, configurePublication)
93+
}
94+
}
95+
repositories {
96+
maven {
97+
url = uri('../repo')
98+
}
9699
}
97100
}
98101
}
@@ -102,7 +105,8 @@ signing {
102105
sign publishing.publications
103106
}
104107

105-
task zipRepo(type: Zip) {
108+
task zipRepo(type: Zip ) {
109+
dependsOn isAar ? 'publishReleasePublicationToMavenRepository' : 'publishMavenJavaPublicationToMavenRepository'
106110
def componentDirPath = "${PUBLISH_GROUP_ID.replace(".", "/")}/$PUBLISH_ARTIFACT_ID/$PUBLISH_VERSION"
107111

108112
archiveBaseName = PUBLISH_ARTIFACT_ID
@@ -114,9 +118,9 @@ task zipRepo(type: Zip) {
114118
}
115119
}
116120

117-
118-
task publishSonatype(dependsOn: ['publishReleasePublicationToMavenRepository', 'zipRepo']) {
121+
task publishSonatype {
119122
group = "publishing"
123+
dependsOn 'zipRepo'
120124
doLast {
121125
def publishZipFile = file("../publish/$PUBLISH_ARTIFACT_ID-$PUBLISH_VERSION" + ".zip")
122126
def uploadToken = Base64.getEncoder().encodeToString("$ossrhUsername:$ossrhPassword".getBytes("UTF-8"))

0 commit comments

Comments
 (0)