-
Notifications
You must be signed in to change notification settings - Fork 3
/
sonatype-publish.gradle
122 lines (108 loc) · 4.37 KB
/
sonatype-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
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
task eocvDocs(type: Javadoc) {
group = "Documentation"
description = "Generate Javadoc"
failOnError = false
source = android.sourceSets.main.java.srcDirs
classpath = project.files(android.getBootClasspath().join(File.pathSeparator))
options.memberLevel = JavadocMemberLevel.PROTECTED
options.addStringOption('Xmaxwarns', '1')
options.addStringOption('Xmaxerrs', '1')
options.links "http://developer.android.com/reference"
}
task javadocJar(type: Jar) {
dependsOn eocvDocs
from eocvDocs.destinationDir
archiveClassifier = 'javadoc'
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier = 'sources'
}
def lcl_groupId = project.PUBLISH_GROUP_ID
def lcl_artifactId = project.PUBLISH_ARTIFACT_ID
def lcl_version = project.PUBLISH_VERSION
def lcl_desc = project.PUBLISH_DESC
def lcl_url = project.PUBLISH_URL
def lcl_vcs_url = project.PUBLISH_VCS_URL
def lcl_vcs_connection = project.PUBLISH_VCS_CONNECTION
ext["signing.keyId"] = System.getenv('OPENFTC_GPG_KEY_ID')
ext["signing.password"] = System.getenv('OPENFTC_GPG_KEY_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('OPENFTC_GPG_KEY_FILE')
ext["ossrhUsername"] = System.getenv('OPENFTC_SONATYPE_USER')
ext["ossrhPassword"] = System.getenv('OPENFTC_SONATYPE_PASSWORD')
signing {
sign publishing.publications
}
/*
* https://developer.android.com/studio/build/maven-publish-plugin
*
* components.release automatically pulls the AAR for the library this
* plugin is applied to.
*/
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
artifact sourcesJar
artifact javadocJar
// The coordinates of the library, being set from variables that
// we'll set up in a moment
groupId lcl_groupId
artifactId lcl_artifactId
version lcl_version
// 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 = lcl_artifactId
description = lcl_desc
// If your project has a dedicated site, use its URL here
url = lcl_url
licenses {
license {
name = 'MIT'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'openftc'
name = 'OpenFTC Team'
email = 'contact@openftc.org'
organization = 'OpenFTC'
organizationUrl = 'openftc.org'
}
}
// Version control info, if you're using GitHub, follow the format as seen here
scm {
connection = lcl_vcs_connection
url = lcl_vcs_url
}
}
}
}
repositories {
// The repository to publish to, Sonatype/MavenCentral
maven {
// This is an arbitrary name, you may also use "mavencentral" or
// any other name that's descriptive for you
name = "mavencentral"
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
// You only need this if you want to publish snapshots, otherwise just set the URL
// to the release repo directly
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
// The username and password we've fetched earlier
credentials {
username System.getenv("OPENFTC_SONATYPE_USER")
password System.getenv("OPENFTC_SONATYPE_PASSWORD")
}
}
}
}
}