Skip to content

Commit 762d163

Browse files
authoredJul 2, 2020
LOG4J2-2764 Implement CI pipeline via GitHub Actions. (apache#379)
1 parent 0c3b913 commit 762d163

File tree

7 files changed

+255
-51
lines changed

7 files changed

+255
-51
lines changed
 
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache license, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the license for the specific language governing permissions and
16+
~ limitations under the license.
17+
-->
18+
<toolchains>
19+
<toolchain>
20+
<type>jdk</type>
21+
<provides>
22+
<version>1.8</version>
23+
</provides>
24+
<configuration>
25+
<jdkHome>${env.JAVA_HOME_8_X64}</jdkHome>
26+
</configuration>
27+
</toolchain>
28+
<toolchain>
29+
<type>jdk</type>
30+
<provides>
31+
<version>11</version>
32+
</provides>
33+
<configuration>
34+
<jdkHome>${env.JAVA_HOME_11_X64}</jdkHome>
35+
</configuration>
36+
</toolchain>
37+
</toolchains>

‎.github/workflows/maven.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Maven
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ${{ matrix.os }}
9+
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, windows-latest]
13+
14+
steps:
15+
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
19+
- name: Setup Maven caching
20+
uses: actions/cache@v2
21+
with:
22+
path: ~/.m2/repository
23+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
24+
restore-keys: |
25+
${{ runner.os }}-maven-
26+
27+
- name: Setup JDK 11
28+
uses: actions/setup-java@v1
29+
with:
30+
java-version: 11
31+
java-package: jdk
32+
architecture: x64
33+
34+
- name: Setup JDK 8
35+
uses: actions/setup-java@v1
36+
with:
37+
java-version: 8
38+
java-package: jdk
39+
architecture: x64
40+
41+
- name: Inspect environment (Linux)
42+
if: runner.os == 'Linux'
43+
run: env | grep '^JAVA'
44+
45+
- name: Build with Maven (Linux)
46+
if: runner.os == 'Linux'
47+
run: ./mvnw -V -B -e -DtrimStackTrace=false verify --global-toolchains .github/workflows/maven-toolchains.xml
48+
49+
- name: Inspect environment (Windows)
50+
if: runner.os == 'Windows'
51+
run: set java
52+
53+
- name: Build with Maven (Windows)
54+
if: runner.os == 'Windows'
55+
run: ./mvnw -V -B -e -DtrimStackTrace=false verify --global-toolchains ".github\workflows\maven-toolchains.xml"

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ target/
2727
velocity.log
2828
felix-cache/
2929
bin/
30+
.mvn/wrapper/MavenWrapperDownloader.java

‎.mvn/wrapper/maven-wrapper.jar

1.16 KB
Binary file not shown.

‎.mvn/wrapper/maven-wrapper.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
16+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
17+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

‎mvnw

+115-41
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# ----------------------------------------------------------------------------
33
# Licensed to the Apache Software Foundation (ASF) under one
44
# or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
1919
# ----------------------------------------------------------------------------
2020

2121
# ----------------------------------------------------------------------------
22-
# Maven2 Start Up Batch script
22+
# Maven Start Up Batch script
2323
#
2424
# Required ENV vars:
2525
# ------------------
@@ -54,38 +54,16 @@ case "`uname`" in
5454
CYGWIN*) cygwin=true ;;
5555
MINGW*) mingw=true;;
5656
Darwin*) darwin=true
57-
#
58-
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
59-
# for the new JDKs provided by Oracle.
60-
#
61-
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
62-
#
63-
# Apple JDKs
64-
#
65-
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
66-
fi
67-
68-
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
69-
#
70-
# Apple JDKs
71-
#
72-
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
73-
fi
74-
75-
if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
76-
#
77-
# Oracle JDKs
78-
#
79-
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
80-
fi
81-
82-
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
83-
#
84-
# Apple JDKs
85-
#
86-
export JAVA_HOME=`/usr/libexec/java_home`
87-
fi
88-
;;
57+
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58+
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59+
if [ -z "$JAVA_HOME" ]; then
60+
if [ -x "/usr/libexec/java_home" ]; then
61+
export JAVA_HOME="`/usr/libexec/java_home`"
62+
else
63+
export JAVA_HOME="/Library/Java/Home"
64+
fi
65+
fi
66+
;;
8967
esac
9068

9169
if [ -z "$JAVA_HOME" ] ; then
@@ -130,13 +108,12 @@ if $cygwin ; then
130108
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
131109
fi
132110

133-
# For Migwn, ensure paths are in UNIX format before anything is touched
111+
# For Mingw, ensure paths are in UNIX format before anything is touched
134112
if $mingw ; then
135113
[ -n "$M2_HOME" ] &&
136114
M2_HOME="`(cd "$M2_HOME"; pwd)`"
137115
[ -n "$JAVA_HOME" ] &&
138116
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
139-
# TODO classpath?
140117
fi
141118

142119
if [ -z "$JAVA_HOME" ]; then
@@ -187,14 +164,25 @@ CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
187164
# traverses directory structure from process work directory to filesystem root
188165
# first directory with .mvn subdirectory is considered project base directory
189166
find_maven_basedir() {
190-
local basedir=$(pwd)
191-
local wdir=$(pwd)
167+
168+
if [ -z "$1" ]
169+
then
170+
echo "Path not specified to find_maven_basedir"
171+
return 1
172+
fi
173+
174+
basedir="$1"
175+
wdir="$1"
192176
while [ "$wdir" != '/' ] ; do
193177
if [ -d "$wdir"/.mvn ] ; then
194178
basedir=$wdir
195179
break
196180
fi
197-
wdir=$(cd "$wdir/.."; pwd)
181+
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
182+
if [ -d "${wdir}" ]; then
183+
wdir=`cd "$wdir/.."; pwd`
184+
fi
185+
# end of workaround
198186
done
199187
echo "${basedir}"
200188
}
@@ -206,7 +194,94 @@ concat_lines() {
206194
fi
207195
}
208196

209-
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
197+
BASE_DIR=`find_maven_basedir "$(pwd)"`
198+
if [ -z "$BASE_DIR" ]; then
199+
exit 1;
200+
fi
201+
202+
##########################################################################################
203+
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
204+
# This allows using the maven wrapper in projects that prohibit checking in binary data.
205+
##########################################################################################
206+
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
207+
if [ "$MVNW_VERBOSE" = true ]; then
208+
echo "Found .mvn/wrapper/maven-wrapper.jar"
209+
fi
210+
else
211+
if [ "$MVNW_VERBOSE" = true ]; then
212+
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
213+
fi
214+
if [ -n "$MVNW_REPOURL" ]; then
215+
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
216+
else
217+
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
218+
fi
219+
while IFS="=" read key value; do
220+
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
221+
esac
222+
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
223+
if [ "$MVNW_VERBOSE" = true ]; then
224+
echo "Downloading from: $jarUrl"
225+
fi
226+
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
227+
if $cygwin; then
228+
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
229+
fi
230+
231+
if command -v wget > /dev/null; then
232+
if [ "$MVNW_VERBOSE" = true ]; then
233+
echo "Found wget ... using wget"
234+
fi
235+
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
236+
wget "$jarUrl" -O "$wrapperJarPath"
237+
else
238+
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
239+
fi
240+
elif command -v curl > /dev/null; then
241+
if [ "$MVNW_VERBOSE" = true ]; then
242+
echo "Found curl ... using curl"
243+
fi
244+
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
245+
curl -o "$wrapperJarPath" "$jarUrl" -f
246+
else
247+
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
248+
fi
249+
250+
else
251+
if [ "$MVNW_VERBOSE" = true ]; then
252+
echo "Falling back to using Java to download"
253+
fi
254+
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
255+
# For Cygwin, switch paths to Windows format before running javac
256+
if $cygwin; then
257+
javaClass=`cygpath --path --windows "$javaClass"`
258+
fi
259+
if [ -e "$javaClass" ]; then
260+
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
261+
if [ "$MVNW_VERBOSE" = true ]; then
262+
echo " - Compiling MavenWrapperDownloader.java ..."
263+
fi
264+
# Compiling the Java class
265+
("$JAVA_HOME/bin/javac" "$javaClass")
266+
fi
267+
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
268+
# Running the downloader
269+
if [ "$MVNW_VERBOSE" = true ]; then
270+
echo " - Running MavenWrapperDownloader.java ..."
271+
fi
272+
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
273+
fi
274+
fi
275+
fi
276+
fi
277+
##########################################################################################
278+
# End of extension
279+
##########################################################################################
280+
281+
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
282+
if [ "$MVNW_VERBOSE" = true ]; then
283+
echo $MAVEN_PROJECTBASEDIR
284+
fi
210285
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
211286

212287
# For Cygwin, switch paths to Windows format before running java
@@ -228,7 +303,6 @@ export MAVEN_CMD_LINE_ARGS
228303

229304
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
230305

231-
# avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in $@
232306
exec "$JAVACMD" \
233307
$MAVEN_OPTS \
234308
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \

‎mvnw.cmd

+45-9
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
@REM ----------------------------------------------------------------------------
1919

2020
@REM ----------------------------------------------------------------------------
21-
@REM Maven2 Start Up Batch script
21+
@REM Maven Start Up Batch script
2222
@REM
2323
@REM Required ENV vars:
2424
@REM JAVA_HOME - location of a JDK home dir
2525
@REM
2626
@REM Optional ENV vars
2727
@REM M2_HOME - location of maven2's installed home dir
2828
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29-
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
29+
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
3030
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
3131
@REM e.g. to debug Maven itself, use
3232
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@@ -35,7 +35,9 @@
3535

3636
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
3737
@echo off
38-
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
38+
@REM set title of command window
39+
title %0
40+
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
3941
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
4042

4143
@REM set %HOME% to equivalent of $HOME
@@ -80,8 +82,6 @@ goto error
8082

8183
:init
8284

83-
set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %*
84-
8585
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
8686
@REM Fallback to current working directory if not found.
8787

@@ -117,12 +117,48 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s
117117
:endReadAdditionalConfig
118118

119119
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120-
121-
set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar""
120+
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
122121
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
123122

124-
@REM avoid using MAVEN_CMD_LINE_ARGS below since that would lose parameter escaping in %*
125-
"%MAVEN_JAVA_EXE%" %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath "%WRAPPER_JAR%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123+
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124+
125+
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126+
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127+
)
128+
129+
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130+
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131+
if exist %WRAPPER_JAR% (
132+
if "%MVNW_VERBOSE%" == "true" (
133+
echo Found %WRAPPER_JAR%
134+
)
135+
) else (
136+
if not "%MVNW_REPOURL%" == "" (
137+
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138+
)
139+
if "%MVNW_VERBOSE%" == "true" (
140+
echo Couldn't find %WRAPPER_JAR%, downloading it ...
141+
echo Downloading from: %DOWNLOAD_URL%
142+
)
143+
144+
powershell -Command "&{"^
145+
"$webclient = new-object System.Net.WebClient;"^
146+
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147+
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148+
"}"^
149+
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150+
"}"
151+
if "%MVNW_VERBOSE%" == "true" (
152+
echo Finished downloading %WRAPPER_JAR%
153+
)
154+
)
155+
@REM End of extension
156+
157+
@REM Provide a "standardized" way to retrieve the CLI args that will
158+
@REM work with both Windows and non-Windows executions.
159+
set MAVEN_CMD_LINE_ARGS=%*
160+
161+
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
126162
if ERRORLEVEL 1 goto error
127163
goto end
128164

0 commit comments

Comments
 (0)
Please sign in to comment.