You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The publisher plugin uses an older version of itself to publish itself into Bintray's JCenter.
29
-
This means that you can check the plugin source code to see an example of how to use it.
30
-
31
-
For more examples, please take a look at [natario1/Egloo](https://github.com/natario1/Egloo), [natario1/Firestore](https://github.com/natario1/Firestore) or [natario1/Elements](https://github.com/natario1/Elements).
32
-
33
22
## Usage
34
23
35
-
To apply the plugin, declare it in your build script with the `com.otaliastudios.tools.publisher` id:
24
+
To apply the plugin, declare it in your build script with the `io.deepmedia.tools.grease` id.
25
+
This must be done after the com.android.library plugin:
36
26
37
27
```groovy
38
-
apply plugin: 'com.otaliastudios.tools.publisher'
28
+
apply plugin: 'com.android.library'
29
+
apply plugin: 'io.deepmedia.tools.grease'
39
30
```
40
31
41
-
### Base Configuration
42
-
43
-
All publishers are configured with the same common fields, although specific publisher
44
-
implementations can have extra fields (for example, for authentication). The common configuration
45
-
is specified at the root level of the `publisher` block:
32
+
Once applied, Grease will create Gradle configurations that you can use to select which of your
33
+
dependencies should be bundled in the final fat AAR.
46
34
47
35
```kotlin
48
-
publisher {
49
-
// Project name. Defaults to rootProject.name
50
-
project.name ="MavenPublisher"
51
-
52
-
// Project description. Can be null
53
-
project.description ="Handy tool to publish maven packages in different repositories."
54
-
55
-
// Package artifact. Defaults to project's archivesBaseName
// Release VCS tag. Defaults to "v${release.version}"
78
-
release.vcsTag ="v0.1.4"
79
-
80
-
// Release description. Defaults to "${project.name} {release.vcsTag}"
81
-
release.description ="New release"
82
-
83
-
// Release sources
84
-
release.setSources(Release.SOURCES_AUTO) // creates a sources Jar
85
-
release.setSources(sourcesJar.get())
86
-
87
-
// Release docs
88
-
release.setDocs(Release.DOCS_AUTO) // create a docs Jar
89
-
release.setDocs(dokkaJar.get())
90
-
}
91
-
```
92
-
93
-
Actual publishers can then be registered in this block by using their respective functions,
94
-
for example:
36
+
dependencies {
37
+
// Api dependency. This will not be bundled.
38
+
api("androidx.core:core:1.3.1")
95
39
96
-
```kotlin
97
-
publisher {
98
-
// Common configuration...
99
-
project.name ="Project name"
100
-
project.description ="Project description"
40
+
// Implementation dependency. This will not be bundled.
41
+
implementation("androidx.core:core:1.3.1")
101
42
102
-
bintray {
103
-
// Override some fields or add missing ones
104
-
project.name ="Project name for bintray"
105
-
release.version ="1.0.0-nightly"
106
-
}
43
+
// Grease dependency! This will be bundled into the final AAR.
44
+
grease("androidx.core:core:1.3.1")
107
45
108
-
directory {
109
-
// Override some fields or add missing ones
110
-
project.description ="Project description for local directory"
111
-
release.version ="1.0.0-rc1"
112
-
}
46
+
// Build-type, product flavour and variant specific configurations.
47
+
// Can be used to enable grease only on specific library variants.
48
+
greaseRelease("androidx.core:core:1.3.1")
49
+
greaseDebug("androidx.core:core:1.3.1")
113
50
}
114
51
```
115
52
116
-
### Specifying the publication contents
117
-
118
-
You have two options to specify the publication contents. MavenPublisher will try to infer default
119
-
values based on the currently applied plugin.
120
-
121
-
-`publisher.component` : specifies the name of a `SoftwareComponent`. Defaults to "release" for Android projects and "java" for java projects, both of which create components for you.
122
-
-`publisher.publication` : specifies the name of a `MavenPublication`. Defaults to null. When this is set, we'll use the publication's `SoftwareComponent` and modify the other publication fields to match the publisher configuration.
123
-
124
-
Typically, you should specify either one or the other.
125
-
126
-
### Secret values
127
-
128
-
Some sensitive values, especially in the auth configuration, are declared as secret.
129
-
In this case, instead of passing the real value, you are supposed to pass a **key** to the real
130
-
value.
131
-
132
-
The publisher will use this key and look for the value as follows:
133
-
134
-
- Look in environment variables
135
-
- Search with `project.findProperty(key)`
136
-
- Search in `local.properties` file, if present
137
-
138
-
### Publication tasks
139
-
140
-
The publisher plugin will add a task named `:publishTo` followed by the publication name.
141
-
The publication name depends on the publisher being used (for example, bintray) and the name
142
-
that is passed to the configuration. For example:
143
-
144
-
```kotlin
145
-
publisher {
146
-
// Common configuration ...
147
-
148
-
bintray {
149
-
// Bintray onfiguration...
150
-
}
151
-
bintray("foo") {
152
-
// Bintray configuration for foo...
153
-
}
154
-
bintray("bar") {
155
-
// Bintray configuration for bar...
156
-
}
157
-
directory {
158
-
// Local dir configuration...
159
-
}
160
-
directory("abc") {
161
-
// Local dir configuration...
162
-
}
163
-
}
164
-
```
165
-
166
-
In the example above, the following tasks will be available:
167
-
168
-
-`:publishToBintray`: publishes the default bintray configuration
169
-
-`:publishToBintrayFoo`: publishes the `foo` bintray configuration
170
-
-`:publishToBintrayBar`: publishes the `bar` bintray configuration
171
-
-`:publishToDirectory`: publishes the default directory configuration
172
-
-`:publishToDirectoryAbc`: publishes the `abc` bintray configuration
173
-
-`:publishAllBintray`: publishes all "bintray" publications
174
-
-`:publishAllDirectory`: publishes all "directory" publications
175
-
-`:publishAll`: publishes everything
176
-
177
-
## Local repository publisher
178
-
179
-
In addition to the common configuration fields, the local publisher will ask you for a path to the
180
-
local directory where the final package should be published. It can be set as follows:
181
-
182
-
```kotlin
183
-
publisher {
184
-
// Common configuration...
185
-
directory {
186
-
// Directory configuration...
187
-
directory ="build/output"
188
-
}
189
-
190
-
// If needed, you can add other named publications.
191
-
directory("other") { ... }
192
-
}
193
-
```
194
-
195
-
As described earlier, all the configuration fields that are set in the `directory` block will override
196
-
the root level values.
197
-
198
-
If the directory is not set, the local publisher will publish into the "maven local" repository,
199
-
typically `$USER_HOME/.m2/repository` (see [docs](https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.html#org.gradle.api.artifacts.dsl.RepositoryHandler:mavenLocal())).
200
-
201
-
## Bintray publisher
202
-
203
-
In addition to the common configuration fields, to authenticate to Bintray, you will need to pass
204
-
a user name, a user key and the Bintray repo name as follows:
205
-
206
-
```kotlin
207
-
publisher {
208
-
// Common configuration...
209
-
bintray {
210
-
// Bintray configuration...
211
-
auth.user ="BINTRAY_USER"// defaults to "auth.user"
212
-
auth.key ="BINTRAY_KEY"// defaults to "auth.key"
213
-
auth.repo ="BINTRAY_REPO"// defaults to "auth.repo"
214
-
dryRun =false// true for a dry-run publication for testing
215
-
}
216
-
217
-
// If needed, you can add other named publications.
218
-
bintray("other") { ... }
219
-
}
220
-
```
221
-
222
-
As described earlier, all the configuration fields that are set in the `bintray` block will override
223
-
the root level values.
224
-
225
-
Note that the `auth` values are [Secret values](#secret-values), so instead of passing the real
226
-
value in plain text, a key (to an environment variable or local property) should be passed.
53
+
Note that we used `androidx.core:core:1.3.1` as an example, but that is not recommended as it will
54
+
likely cause compile issue on projects that consume the Grease AAR, if they already depend on the
55
+
`androidx.core:core:1.3.1` (as most project do).
227
56
228
-
Since there is a default key, there is no need to declare your own keys in the plugin configuration -
229
-
you can simply provide values for the default keys (for example, as env properties).
57
+
If you don't control the projects that will consume the Grease AAR, you should only bundle in
58
+
dependencies that you own, to be sure that they won't be present in the classpath of the consumer.
0 commit comments