Last active
August 29, 2015 14:03
-
-
Save pcompieta/0b202e9ce57e490c84c4 to your computer and use it in GitHub Desktop.
Validate a Maven Core Pull Request - Win7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@setlocal enableextensions enabledelayedexpansion | |
@echo off | |
rem PR validator: This script will checkout Maven, apply a PR, build the Maven distribution and | |
rem run the Maven integration tests against the just-built distribution. If you | |
rem successfully get to the end of this script then your PR is ready to be reviewed. | |
rem | |
rem Assumptions: | |
rem 1) You have a functioning version of Maven installed (script tested with 3.2.1) | |
rem 2) You have a decent connection. This script checks out everything from scratch and downloads | |
rem everything into a clean local repository. Not terribly efficient but makes sure there is no | |
rem interference from previous Maven operations. | |
rem | |
rem Adapted for Win7 from https://gist.github.com/jvanzyl/16da25976f8ad27293fa | |
rem | |
rem To use use this save it to a file called maven-pr-validator.bat and run it using the PR# like the following: | |
rem | |
rem maven-pr-validator 16 | |
rem | |
rem To debug and avoid exiting in case of errors: modify procedure 'shallExitProcedure' at the end of file to return 1 instead of 0 | |
rem Following pieces are necessary to this script: have them already in place as Win env vars | |
rem or use one or more of the following commented lines | |
rem set JAVA_HOME=c:\jdk1.7.0_51 | |
rem set M2_HOME=C:\dev\apache-maven-3.2.1 | |
rem set GIT_HOME=c:\Program Files (x86)\Git | |
rem set PATH=%M2_HOME%\bin;%GIT_HOME%\bin;%PATH% | |
rem set MAVEN_OPTS=-Xms1024m -Xmx1024m | |
IF "%~1"=="" echo You need to provide a PR. && call :shallExitProcedure && goto :EOF | |
set pr=%1 | |
set mvnRepoUrl=https://github.com/apache/maven | |
set remoteRepo=%mvnRepoUrl%.git | |
set remoteRepoIT=%mvnRepoUrl%-integration-testing.git | |
set patchUrl=%mvnRepoUrl%/pull | |
set workDirectory=%CD%\z-maven-with-pr-%pr% | |
set localRepository=%workDirectory%\local-repository | |
set mvn=mvn -Dmaven.repo.local=%localRepository% | |
mkdir %workDirectory% | |
cd %workDirectory% | |
echo Downloading patch... | |
rem Using Maven-Wagon to download file via http | |
call %mvn% wagon:download-single -Dwagon.fromFile=%pr%.patch -Dwagon.url=%patchUrl% -Dwagon.toDir=. || echo Retrieving patch file from Github failed. && call :shallExitProcedure && goto :EOF | |
echo Cloning maven from: %remoteRepo% | |
git clone %remoteRepo% || echo Cloning Maven failed. && call :shallExitProcedure && goto :EOF | |
echo Cloning maven-integration-testing from %remoteRepoIT% | |
git clone %remoteRepoIT% || echo Cloning Maven ITs failed. && call :shallExitProcedure && goto :EOF | |
echo Building snapshot Maven... | |
cd maven | |
rem We execute this twice to make sure no download spew ends up in mavenVersion.txt. | |
rem The -q mode of Maven keeps everything from being emitted, including useful output... | |
call %mvn% -q help:evaluate -Dexpression=project.version | |
call %mvn% help:evaluate -Dexpression=project.version > temp.txt | |
findstr /B /V "[" temp.txt > %workDirectory%\mavenVersion.txt | |
set /p mavenVersion=<%workDirectory%\mavenVersion.txt | |
del temp.txt | |
echo %mavenVersion% | |
echo Applying and testing patch... | |
git am --signoff < ..\%pr%.patch || echo Applying %pr%.patch failed. && call :shallExitProcedure && goto :EOF | |
call %mvn% clean package || echo Maven clean package failed. && call :shallExitProcedure && goto :EOF | |
cd apache-maven\target | |
%JAVA_HOME%\bin\jar xf apache-maven-%mavenVersion%-bin.zip | |
echo Running ITs against snapshot Maven: %mavenVersion% | |
set distro=%workDirectory%\maven\apache-maven\target\apache-maven-%mavenVersion% | |
set M2_HOME=%distro% | |
cd %workDirectory%\maven-integration-testing | |
call %mvn% clean install -Prun-its,embedded -DmavenHome=%distro% | |
@endlocal | |
exit /b 0 | |
:shallExitProcedure | |
rem 1 forces to continues even in case of errors, 0 exits normally | |
exit /b 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment