|
| 1 | + |
| 2 | +import org.apache.tools.ant.taskdefs.condition.Os |
| 3 | + |
| 4 | + |
| 5 | +String findCommand(String dir, String command) { |
| 6 | + def extension = Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : "" |
| 7 | + def cmd = "$dir/$command$extension" |
| 8 | + if (! new File(cmd).exists()) { |
| 9 | + throw new Exception("Command $command not found in dir $dir") |
| 10 | + } |
| 11 | + cmd |
| 12 | + |
| 13 | +} |
| 14 | + |
| 15 | +String findJavaCommand(String s) { |
| 16 | + def jh = System.getenv("JAVA8_HOME") |
| 17 | + if (jh == null) { |
| 18 | + throw new Exception("Environment variable JAVA8_HOME not set") |
| 19 | + } |
| 20 | + findCommand("$jh/bin", "javadoc") |
| 21 | +} |
| 22 | + |
| 23 | +List<String> projectClasses(List<String> list) { |
| 24 | + list.collect { |
| 25 | +// "$projectDir/../$it/src/main/java" |
| 26 | + "$projectDir/../$it/build/classes/main" |
| 27 | + } |
| 28 | + |
| 29 | +} |
| 30 | + |
| 31 | +def createDynamicJavadoc(String mainPath, List<String> paths) { |
| 32 | + def taskName = "dynamicJava8Javadoc" |
| 33 | + task "$taskName"(type: Exec) { |
| 34 | + def cp = projectClasses(paths).join(";") |
| 35 | + def c = findJavaCommand("javadoc") |
| 36 | + commandLine c, "-sourcepath", "$mainPath/src/main/java", "-d", "$mainPath/build/docs/javadoc", "-subpackages", "fj", "-Xdoclint:none", "-quiet", "-classpath", cp |
| 37 | + } |
| 38 | + project.tasks[taskName] |
| 39 | +} |
| 40 | + |
| 41 | +ext { |
| 42 | + createDynamicJavadoc = this.&createDynamicJavadoc |
| 43 | +} |
| 44 | + |
| 45 | +task java8Javadoc(type: Exec) { |
| 46 | + def c = findJavaCommand("javadoc") |
| 47 | + commandLine c, "-sourcepath", "$projectDir/src/main/java", "-d", "$buildDir/docs/javadoc", "-subpackages", "fj", "-Xdoclint:none", "-quiet" |
| 48 | +} |
| 49 | + |
0 commit comments