Skip to content

Commit 2220ed3

Browse files
Added checkstyle
1 parent f9144b1 commit 2220ed3

File tree

196 files changed

+4034
-3057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+4034
-3057
lines changed

.editorconfig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
14
root = true
25

36
[*]
4-
end_of_line = lf
5-
insert_final_newline = true
67
indent_style = tab
78
indent_size = 4
9+
end_of_line = lf
10+
insert_final_newline = true
11+
12+
[*.yml]
13+
indent_style = space
14+
indent_size = 2
15+
16+
[*.yaml]
17+
indent_style = space
18+
indent_size = 2
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
2+
/*
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
*/
20+
21+
import java.util.Properties;
22+
23+
public class MavenWrapperDownloader {
24+
25+
/**
26+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is
27+
* provided.
28+
*/
29+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
30+
31+
/**
32+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl
33+
* property to use instead of the default one.
34+
*/
35+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";
36+
37+
/**
38+
* Path where the maven-wrapper.jar will be saved to.
39+
*/
40+
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
41+
42+
/**
43+
* Name of the property which should be used to override the default download url for
44+
* the wrapper.
45+
*/
46+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47+
48+
public static void main(String args[]) {
49+
System.out.println("- Downloader started");
50+
File baseDirectory = new File(args[0]);
51+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52+
53+
// If the maven-wrapper.properties exists, read it and check if it contains a
54+
// custom
55+
// wrapperUrl parameter.
56+
File mavenWrapperPropertyFile = new File(baseDirectory,
57+
MAVEN_WRAPPER_PROPERTIES_PATH);
58+
String url = DEFAULT_DOWNLOAD_URL;
59+
if (mavenWrapperPropertyFile.exists()) {
60+
FileInputStream mavenWrapperPropertyFileInputStream = null;
61+
try {
62+
mavenWrapperPropertyFileInputStream = new FileInputStream(
63+
mavenWrapperPropertyFile);
64+
Properties mavenWrapperProperties = new Properties();
65+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
66+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
67+
}
68+
catch (IOException e) {
69+
System.out.println(
70+
"- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
71+
}
72+
finally {
73+
try {
74+
if (mavenWrapperPropertyFileInputStream != null) {
75+
mavenWrapperPropertyFileInputStream.close();
76+
}
77+
}
78+
catch (IOException e) {
79+
// Ignore ...
80+
}
81+
}
82+
}
83+
System.out.println("- Downloading from: : " + url);
84+
85+
File outputFile = new File(baseDirectory.getAbsolutePath(),
86+
MAVEN_WRAPPER_JAR_PATH);
87+
if (!outputFile.getParentFile().exists()) {
88+
if (!outputFile.getParentFile().mkdirs()) {
89+
System.out.println("- ERROR creating output direcrory '"
90+
+ outputFile.getParentFile().getAbsolutePath() + "'");
91+
}
92+
}
93+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
94+
try {
95+
downloadFileFromURL(url, outputFile);
96+
System.out.println("Done");
97+
System.exit(0);
98+
}
99+
catch (Throwable e) {
100+
System.out.println("- Error downloading");
101+
e.printStackTrace();
102+
System.exit(1);
103+
}
104+
}
105+
106+
private static void downloadFileFromURL(String urlString, File destination)
107+
throws Exception {
108+
URL website = new URL(urlString);
109+
ReadableByteChannel rbc;
110+
rbc = Channels.newChannel(website.openStream());
111+
FileOutputStream fos = new FileOutputStream(destination);
112+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113+
fos.close();
114+
rbc.close();
115+
}
116+
117+
}

.mvn/wrapper/maven-wrapper.jar

100644100755
-1.14 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip

.springformat

Whitespace-only changes.

docs/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>org.springframework.cloud</groupId>

mvnw

Lines changed: 104 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -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,7 +108,7 @@ 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)`"
@@ -184,27 +162,28 @@ fi
184162

185163
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
186164

187-
# For Cygwin, switch paths to Windows format before running java
188-
if $cygwin; then
189-
[ -n "$M2_HOME" ] &&
190-
M2_HOME=`cygpath --path --windows "$M2_HOME"`
191-
[ -n "$JAVA_HOME" ] &&
192-
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
193-
[ -n "$CLASSPATH" ] &&
194-
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
195-
fi
196-
197165
# traverses directory structure from process work directory to filesystem root
198166
# first directory with .mvn subdirectory is considered project base directory
199167
find_maven_basedir() {
200-
local basedir=$(pwd)
201-
local wdir=$(pwd)
168+
169+
if [ -z "$1" ]
170+
then
171+
echo "Path not specified to find_maven_basedir"
172+
return 1
173+
fi
174+
175+
basedir="$1"
176+
wdir="$1"
202177
while [ "$wdir" != '/' ] ; do
203178
if [ -d "$wdir"/.mvn ] ; then
204179
basedir=$wdir
205180
break
206181
fi
207-
wdir=$(cd "$wdir/.."; pwd)
182+
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
183+
if [ -d "${wdir}" ]; then
184+
wdir=`cd "$wdir/.."; pwd`
185+
fi
186+
# end of workaround
208187
done
209188
echo "${basedir}"
210189
}
@@ -216,38 +195,92 @@ concat_lines() {
216195
fi
217196
}
218197

219-
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
220-
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
221-
222-
# Provide a "standardized" way to retrieve the CLI args that will
223-
# work with both Windows and non-Windows executions.
224-
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
225-
export MAVEN_CMD_LINE_ARGS
226-
227-
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
228-
229-
echo "Running version check"
230-
VERSION=$( sed '\!<parent!,\!</parent!d' `dirname $0`/pom.xml | grep '<version' | head -1 | sed -e 's/.*<version>//' -e 's!</version>.*$!!' )
231-
echo "The found version is [${VERSION}]"
198+
BASE_DIR=`find_maven_basedir "$(pwd)"`
199+
if [ -z "$BASE_DIR" ]; then
200+
exit 1;
201+
fi
232202

233-
if echo $VERSION | egrep -q 'M|RC'; then
234-
echo Activating \"milestone\" profile for version=\"$VERSION\"
235-
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone"
203+
##########################################################################################
204+
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
205+
# This allows using the maven wrapper in projects that prohibit checking in binary data.
206+
##########################################################################################
207+
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
208+
if [ "$MVNW_VERBOSE" = true ]; then
209+
echo "Found .mvn/wrapper/maven-wrapper.jar"
210+
fi
236211
else
237-
echo Deactivating \"milestone\" profile for version=\"$VERSION\"
238-
echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//')
212+
if [ "$MVNW_VERBOSE" = true ]; then
213+
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
214+
fi
215+
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
216+
while IFS="=" read key value; do
217+
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
218+
esac
219+
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
220+
if [ "$MVNW_VERBOSE" = true ]; then
221+
echo "Downloading from: $jarUrl"
222+
fi
223+
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
224+
225+
if command -v wget > /dev/null; then
226+
if [ "$MVNW_VERBOSE" = true ]; then
227+
echo "Found wget ... using wget"
228+
fi
229+
wget "$jarUrl" -O "$wrapperJarPath"
230+
elif command -v curl > /dev/null; then
231+
if [ "$MVNW_VERBOSE" = true ]; then
232+
echo "Found curl ... using curl"
233+
fi
234+
curl -o "$wrapperJarPath" "$jarUrl"
235+
else
236+
if [ "$MVNW_VERBOSE" = true ]; then
237+
echo "Falling back to using Java to download"
238+
fi
239+
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
240+
if [ -e "$javaClass" ]; then
241+
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
242+
if [ "$MVNW_VERBOSE" = true ]; then
243+
echo " - Compiling MavenWrapperDownloader.java ..."
244+
fi
245+
# Compiling the Java class
246+
("$JAVA_HOME/bin/javac" "$javaClass")
247+
fi
248+
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
249+
# Running the downloader
250+
if [ "$MVNW_VERBOSE" = true ]; then
251+
echo " - Running MavenWrapperDownloader.java ..."
252+
fi
253+
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
254+
fi
255+
fi
256+
fi
239257
fi
258+
##########################################################################################
259+
# End of extension
260+
##########################################################################################
240261

241-
if echo $VERSION | egrep -q 'RELEASE'; then
242-
echo Activating \"central\" profile for version=\"$VERSION\"
243-
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral"
244-
else
245-
echo Deactivating \"central\" profile for version=\"$VERSION\"
246-
echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//')
262+
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
263+
if [ "$MVNW_VERBOSE" = true ]; then
264+
echo $MAVEN_PROJECTBASEDIR
247265
fi
266+
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
267+
268+
# For Cygwin, switch paths to Windows format before running java
269+
if $cygwin; then
270+
[ -n "$M2_HOME" ] &&
271+
M2_HOME=`cygpath --path --windows "$M2_HOME"`
272+
[ -n "$JAVA_HOME" ] &&
273+
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
274+
[ -n "$CLASSPATH" ] &&
275+
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
276+
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
277+
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
278+
fi
279+
280+
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
248281

249282
exec "$JAVACMD" \
250283
$MAVEN_OPTS \
251284
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
252285
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
253-
${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@"
286+
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

0 commit comments

Comments
 (0)