-
Notifications
You must be signed in to change notification settings - Fork 30
/
publish.gradle
128 lines (116 loc) · 4.64 KB
/
publish.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
apply plugin: 'maven-publish'
apply plugin: 'signing'
ext {
PUBLISH_GROUP_ID = 'io.github.windysha'
PUBLISH_ARTIFACT_ID = 'bypassHiddenApiRestriction'
PUBLISH_ARTIFACT_NAME = 'Android Hidden Api Bypass'
PUBLISH_VERSION_NAME = '1.1.0'
POM_URL = 'https://github.com/WindySha/bypassHiddenApiRestriction'
POM_DESCRIPTION = 'This is a library that can bypass the hidden api restriction on Android 9-12.'
POM_DEVELOPER_ID = 'WindySha'
POM_DEVELOPER_NAME = 'WindySha'
POM_DEVELOPER_EMAIL = '[email protected]'
POM_DEVELOPER_URL = 'https://windysha.github.io/'
POM_SCM_URL = 'https://github.com/WindySha/bypassHiddenApiRestriction/tree/master'
POM_SCM_CONNECTION = 'scm:git:https://github.com/WindySha/bypassHiddenApiRestriction.git'
}
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
// For Android libraries
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
// For pure Kotlin libraries, in case you have them
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
File secretPropsFile = project.rootProject.file('bypass_hidden_api_signing.properties')
if (secretPropsFile.exists()) {
println "Found secret props file, loading props"
Properties p = new Properties()
p.load(new FileInputStream(secretPropsFile))
p.each { name, value ->
ext[name] = value
}
} else {
println "No props file, loading env vars"
}
publishing {
publications {
release(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up in a moment
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION_NAME
afterEvaluate {
artifact tasks.getByName("bundleReleaseAar")
artifact androidSourcesJar
}
// Two artifacts, the `aar` and the sources
// artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
// artifact androidSourcesJar
// Self-explanatory metadata for the most part
pom {
name = PUBLISH_ARTIFACT_NAME
description = POM_DESCRIPTION
url = POM_URL
licenses {
license {
//协议类型,一般默认Apache License2.0的话不用改:
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
email = POM_DEVELOPER_EMAIL
url = POM_DEVELOPER_URL
}
}
// Version control info, if you're using GitHub, follow the format as seen here
scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_CONNECTION
}
// A slightly hacky fix so that your POM will include any transitive dependencies
// that your library builds upon
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
project.configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
repositories {
maven {
name = "mavenCentral"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
// The username and password we've fetched earlier
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
signing {
sign publishing.publications
}
// https://s01.oss.sonatype.org/#stagingRepositories
// publish dst: https://repo.maven.apache.org/maven2/io/github/windysha/bypassHiddenApiRestriction/1.0.2/