Skip to content

Instantly share code, notes, and snippets.

@Jthomas54
Last active June 9, 2017 16:40
Show Gist options
  • Save Jthomas54/b710f225fd378858661e2224ebd88f5f to your computer and use it in GitHub Desktop.
Save Jthomas54/b710f225fd378858661e2224ebd88f5f to your computer and use it in GitHub Desktop.
Tasks for doclava and jars
android {
configurations {
//Used to hold the doclava dependency configuration
doclava
//Used to hold the other dependency configuration
classpaths
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
classpaths compile 'com.squareup.retrofit2:retrofit:2.0.0'
classpaths compile 'com.squareup.retrofit2:converter-gson:2.0.0'
doclava 'com.google.doclava:doclava:1.0.6'
}
//Create doclava tasks
libraryVariants.all { variant ->
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
source = variant.javaCompile.source
title = null
classpath = files(configurations.classpaths.files.asType(List), android.getBootClasspath())
options.docletpath = configurations.doclava.files.asType(List)
options.memberLevel = JavadocMemberLevel.PUBLIC
options.addStringOption "hdf project.name", "Change Document Name Here"
options {
doclet 'com.google.doclava.Doclava'
encoding = 'UTF-8'
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
}
//Create jar tasks
libraryVariants.all { variant ->
def name = variant.buildType.name
if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
return //ignore debug
}
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
artifacts.add('archives', task);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment