Skip to content

Commit

Permalink
test: support multimodule projects
Browse files Browse the repository at this point in the history
  • Loading branch information
berezinant committed Jan 17, 2024
1 parent e6235f5 commit 3511bf9
Showing 1 changed file with 43 additions and 15 deletions.
58 changes: 43 additions & 15 deletions testDokka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ DOKKA_REPO_PATH="./"
# Port to view results
PORT=8001

#
IS_MULTIMODULE=0

# 0. Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
Expand All @@ -27,32 +30,53 @@ while [[ $# -gt 0 ]]; do
TEST_PROJECT_PATH="$2"
shift 2
;;
-m|--multimodule)
IS_MULTIMODULE=1
shift
;;
-p|--port)
PORT="$2"
shift 2
;;
*)
echo "Wrong parameter: $1"
echo "TestDokka: Wrong parameter: $1"
exit 1
;;
esac
done

echo "Test locally Dokka version $NEW_VERSION"
echo "Test project path: $TEST_PROJECT_PATH"
echo "Dokka path: $DOKKA_REPO_PATH"
echo "Port: $PORT"
echo "TestDokka: Test locally Dokka version $NEW_VERSION"
echo "TestDokka: Test project path: $TEST_PROJECT_PATH"
echo "TestDokka: Is multimodule: $IS_MULTIMODULE"
echo "TestDokka: Dokka path: $DOKKA_REPO_PATH"
echo "TestDokka: Port: $PORT"

# 1. Publish to local Maven repository
cd "$DOKKA_REPO_PATH"
echo "TestDokka: Publish to local Maven repository"
./gradlew publishToMavenLocal -Pversion="$NEW_VERSION"

# 2. Update Dokka version in test project
cd "$TEST_PROJECT_PATH"
sed -i "" "s/\(id(\"org\.jetbrains\.dokka\") version\) \".*\"/\1 \"$NEW_VERSION\"/" build.gradle.kts
if [ -f "build.gradle.kts" ]; then
echo "TestDokka: Update version in build.gradle.kts"
sed -i "" "s/\(id(\"org\.jetbrains\.dokka\") version\) \".*\"/\1 \"$NEW_VERSION\"/" build.gradle.kts
fi

if [ -f "gradle.properties" ]; then
echo "TestDokka: Update version in gradle.properties"
sed -i "" "s/dokka_version=.*/dokka_version=$NEW_VERSION/" gradle.properties
fi


# 3. Build and generate documentation
./gradlew clean && ./gradlew dokkaHTML
if [ "$IS_MULTIMODULE" -eq 1 ]; then
echo "TestDokka: Build multimodule project"
./gradlew clean && ./gradlew dokkaHtmlMultiModule
else
echo "TestDokka: Build single module project"
./gradlew clean && ./gradlew dokkaHTML
fi

wait

Expand All @@ -62,21 +86,25 @@ PID=$(lsof -t -i :"$PORT" || true)

# Check that PID is not empty
if [ -n "$PID" ]; then
echo "Kill process with PID $PID"
echo "TestDokka: Kill process with PID $PID"
kill -9 "$PID"
else
echo "Port $PORT is free"
echo "TestDokka: Port $PORT is free"
fi

# 5.1 Echo link to documentation
echo "Open http://localhost:$PORT in browser"
echo "TestDokka: Open http://localhost:$PORT in browser"

# 5.2 Start Python server to view results
cd "./build/dokka/html"
if [ "$IS_MULTIMODULE" -eq 1 ]; then
cd "./build/dokka/htmlMultiModule"
else
cd "./build/dokka/html"
fi

echo 'Start Python server in directory'
echo "$TEST_PROJECT_PATH/build/dokka/html"
echo 'TestDokka: Start Python server in directory'
echo "TestDokka: $TEST_PROJECT_PATH/build/dokka/html"

python3 -m http.server $PORT
python3 -m http.server "$PORT"

echo "Done"
echo "TestDokka: Done"

0 comments on commit 3511bf9

Please sign in to comment.