From 85917cbb25e4546992d6e4ab46e293c3c7918c38 Mon Sep 17 00:00:00 2001 From: Allen Wittenauer Date: Fri, 22 Apr 2022 15:44:12 -0700 Subject: [PATCH] YETUS-1161. Switch pom versions to use maven.config --- .gitignore | 1 + .mvn/maven.config | 1 + .yetus/excludes.txt | 1 + asf-site-src/pom.xml | 2 +- .../audience-annotations/pom.xml | 2 +- audience-annotations-component/pom.xml | 2 +- pom.xml | 29 ++++++++++++- precommit/pom.xml | 2 +- precommit/src/main/shell/core.d/01-common.sh | 8 ++-- precommit/src/main/shell/test-patch.sh | 2 +- release/initial-patches.sh | 43 +++++++++++-------- releasedocmaker/pom.xml | 2 +- shelldocs/pom.xml | 2 +- yetus-assemblies/pom.xml | 2 +- yetus-dist/pom.xml | 2 +- yetus-maven-plugin/pom.xml | 2 +- 16 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 .mvn/maven.config diff --git a/.gitignore b/.gitignore index 480fc9222..a34ac9631 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store *.iml +.flattened-pom.xml *.ipr *.iws *.orig diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 000000000..deb9e1d11 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1 @@ +-Drevision=0.14.0-SNAPSHOT diff --git a/.yetus/excludes.txt b/.yetus/excludes.txt index 87ec84c64..8fc1bade6 100644 --- a/.yetus/excludes.txt +++ b/.yetus/excludes.txt @@ -18,3 +18,4 @@ precommit/src/test/resources/brokenfiles/a.*\.txt precommit/src/test/resources/brokenfiles/[2-3]\.txt ^precommit/src/test/resources/brokenfiles/4\.txt precommit/src/test/resources/brokenfiles/perlcritic.pl +.mvn/maven.config diff --git a/asf-site-src/pom.xml b/asf-site-src/pom.xml index ad66a00f5..b70a0e977 100644 --- a/asf-site-src/pom.xml +++ b/asf-site-src/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. asf-site diff --git a/audience-annotations-component/audience-annotations/pom.xml b/audience-annotations-component/audience-annotations/pom.xml index 049c6c268..ed575e675 100644 --- a/audience-annotations-component/audience-annotations/pom.xml +++ b/audience-annotations-component/audience-annotations/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} ../.. audience-annotations diff --git a/audience-annotations-component/pom.xml b/audience-annotations-component/pom.xml index aaec25f6c..696873eb5 100644 --- a/audience-annotations-component/pom.xml +++ b/audience-annotations-component/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. audience-annotations-component diff --git a/pom.xml b/pom.xml index 1745f96bc..64222a821 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} Project-wide definitions for Apache Yetus Apache Yetus Project pom @@ -67,6 +67,7 @@ 9.0 2.11.0 3.0.0 + 1.2.7 5.8.2 3.1.2 3.3.1 @@ -93,7 +94,6 @@ - org.codehaus.mojo exec-maven-plugin @@ -194,6 +194,31 @@ + + org.codehaus.mojo + flatten-maven-plugin + ${flatten.version} + + true + resolveCiFriendliesOnly + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + org.apache.maven.plugins diff --git a/precommit/pom.xml b/precommit/pom.xml index e02190948..7a1fc4a72 100644 --- a/precommit/pom.xml +++ b/precommit/pom.xml @@ -26,7 +26,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. precommit diff --git a/precommit/src/main/shell/core.d/01-common.sh b/precommit/src/main/shell/core.d/01-common.sh index caa5869c6..a81668fa7 100755 --- a/precommit/src/main/shell/core.d/01-common.sh +++ b/precommit/src/main/shell/core.d/01-common.sh @@ -613,7 +613,7 @@ function importplugins # shellcheck disable=SC1090 files+=("${PERSONALITY}") else - if [[ "${PERSONALITY}" != "${BASEDIR}/.yetus/personality.sh" ]]; then + if [[ -n "${PERSONALITY}" && "${PERSONALITY}" != "${BASEDIR}/.yetus/personality.sh" ]]; then yetus_error "ERROR: ${PERSONALITY} does not exist." exit 1 fi @@ -764,11 +764,9 @@ function set_yetus_version elif [[ -f "${BINDIR}/VERSION" ]]; then # dist version file VERSION=$(cat "${BINDIR}/VERSION") - elif [[ -f "${BINDIR}/../../../pom.xml" ]]; then + elif [[ -f "${BINDIR}/../../../../.mvn/maven.config" ]]; then # this way we have no dependency on Maven being installed - VERSION=$("${GREP}" "" "${BINDIR}/../../../pom.xml" 2>/dev/null \ - | head -1 \ - | "${SED}" -e 's|^ *||' -e 's|.*$||' 2>/dev/null) + VERSION=$("${GREP}" "revision" "${BINDIR}/../../../../.mvn/maven.config" 2>/dev/null | cut -f2 -d= 2>/dev/null) fi } diff --git a/precommit/src/main/shell/test-patch.sh b/precommit/src/main/shell/test-patch.sh index 952196c3d..6890a1fa9 100755 --- a/precommit/src/main/shell/test-patch.sh +++ b/precommit/src/main/shell/test-patch.sh @@ -2241,7 +2241,7 @@ function cleanup_and_exit big_console_header "Finished build." fi - if [[ "${DOCKERMODE}" != true ]]; then + if [[ "${DOCKERMODE}" != true && -f "${PATCH_DIR}/pidfile.txt" ]]; then rm "${PATCH_DIR}/pidfile.txt" fi diff --git a/release/initial-patches.sh b/release/initial-patches.sh index 31612fc0a..beeef9ae4 100755 --- a/release/initial-patches.sh +++ b/release/initial-patches.sh @@ -27,13 +27,6 @@ if [[ ! -d precommit ]]; then exit 1 fi -SYSTEM=$(uname -s) -if [[ "${SYSTEM}" == Darwin ]]; then - SEDI=("-i" '') -else - SEDI=("-i") -fi - #shellcheck source=SCRIPTDIR/../precommit/src/main/shell/core.d/00-yetuslib.sh . precommit/src/main/shell/core.d/00-yetuslib.sh @@ -82,6 +75,20 @@ option_parse() fi } +function check_basedir_repo +{ + if [[ ! -e "${BASEDIR}/.git" ]]; then + yetus_error "ERROR: ${BASEDIR} is not a git repo." + cleanup_and_exit 1 + fi + + GIT_DIR="${BASEDIR}/.git" + export GIT_DIR + + GIT_CEILING_DIRECTORIES="${BASEDIR}" + export GIT_CEILING_DIRECTORIES +} + docker_run() { docker run -i --rm \ -v "${PWD}:/src" \ @@ -106,7 +113,7 @@ determine_versions() { declare micro declare microinc - OLD_BRANCH_VERSION=$(docker_run mvn -Dmaven.repo.local="${HOME}/.m2" help:evaluate -Dexpression=project.version -q -DforceStdout) + OLD_BRANCH_VERSION=$(grep revision .mvn/maven.config | cut -f2 -d=) if [[ ${OLD_BRANCH_VERSION} =~ -SNAPSHOT ]]; then if [[ -n "${NEW_BRANCH_VERSION}" ]]; then @@ -128,17 +135,20 @@ determine_versions() { } update_version() { - declare oldversion=${1//\./\\.} - declare newversion=$2 + declare newversion=$1 - # *MOST* systems have sed -i these days - while read -r file; do - sed "${SEDI[@]}" "s,${oldversion},${newversion},g" "${file}" - done < <( find . -name 'pom.xml') + if ! grep -q .mvn/maven.config .yetus/excludes.txt; then + echo ".mvn/maven.config" >> .yetus/excludes.txt + fi + mkdir -p "${BASEDIR}/.mvn" + echo "-Drevision=${newversion}" > "${BASEDIR}/.mvn/maven.config" + git add "${BASEDIR}/.mvn/maven.config" } option_parse "$@" +check_basedir_repo + trap cleanup INT QUIT TRAP ABRT BUS SEGV TERM ERR set -x @@ -158,16 +168,15 @@ determine_versions git checkout -b "${JIRAISSUE}-release" -update_version "${OLD_BRANCH_VERSION}" "${NEW_BRANCH_VERSION}" +update_version "${NEW_BRANCH_VERSION}" git commit -a -m "${JIRAISSUE}. Stage version ${NEW_BRANCH_VERSION}" if [[ -n "${NEW_MAIN_VERSION}" ]]; then git checkout --force main git checkout -b "${JIRAISSUE}-${STARTING_BRANCH}" - update_version "${OLD_BRANCH_VERSION}" "${NEW_MAIN_VERSION}" + update_version "${NEW_MAIN_VERSION}" git commit -a -m "${JIRAISSUE}. Bump main version to ${NEW_MAIN_VERSION}" - fi git checkout "${JIRAISSUE}-release" diff --git a/releasedocmaker/pom.xml b/releasedocmaker/pom.xml index 8395deb55..141eb0884 100644 --- a/releasedocmaker/pom.xml +++ b/releasedocmaker/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. releasedocmaker diff --git a/shelldocs/pom.xml b/shelldocs/pom.xml index 19711e975..0b7ebfef9 100644 --- a/shelldocs/pom.xml +++ b/shelldocs/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. shelldocs diff --git a/yetus-assemblies/pom.xml b/yetus-assemblies/pom.xml index 7b20ee7f3..32518819f 100644 --- a/yetus-assemblies/pom.xml +++ b/yetus-assemblies/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. yetus-assemblies diff --git a/yetus-dist/pom.xml b/yetus-dist/pom.xml index 360660ac8..b3d432507 100644 --- a/yetus-dist/pom.xml +++ b/yetus-dist/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. yetus-dist diff --git a/yetus-maven-plugin/pom.xml b/yetus-maven-plugin/pom.xml index 27608602c..39b882004 100644 --- a/yetus-maven-plugin/pom.xml +++ b/yetus-maven-plugin/pom.xml @@ -25,7 +25,7 @@ org.apache.yetus yetus-project - 0.14.0-SNAPSHOT + ${revision} .. yetus-maven-plugin