-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate_javadoc_for_release.sh
executable file
·118 lines (100 loc) · 4.38 KB
/
generate_javadoc_for_release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash -e
VERSION=12
WORKDIR=out
ALLOW_SNAPSHOT=0
# create work directory
if [ ! -d $WORKDIR ] ; then
mkdir -p $WORKDIR
fi
# get bundle list
if [ -f $WORKDIR/feature.json ] ; then
echo "feature.json already present, not downloading";
else
echo "Downloading bundle list for Sling $VERSION (oak-tar variant)"
wget https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.starter/$VERSION/org.apache.sling.starter-$VERSION-oak_tar.slingosgifeature -O $WORKDIR/feature.json
fi
# extract <artifactId>-<version> from feature file
artifacts=$(cat $WORKDIR/feature.json | jq -r '.bundles[].id | select(startswith("org.apache.sling"))' | awk -F ':' '{ print $2 ":" $3 }')
# add additional artifacts which are not part of the launchpad
# https://issues.apache.org/jira/browse/SLING-6766
artifacts+=" adapter-annotations:1.0.0"
artifacts+=" org.apache.sling.servlets.annotations:1.1.0"
# checkout tags
for artifact in $artifacts; do
artifact_name=$(echo $artifact | sed 's/:.*//')
artifact_version=$(echo $artifact | sed 's/.*://')
branch_name="${artifact_name}-${artifact_version}"
artifact_dir="sling-${artifact_name}-${artifact_version}"
artifact_repo=$(echo $artifact_name | tr '.' '-')
artifact_repo="sling-${artifact_repo}"
# - don't document Slingshot sample
# - threaddump was renamed and tag history is lost
# - validation core fails on Javadoc aggregation, but does not export anything
if [[ ${artifact_name} == *slingshot || ${artifact_name} = "org.apache.sling.extensions.threaddump" || ${artifact_name} == "org.apache.sling.validation.core" ]]; then
continue;
fi
if [ -d $WORKDIR/$artifact_dir ] ; then
echo "Not checking out $artifact_dir, already present";
else
if [[ "$artifact_version" == *-SNAPSHOT ]]; then
if [ $ALLOW_SNAPSHOT == 0 ] ; then
echo "Failing build due to SNAPSHOT artifact $artifact";
exit 1;
else
continue
fi
fi
echo "Exporting $artifact from source control"
git -c advice.detachedHead=false clone https://github.com/apache/${artifact_repo} --branch ${branch_name} ${WORKDIR}/${artifact_dir}
if [ -f patches/$artifact ]; then
echo "Applying patch"
pushd $WORKDIR/$artifact_dir
patch -p0 < ../../patches/$artifact_dir
popd
fi
fi
done
# generate dummy pom.xml
echo "Generating pom.xml"
pushd $WORKDIR
POM=pom.xml
echo "<project>" > $POM
echo " <modelVersion>4.0.0</modelVersion>" >> $POM
echo " <groupId>org.apache.sling</groupId>" >> $POM
echo " <artifactId>org.apache.sling.javadoc-builder</artifactId>" >> $POM
echo " <packaging>pom</packaging>" >> $POM
echo " <version>$VERSION</version>" >> $POM
echo >> $POM
echo " <parent>" >> $POM
echo " <groupId>org.apache</groupId>" >> $POM
echo " <artifactId>apache</artifactId>" >> $POM
echo " <version>8</version>" >> $POM
echo " </parent>" >> $POM
echo >> $POM
echo " <name>Apache Sling</name>" >> $POM
echo >> $POM
echo " <properties>" >> $POM
echo " <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>" >> $POM
echo " </properties>" >> $POM
echo >> $POM
echo " <modules> " >> $POM
for artifact_dir in $(find . -type d -maxdepth 1 -name '*sling*'); do
echo " <module>$artifact_dir</module>" >> $POM
done
echo " </modules>" >> $POM
echo "</project>" >> $POM
popd
if [ ! -f $WORKDIR/src/main/javadoc/overview.html ] ; then
echo "Downloading javadoc overview file"
mkdir -p $WORKDIR/src/main/javadoc
wget https://svn.apache.org/repos/asf/sling/trunk/src/main/javadoc/overview.html -O $WORKDIR/src/main/javadoc/overview.html
fi
# generate javadoc
echo "Starting javadoc generation"
pushd $WORKDIR
# This might fail due to duplications in the classpath (see https://issues.apache.org/jira/browse/SLING-6766?focusedCommentId=16358298&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16358298)
# The classpath order is unfortunately not predictable with m-j-p 3.0.0 (https://issues.apache.org/jira/browse/MJAVADOC-513)
mvn -DexcludePackageNames="*.impl:*.internal:*.jsp:sun.misc:*.juli:*.testservices:*.integrationtest:*.maven:javax.*:org.osgi.*" \
org.apache.maven.plugins:maven-javadoc-plugin:3.0.0:aggregate -Dnotimestamp=true -Dignore.javadocjdk=true
popd
echo "Generated Javadocs can be found in $WORKDIR/target/site/apidocs/"