Skip to content

Commit

Permalink
[FLINK-33501][ci] Makes use of Maven wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
XComp committed Nov 28, 2023
1 parent 63996b5 commit 99ba4db
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# updating the Maven version requires updates to certain documentation and verification logic
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
distributionSha256Sum=ccf20a80e75a17ffc34d47c5c95c98c39d426ca17d670f09cd91e877072a9309
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trigger:

resources:
containers:
# Container with Maven 3.8.6, SSL to have the same environment everywhere.
# Container with SSL to have the same environment everywhere.
# see https://github.com/apache/flink-connector-shared-utils/tree/ci_utils
- container: flink-build-container
image: chesnay/flink-ci:java_8_11_17_21_maven_386
Expand Down
2 changes: 1 addition & 1 deletion tools/azure-pipelines/build-apache-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trigger:

resources:
containers:
# Container with Maven 3.8.6, SSL to have the same environment everywhere.
# Container with SSL to have the same environment everywhere.
# see https://github.com/apache/flink-connector-shared-utils/tree/ci_utils
- container: flink-build-container
image: chesnay/flink-ci:java_8_11_17_21_maven_386
Expand Down
2 changes: 0 additions & 2 deletions tools/azure-pipelines/build-nightly-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
inputs:
script: |
source ./tools/ci/maven-utils.sh
setup_maven
run_mvn -version
export MVN="run_mvn"
Expand Down Expand Up @@ -93,7 +92,6 @@ jobs:
inputs:
script: |
source ./tools/ci/maven-utils.sh
setup_maven
run_mvn -version
cd tools
Expand Down
1 change: 0 additions & 1 deletion tools/azure-pipelines/e2e-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ jobs:
- script: |
echo "Setting up Maven"
source ./tools/ci/maven-utils.sh
setup_maven
# the APT mirrors access is based on a proposal from https://github.com/actions/runner-images/issues/7048#issuecomment-1419426054
echo "Configure APT mirrors"
Expand Down
36 changes: 7 additions & 29 deletions tools/ci/maven-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,13 @@

# Utility for invoking Maven in CI
function run_mvn {
MVN_CMD="mvn"
if [[ "$M2_HOME" != "" ]]; then
MVN_CMD="${M2_HOME}/bin/mvn"
fi

if [[ "$MVN_RUN_VERBOSE" != "false" ]]; then
echo "Invoking mvn with '$MVN_GLOBAL_OPTIONS ${@}'"
fi
$MVN_CMD $MVN_GLOBAL_OPTIONS "${@}"
$MAVEN_WRAPPER $MVN_GLOBAL_OPTIONS "${@}"
}
export -f run_mvn

function setup_maven {
set -e # fail if there was an error setting up maven
if [ ! -d "${MAVEN_VERSIONED_DIR}" ]; then
wget -nv https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${MAVEN_VERSION}/apache-maven-${MAVEN_VERSION}-bin.zip
unzip -d "${MAVEN_CACHE_DIR}" -qq "apache-maven-${MAVEN_VERSION}-bin.zip"
rm "apache-maven-${MAVEN_VERSION}-bin.zip"
fi

export M2_HOME="${MAVEN_VERSIONED_DIR}"
echo "##vso[task.setvariable variable=M2_HOME]$M2_HOME"

# just in case: clean up the .m2 home and remove invalid jar files
if [ -d "${HOME}/.m2/repository/" ]; then
find ${HOME}/.m2/repository/ -name "*.jar" -exec sh -c 'if ! zip -T {} >/dev/null ; then echo "deleting invalid file: {}"; rm -f {} ; fi' \;
fi

echo "Installed Maven ${MAVEN_VERSION} to ${M2_HOME}"
set +e
}

function set_mirror_config {
if [[ "$MAVEN_MIRROR_CONFIG_FILE" != "" ]]; then
echo "[WARN] Maven mirror already configured to $MAVEN_MIRROR_CONFIG_FILE"
Expand Down Expand Up @@ -81,10 +56,13 @@ function collect_coredumps {

CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

MAVEN_VERSION="3.8.6"
MAVEN_CACHE_DIR=${HOME}/maven_cache
MAVEN_VERSIONED_DIR=${MAVEN_CACHE_DIR}/apache-maven-${MAVEN_VERSION}
if [[ ! "${CI_DIR}" =~ .*/tools/ci[/]{0,1}$ ]]; then
echo "Error: ${BASH_SOURCE[0]} is expected to be located in the './tools/ci/' subfolder to make the Maven wrapper path resolution work."
exit 1
fi
MAVEN_WRAPPER="${CI_DIR}/../../mvnw"

export MAVEN_WRAPPER

MAVEN_MIRROR_CONFIG_FILE=""
NPM_PROXY_PROFILE_ACTIVATION=""
Expand Down

0 comments on commit 99ba4db

Please sign in to comment.