-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbintray_publish.gradle
140 lines (131 loc) · 4.65 KB
/
bintray_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
129
130
131
132
133
134
135
136
137
138
139
140
/**
* Use this plugin to publish an Android library in the jCenter repository via BinTray.
*
* JCenter is the default repository with the Android's gradle plugin. It is a superset
* of the good old Maven Central repository. Also, this process is remarkably less cumbersome
* than the Maven way.
*
* HOW TO
*
* To publish a new library (this is the first-time-only setup):
*
* 1. Create an account at bintray.com
* 2. From the website, add a new package in your maven repository, with the name of your artifact
* 3. Configure your "ext" block as indicated in CONFIGURATION
* 4. Execute the Gradle task as indicated in USAGE
* 5. Find your library and version appear in your Bintray repo, such as https://bintray.com/espinchi/maven/pixalytics-core/view
* 6. Publish it in the JCenter repository by clicking on the "Include My Package" button
* 5. In a few hours, you will get a message from bintray authorising it
*
* To publish a new version of an existing library (from here on)
*
* 1. Update the version number
* 2. Execute the Gradle task as indicated in USAGE
*
* To publish a new version of an existing library of a different author (not too common): follow the steps as if you were
* publishing a new library. You will be publishing into your own bintray account. From there, you'll have to publish into
* JCenter from the web interface (step 6 above).
*
* USAGE
*
* To publish a new library, or a new version of an existing library, just execute this command
* from the module directory:
*
* ../gradlew bintrayUpload
*
* CONFIGURATION
*
* Add this this plugin by adding this line in your module's build.gradle:
*
* apply from: '../bintray_publish.gradle'
*
* To pass the parameters in, use an "ext" block somewhere in your module's build.gradle. Use
* this as a template:
*
* <pre>
ext {
// Library identifier. Your final dependency will be `group:artifact:version
libraryGroup = 'com.mycompany'
libraryArtifact = 'my-fancy-library'
libraryVersion = '1.0.0'
// Optional Maven parameters to build the pom.xml
libraryDescription = 'This library does this and that'
librarySiteUrl = 'https://github.com/mycompany/my-fancy-library'
libraryGitUrl = 'https://github.com/mycompany/my-fancy-library.git'
libraryLicense = {
name 'MIT'
url 'http://opensource.org/licenses/MIT'
}
libraryDevelopers = {
developer {
id 'my-github-name'
name 'My Name'
email '[email protected]'
}
}
// Credentials in Bintray. In a "bintray.properties" file that's ignored in Git
Properties properties = new Properties()
properties.load(project.rootProject.file('bintray.properties').newDataInputStream())
bintrayUser = properties.getProperty('bintray.user') // Yes, you need to create an account at bintray.com
bintrayApiKey = properties.getProperty('bintray.apikey') // Find it in your profile settings at bintray.com
}
</pre>
*
* MORE INFORMATION
*
* Great blog post: https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/
* Official Bintray plugin, that this plugin here wraps: https://github.com/bintray/gradle-bintray-plugin
*/
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = libraryVersion
group = libraryGroup
bintray {
user = bintrayUser
key = bintrayApiKey
configurations = ['archives']
pkg {
repo = "maven"
name = libraryArtifact
websiteUrl = librarySiteUrl
vcsUrl = libraryGitUrl
licenses = [libraryLicense.name]
publish = true
}
}
install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
name libraryDescription
url librarySiteUrl
licenses {
license libraryLicense
}
developers libraryDevelopers
scm {
connection libraryGitUrl
developerConnection libraryGitUrl
url librarySiteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}