diff --git a/build/build-production.sh b/build/build-production.sh index 4410c4b..4119066 100755 --- a/build/build-production.sh +++ b/build/build-production.sh @@ -8,13 +8,11 @@ readonly NAME_PROJ="logfilter" readonly DIR_ARCHIVE="./docs/archive" readonly PROFILE="production" -readonly CMD_BUILD="mvn clean package site:site -P ${PROFILE} -DPID=$$" -# package only -# readonly CMD_BUILD="mvn clean package -P ${PROFILE} -PID=$$" +readonly SONAR_URL="https://sonarcloud.io" +readonly SONAR_ORGANIZATION="suwa-sh-github" +readonly SONAR_EXCLUDES="src/test/**,**/classification/**,**/dto/**,**/exception/**,**/*Const.java" -# package only & skip test -# readonly CMD_BUILD="mvn clean package -Dmaven.test.skip=true -P ${PROFILE}" # -------------------------------------------------- # build @@ -34,8 +32,22 @@ echo echo -------------------------------------------------- echo build echo -------------------------------------------------- -echo ${CMD_BUILD} -${CMD_BUILD} +if [[ "${SONAR_TOKEN}x" = "x" ]]; then + echo "SONAR_TOKEN が定義されていません。sonar解析をスキップします。" + readonly CMD_BUILD="mvn clean package site:site -P ${PROFILE} -DPID=$$" + echo ${CMD_BUILD} + ${CMD_BUILD} + +else + readonly CMD_BUILD="mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package site:site sonar:sonar -P ${PROFILE} -DPID=$$" + echo ${CMD_BUILD} + ${CMD_BUILD} \ + -Dsonar.host.url=${SONAR_URL} \ + -Dsonar.organization=${SONAR_ORGANIZATION} \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.exclusions="${SONAR_EXCLUDES}" 2>&1 | tee -a ${PATH_LOG} 2>&1 +fi + ret_code=$? if [ ${ret_code} -ne 0 ]; then echo "maven buildでエラーが発生しました。" >&2 @@ -52,4 +64,3 @@ mv target/${NAME_PROJ}*.tar.gz ${DIR_ARCHIVE} ls -l "${DIR_ARCHIVE}" exit 0 - diff --git a/pom.xml b/pom.xml index faeb463..7ea5b57 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 logfilter 1.0.0 - Log Filter + logfilter me.suwash.commons @@ -374,4 +374,4 @@ Github https://github.com/suwa-sh/logfilter/issues - \ No newline at end of file +