#!/bin/bash

set -eau pipefail

# run basic gradle tasks
echo
echo "----------------------------------------"
echo "Running tests"
echo "----------------------------------------"
# TODO : the build.gradle.kts needs to accept a parameter to set spring profile
# ./gradlew clean test --args='--spring.profiles.active=local-test'
./gradlew clean test

# run code analysis
echo
echo "----------------------------------------"
echo "Running code analysis"
echo "----------------------------------------"
./gradlew ktlintCheck
./gradlew detekt

# build the bootJar with gitinfo
echo
echo "----------------------------------------"
echo "Building bootJar"
echo "----------------------------------------"
./gradlew bootJar -Pgitinfo

# copy the jar file to this directory
echo
echo "----------------------------------------"
echo "Copying marvel.jar here"
echo "----------------------------------------"
cp restapi/build/libs/marvel.jar ./

