Last active
August 29, 2015 14:08
-
-
Save scruffyfox/a0e884d6f04f0b759625 to your computer and use it in GitHub Desktop.
Delombok javadoc generator with dependency inclusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def srcJava = 'src/main/java' | |
def srcDelomboked = 'build/src-delomboked/main/java' | |
task delombok { | |
inputs.files file(srcJava) | |
outputs.dir file(srcDelomboked) | |
doLast { | |
FileCollection collection = files(configurations.compile) | |
FileCollection sumTree = collection + fileTree(dir: 'bin') | |
ant.taskdef(name: 'delombok', classname: 'lombok.delombok.ant.DelombokTask', classpath: 'libs/lombok.jar') | |
ant.delombok(from:srcJava, to:srcDelomboked, classpath: sumTree.asPath) | |
} | |
} | |
def findClasses(File path) | |
{ | |
List<File> found = new ArrayList<File>(); | |
for (File file : path.listFiles()) | |
{ | |
if (file.getName().equalsIgnoreCase("classes.jar")) | |
{ | |
found.add(file); | |
} | |
if (file.isDirectory()) | |
{ | |
found.addAll(findClasses(file)); | |
} | |
} | |
return found; | |
} | |
android.libraryVariants.all { variant -> | |
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) { | |
description "Generates Javadoc for $variant.name." | |
setDependsOn(['build', 'delombok']) | |
source = srcDelomboked | |
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" | |
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) | |
List<String> jars = new ArrayList<String>(); | |
File dependencies = new File("build/intermediates/exploded-aar/") | |
for (File folder : dependencies.listFiles()) | |
{ | |
List<File> found = findClasses(folder); | |
for (File foundFile : found) | |
{ | |
classpath += files(foundFile.getAbsolutePath()) | |
} | |
} | |
// ADD YOUR JAVADOCS HERE, AND THEIR PACKAGE NAMES | |
options.links("http://3sidedcube.github.io/Android-LightningUtil/", "com.cube.storm.util"); | |
options.links("http://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/", "com.google.gson") | |
options.links("http://docs.oracle.com/javase/7/docs/api/"); | |
options.linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"); | |
// exclude generated files | |
exclude '**/BuildConfig.java' | |
exclude '**/R.java' | |
// exclude any internal packages | |
exclude '**/com/acme/sdk/api/**' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: http://andydyer.org/blog/2014/09/29/delombok-and-javadoc-with-gradle/