Skip to content

Commit d53c2d4

Browse files
notusedusernameMathieuSoysal
authored andcommitted
fix(#95): Added support for older and newer maven-javadoc-plugin
The path of the generated javadocs changed in 3.10.0; these changes aim to support both versions by automatically detecting the user's version
1 parent 2385492 commit d53c2d4

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

action.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ inputs:
4646
javadoc-source-folder:
4747
description: "Custom path for the new Javadoc"
4848
required: false
49-
default: target/reports/apidocs
5049

5150
# Development and testing inputs
5251
without-deploy: # deploy the javadoc to the GitHub Page, is used for development testing with nektos/act
@@ -90,12 +89,39 @@ runs:
9089
- name: Set Javadoc source folder
9190
id: set-javadoc-source-folder
9291
run: |
93-
if [[ ${{ inputs.project }} == "gradle" && ${{ inputs.javadoc-source-folder }} == "target/reports/apidocs" ]]; then
94-
echo "javadoc-source-folder=build/docs/javadoc" >> "$GITHUB_OUTPUT"
95-
elif [ ! -d ${{ inputs.javadoc-source-folder }} ]; then
96-
echo "javadoc-source-folder=target/site/apidocs" >> "$GITHUB_OUTPUT"
97-
else
92+
gradle_path="build/docs/javadoc"
93+
maven_pre_javadoc_3_10_x="target/site/apidocs"
94+
maven_post_javadoc_3_10_x="target/reports/apidocs"
95+
96+
if [[ ! ${{ inputs.javadoc-source-folder }} == "" ]]; then
97+
echo "::notice Using custom 'javadoc-source-folder': '${{ inputs.javadoc-source-folder }}'"
9898
echo "javadoc-source-folder=${{ inputs.javadoc-source-folder }}" >> "$GITHUB_OUTPUT"
99+
exit 0
100+
fi
101+
102+
if [[ ${{ inputs.project }} == "gradle" ]]; then
103+
echo "::notice No custom 'javadoc-source-folder' was provided, using default Gradle path '$gradle_path'"
104+
echo "javadoc-source-folder=$gradle_path" >> "$GITHUB_OUTPUT"
105+
exit 0
106+
fi
107+
108+
# Else assuming Maven as inputs.project for backwards compatiblity
109+
subdir_prefix=""
110+
if [[ ! ${{ inputs.subdirectories }} == "" ]]; then
111+
subdir_prefix=$(echo $subdirectories | tr " " "\n" | head -n 1)/
112+
echo "::notice Checking for maven-javadoc-plugin output in the first subdirectory '$subdir_prefix'"
113+
fi
114+
115+
# Checking for plugin outputs to determine maven-javadoc-plugin version
116+
if [[ -d "$subdir_prefix$maven_pre_javadoc_3_10_x" ]]; then
117+
echo "::notice Detected maven-javadoc-plugin output with version older than 3.10.0, using path '$maven_pre_javadoc_3_10_x'"
118+
echo "javadoc-source-folder=$maven_pre_javadoc_3_10_x" >> "$GITHUB_OUTPUT"
119+
elif [[ -d "$subdir_prefix$maven_post_javadoc_3_10_x" ]]; then
120+
echo "::notice Detected maven-javadoc-plugin output with version newer than 3.10.0, using path '$maven_post_javadoc_3_10_x'"
121+
echo "javadoc-source-folder=$maven_post_javadoc_3_10_x" >> "$GITHUB_OUTPUT"
122+
else
123+
echo "::error Could not find maven-javadoc-plugin output on the default path(s) ($maven_pre_javadoc_3_10_x for versions older than 3.10.0, or $maven_post_javadoc_3_10_x for 3.10.0+) and no custom value was provided for 'javadoc-source-path' input."
124+
exit 1
99125
fi
100126
shell: bash
101127

0 commit comments

Comments
 (0)