| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <project name="org.apache.easyant.plugins#javadoc" xmlns:ea="antlib:org.apache.easyant"> |
| <ea:core-version requiredrevision="[0.8,+]" /> |
| |
| <macrodef name="patch-javadoc" description="workaround for CVE-2013-1571"> |
| <attribute name="dir"/> |
| <attribute name="docencoding" default="${file.encoding}"/> |
| <sequential> |
| <replace encoding="@{docencoding}" summary="true" taskname="patch-javadoc"> |
| <fileset dir="@{dir}" casesensitive="false" includes="**/index.html,**/index.htm,**/toc.html,**/toc.htm"> |
| <!-- TODO: add encoding="@{docencoding}" to contains check, when we are on ANT 1.9.0: --> |
| <not><contains text="function validURL(url) {" casesensitive="true" /></not> |
| </fileset> |
| <replacetoken><![CDATA[function loadFrames() {]]></replacetoken> |
| <replacevalue expandProperties="false"><![CDATA[if (targetPage != "" && !validURL(targetPage)) |
| targetPage = "undefined"; |
| function validURL(url) { |
| var pos = url.indexOf(".html"); |
| if (pos == -1 || pos != url.length - 5) |
| return false; |
| var allowNumber = false; |
| var allowSep = false; |
| var seenDot = false; |
| for (var i = 0; i < url.length - 5; i++) { |
| var ch = url.charAt(i); |
| if ('a' <= ch && ch <= 'z' || |
| 'A' <= ch && ch <= 'Z' || |
| ch == '$' || |
| ch == '_') { |
| allowNumber = true; |
| allowSep = true; |
| } else if ('0' <= ch && ch <= '9' |
| || ch == '-') { |
| if (!allowNumber) |
| return false; |
| } else if (ch == '/' || ch == '.') { |
| if (!allowSep) |
| return false; |
| allowNumber = false; |
| allowSep = false; |
| if (ch == '.') |
| seenDot = true; |
| if (ch == '/' && seenDot) |
| return false; |
| } else { |
| return false; |
| } |
| } |
| return true; |
| } |
| function loadFrames() {]]></replacevalue> |
| </replace> |
| </sequential> |
| </macrodef> |
| |
| <target name="javadoc:init"> |
| <ea:parameter property="src.main.java" default="${basedir}/src/main/java" description="directory where sources to be compiled are" /> |
| <ea:parameter property="src.test.java" default="${basedir}/src/test/java" description="directory where test sources to be compiled are" /> |
| <ea:parameter property="javadoc.file.encoding" default="UTF-8" description="encoding used for generated javadoc" /> |
| |
| <ea:parameter property="target.reports" default="${target}/reports" description="base directory for reports" /> |
| <ea:parameter property="target.javadoc" default="${target.reports}/javadoc" description="base directory where javadoc will be generated" /> |
| <ea:parameter property="target.javadoc.main" default="${target.javadoc}/main" description="directory where javadoc will be generated" /> |
| <ea:parameter property="target.javadoc.test" default="${target.javadoc}/test" |
| description="directory where javadoc for tests will be generated" /> |
| |
| <ea:parameter property="javadoc.publish.conf" default="documentation" description="default configuration for javadoc artifacts" /> |
| |
| <!-- javadoc task seems to be sensible to empty directory --> |
| <!-- if src.test.java does not exit OR is an empty dir we set the empty.src.test.java.dir property that will skip the javadoc generation --> |
| <condition property="empty.src.test.java.dir"> |
| <or> |
| <not> |
| <available file="${src.test.java}" /> |
| </not> |
| <length length="0"> |
| <fileset dir="${src.test.java}" /> |
| </length> |
| </or> |
| </condition> |
| <!-- if src.main.java does not exit OR is an empty dir we set the empty.src.main.java.dir property that will skip the javadoc generation --> |
| <condition property="empty.src.main.java.dir"> |
| <or> |
| <not> |
| <available file="${src.main.java}" /> |
| </not> |
| <length length="0"> |
| <fileset dir="${src.main.java}" /> |
| </length> |
| </or> |
| </condition> |
| </target> |
| |
| <target name="-javadoc:main" depends="javadoc:init" unless="empty.src.main.java.dir"> |
| <path id="java.main.source.path"> |
| <dirset dir="${src.main.java}" /> |
| </path> |
| <javadoc encoding="${javadoc.file.encoding}" docencoding="${javadoc.file.encoding}" destdir="${target.javadoc.main}" |
| sourcepathref="java.main.source.path" /> |
| |
| <patch-javadoc dir="${target.javadoc.main}" docencoding="${javadoc.file.encoding}"/> |
| </target> |
| |
| <target name="-javadoc:test" depends="javadoc:init" unless="empty.src.test.java.dir"> |
| <path id="java.test.source.path"> |
| <dirset dir="${src.test.java}" /> |
| </path> |
| <javadoc encoding="${javadoc.file.encoding}" docencoding="${javadoc.file.encoding}" destdir="${target.javadoc.test}" |
| sourcepathref="java.test.source.path" /> |
| |
| <patch-javadoc dir="${target.javadoc.test}" docencoding="${javadoc.file.encoding}"/> |
| </target> |
| |
| <target name="javadoc:package" depends="javadoc:javadoc" description="generate a package containing javadoc" |
| unless="skip.javadoc.package"> |
| <ea:parameter property="target.artifacts" default="${target}/artifacts" description="destination directory for target artifacts" /> |
| <ea:parameter property="project.ivy.instance" default="project.ivy.instance" description="the ivy instance name for your project" /> |
| |
| <mkdir dir="${target.artifacts}" /> |
| <zip destfile="${target.artifacts}/${ivy.module}-javadoc.zip"> |
| <fileset dir="${target.javadoc}" erroronmissingdir="false" /> |
| </zip> |
| <ea:registerartifact type="javadoc" ext="zip" classifier="javadoc" settingsRef="${project.ivy.instance}" |
| confs="${javadoc.publish.conf}" /> |
| </target> |
| |
| <target name="javadoc:javadoc" depends="-javadoc:main,-javadoc:test" description="generate javadoc report for main classes and test classes" /> |
| </project> |