-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartifacts.gradle
More file actions
73 lines (58 loc) · 3.08 KB
/
artifacts.gradle
File metadata and controls
73 lines (58 loc) · 3.08 KB
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
apply plugin: 'com.github.dcendents.android-maven'
if (project.plugins.hasPlugin('com.android.library')) {
android.libraryVariants.all { variant ->
Task javadocTask = task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
group = 'artifact'
description "Generates Javadoc for $variant.name"
// Source files from the variant
source = variant.javaCompiler.source
// Classpath from the variant + android.jar
String androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = variant.javaCompiler.classpath + files(androidJar)
// The Android online reference doesn't include package-list, so we have to use the local one
String packageListRef = "${android.sdkDirectory}/docs/reference/"
options.linksOffline 'http://d.android.com/reference/', packageListRef
// Exclude generated files
exclude '**/BuildConfig.java'
exclude '**/R.java'
// Output to a unique javadoc folder per variant
destinationDir = new File(project.docsDir, "javadoc-$variant.name")
}
// For official releasese, don't prefix the name so the artifact is published correctly
// (Can't seem to modify it for publishing, for whatever reason...)
String classifierPrefix = (variant.name == 'release') ? '' : "$variant.name-"
Task javadocJarTask = task("generate${variant.name.capitalize()}JavadocJar", type: Jar, dependsOn: javadocTask) {
group = 'artifact'
description = "Generates javadoc jar for $variant.name"
classifier = "${classifierPrefix}javadoc"
from javadocTask.destinationDir
}
Task sourcesJarTask = task("generate${variant.name.capitalize()}SourcesJar", type: Jar) {
group = 'artifact'
description = "Generates sources jar for $variant.name"
classifier = "${classifierPrefix}sources"
from variant.javaCompiler.source
}
Task jarTask = task("jar${variant.name.capitalize()}", type: Jar, dependsOn: variant.javaCompile) {
group = 'artifact'
description = "Generates exported jar for $variant.name"
from variant.javaCompile.destinationDir
// Exclude generated files
exclude '**/BuildConfig.class'
exclude '**/R.class'
}
if (variant.name == 'release') {
// There's a lot of "magic" around the archives configuration; easier
// just to embrace it rather than try to configure around it
artifacts {
archives javadocJarTask, sourcesJarTask, jarTask
}
} else {
// Create a configuration we can publish from for each variant
String configurationName = "archives${variant.name.capitalize()}"
configurations.create(configurationName)
artifacts.add configurationName, javadocJarTask
artifacts.add configurationName, sourcesJarTask
}
}
}