Skip to content

Commit 27ff1f1

Browse files
committed
Update javadoc target to work with both unnamed and named packages
and to incorporate links to referenced Java API classes.
1 parent d6d31a0 commit 27ff1f1

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

build.xml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
<property name="dist.dir" value="dist"/>
1212
<property name="docs.dir" value="build/docs"/>
1313

14+
<!-- Javadoc external API links. Uses the JDK running Ant; no hard-coded Java version. -->
15+
<condition property="javadoc.api.url" value="https://docs.oracle.com/javase/8/docs/api/">
16+
<equals arg1="${java.specification.version}" arg2="1.8"/>
17+
</condition>
18+
<condition property="javadoc.api.url" value="https://docs.oracle.com/en/java/javase/${java.specification.version}/docs/api/">
19+
<not>
20+
<equals arg1="${java.specification.version}" arg2="1.8"/>
21+
</not>
22+
</condition>
23+
24+
1425
<condition property="isMac">
1526
<os family="mac"/>
1627
</condition>
@@ -26,12 +37,20 @@
2637
<isset property="isMac"/>
2738
</condition>
2839

40+
<target name="preflight" description="Print toolchain/OS info">
41+
<echo message="Java: ${java.runtime.name} ${java.runtime.version}"/>
42+
<echo message="Java Vendor: ${java.vendor}"/>
43+
<echo message="Java Home: ${java.home}"/>
44+
<echo message="Java Spec Version: ${java.specification.version}"/>
45+
<echo message="OS: ${os.name} ${os.version} (${os.arch})"/>
46+
</target>
47+
2948
<target name="clean" description="Remove all build and distribution files">
3049
<delete dir="build"/>
3150
<delete dir="${dist.dir}"/>
3251
</target>
3352

34-
<target name="compile" description="Compile Java source code">
53+
<target name="compile" depends="preflight" description="Compile Java source code">
3554
<mkdir dir="${build.dir}"/>
3655
<javac srcdir="${src.dir}"
3756
destdir="${build.dir}"
@@ -53,14 +72,26 @@
5372
<java jar="${jar.dir}/${app.name}.jar" fork="true"/>
5473
</target>
5574

56-
<target name="javadoc" description="Generate API documentation with Javadoc">
75+
<target name="javadoc" depends="preflight" description="Generate Javadoc (works for unnamed or named packages)">
5776
<mkdir dir="${docs.dir}"/>
5877
<javadoc destdir="${docs.dir}"
59-
sourcepath="${src.dir}"
60-
packagenames="*"
78+
source="1.8"
79+
encoding="UTF-8"
6180
use="true"
6281
author="true"
63-
version="true"/>
82+
version="true"
83+
failonerror="true">
84+
<fileset dir="${src.dir}" includes="**/*.java"/>
85+
86+
<link href="${javadoc.api.url}"/>
87+
<!-- Uncomment to resolve references in Javadoc comments. -->
88+
<!--
89+
<classpath>
90+
<pathelement path="${build.dir}"/>
91+
<fileset dir="lib" includes="**/*.jar"/>
92+
</classpath>
93+
-->
94+
</javadoc>
6495
</target>
6596

6697
<target name="package" description="Build the native installer for the current OS (DMG or DEB)">
@@ -79,7 +110,6 @@
79110
<arg value="--type"/><arg value="dmg"/>
80111
<arg value="--icon"/><arg value="${icon.file}"/>
81112
<arg value="--app-version"/><arg value="${app.version}"/>
82-
83113
<arg value="--mac-package-name"/><arg value="${app.name}"/>
84114
<arg value="--mac-package-identifier"/><arg value="com.example.${app.name}"/>
85115
</exec>

0 commit comments

Comments
 (0)