Skip to content

Commit 22de23c

Browse files
committed
feat: configuration using Java's service loader
Additional rewrite of library. fixes issue #7
1 parent ed01f48 commit 22de23c

File tree

94 files changed

+2434
-772
lines changed

Some content is hidden

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

94 files changed

+2434
-772
lines changed

.gitignore

+119-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,120 @@
1-
target
2-
.idea
3-
*.jar
1+
### Maven template
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
pom.xml.next
7+
release.properties
8+
dependency-reduced-pom.xml
9+
buildNumber.properties
10+
.mvn/timing.properties
11+
### NetBeans template
12+
nbproject/private/
13+
build/
14+
nbbuild/
15+
dist/
16+
nbdist/
17+
nbactions.xml
18+
nb-configuration.xml
19+
.nb-gradle/
20+
### JetBrains template
21+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
22+
423
*.iml
24+
25+
## Directory-based project format:
26+
.idea/
27+
# if you remove the above rule, at least ignore the following:
28+
29+
# User-specific stuff:
30+
# .idea/workspace.xml
31+
# .idea/tasks.xml
32+
# .idea/dictionaries
33+
34+
# Sensitive or high-churn files:
35+
# .idea/dataSources.ids
36+
# .idea/dataSources.xml
37+
# .idea/sqlDataSources.xml
38+
# .idea/dynamic.xml
39+
# .idea/uiDesigner.xml
40+
41+
# Gradle:
42+
# .idea/gradle.xml
43+
# .idea/libraries
44+
45+
# Mongo Explorer plugin:
46+
# .idea/mongoSettings.xml
47+
48+
## File-based project format:
49+
*.ipr
50+
*.iws
51+
52+
## Plugin-specific files:
53+
54+
# IntelliJ
55+
/out/
56+
57+
# mpeltonen/sbt-idea plugin
58+
.idea_modules/
59+
60+
# JIRA plugin
61+
atlassian-ide-plugin.xml
62+
63+
# Crashlytics plugin (for Android Studio and IntelliJ)
64+
com_crashlytics_export_strings.xml
65+
crashlytics.properties
66+
crashlytics-build.properties
67+
### Java template
68+
*.class
69+
70+
# Mobile Tools for Java (J2ME)
71+
.mtj.tmp/
72+
73+
# Package Files #
74+
*.jar
75+
*.war
76+
*.ear
77+
78+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
79+
hs_err_pid*
80+
### Eclipse template
81+
*.pydevproject
82+
.metadata
83+
.gradle
84+
bin/
85+
tmp/
86+
*.tmp
87+
*.bak
88+
*.swp
89+
*~.nib
90+
local.properties
91+
.settings/
92+
.loadpath
93+
94+
# Eclipse Core
95+
.project
96+
97+
# External tool builders
98+
.externalToolBuilders/
99+
100+
# Locally stored "Eclipse launch configurations"
101+
*.launch
102+
103+
# CDT-specific
104+
.cproject
105+
106+
# JDT-specific (Eclipse Java Development Tools)
107+
.classpath
108+
109+
# Java annotation processor (APT)
110+
.factorypath
111+
112+
# PDT-specific
113+
.buildpath
114+
115+
# sbteclipse plugin
116+
.target
117+
118+
# TeXlipse plugin
119+
.texlipse
120+

.mvn/wrapper/MavenWrapperDownloader.java

100755100644
+29-22
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
/*
2-
Licensed to the Apache Software Foundation (ASF) under one
3-
or more contributor license agreements. See the NOTICE file
4-
distributed with this work for additional information
5-
regarding copyright ownership. The ASF licenses this file
6-
to you under the Apache License, Version 2.0 (the
7-
"License"); you may not use this file except in compliance
8-
with 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,
13-
software distributed under the License is distributed on an
14-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
KIND, either express or implied. See the License for the
16-
specific language governing permissions and limitations
17-
under the License.
18-
*/
19-
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
2016
import java.net.*;
2117
import java.io.*;
2218
import java.nio.channels.*;
2319
import java.util.Properties;
2420

2521
public class MavenWrapperDownloader {
2622

23+
private static final String WRAPPER_VERSION = "0.5.5";
2724
/**
2825
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
2926
*/
30-
private static final String DEFAULT_DOWNLOAD_URL =
31-
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar";
27+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
3229

3330
/**
3431
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
@@ -76,13 +73,13 @@ public static void main(String args[]) {
7673
}
7774
}
7875
}
79-
System.out.println("- Downloading from: : " + url);
76+
System.out.println("- Downloading from: " + url);
8077

8178
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
8279
if(!outputFile.getParentFile().exists()) {
8380
if(!outputFile.getParentFile().mkdirs()) {
8481
System.out.println(
85-
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
82+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
8683
}
8784
}
8885
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
@@ -98,6 +95,16 @@ public static void main(String args[]) {
9895
}
9996

10097
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99+
String username = System.getenv("MVNW_USERNAME");
100+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101+
Authenticator.setDefault(new Authenticator() {
102+
@Override
103+
protected PasswordAuthentication getPasswordAuthentication() {
104+
return new PasswordAuthentication(username, password);
105+
}
106+
});
107+
}
101108
URL website = new URL(urlString);
102109
ReadableByteChannel rbc;
103110
rbc = Channels.newChannel(website.openStream());

.mvn/wrapper/maven-wrapper.properties

100755100644
+18-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
1+
#
2+
# Copyright 2018-2019 Wave Software
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar

.travis.yml

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
language: java
2-
script: ./mvnw install --fail-at-end
2+
sudo: false
3+
dist: xenial
4+
script: ./mvnw -V clean verify --fail-at-end -U -Prelease-checks
35
matrix:
46
include:
5-
- jdk: openjdk7
6-
- jdk: openjdk8
7-
env: JACOCO=true COVERALLS=true
8-
- jdk: oraclejdk8
9-
- jdk: oraclejdk9
10-
- jdk: openjdk8
11-
env: GDMSESSION=sonar
12-
- jdk: openjdk8
13-
env: SONAR=publish
7+
- jdk: openjdk8
8+
env: JACOCO=true COVERALLS=true
9+
- jdk: openjdk11
10+
env: JACOCO=true
11+
- jdk: openjdk8
12+
env: JACOCO=true SONAR=publish
13+
script: ./mvnw -V clean verify sonar:sonar --fail-at-end -U
14+
notifications:
15+
email:
16+
on_failure: change

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2018 Wave Software
189+
Copyright 2018-2019 Wave Software
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

mvnw

+28-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ if $mingw ; then
114114
M2_HOME="`(cd "$M2_HOME"; pwd)`"
115115
[ -n "$JAVA_HOME" ] &&
116116
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117-
# TODO classpath?
118117
fi
119118

120119
if [ -z "$JAVA_HOME" ]; then
@@ -212,7 +211,11 @@ else
212211
if [ "$MVNW_VERBOSE" = true ]; then
213212
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
214213
fi
215-
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
214+
if [ -n "$MVNW_REPOURL" ]; then
215+
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
216+
else
217+
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
218+
fi
216219
while IFS="=" read key value; do
217220
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
218221
esac
@@ -221,22 +224,38 @@ else
221224
echo "Downloading from: $jarUrl"
222225
fi
223226
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
227+
if $cygwin; then
228+
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
229+
fi
224230

225231
if command -v wget > /dev/null; then
226232
if [ "$MVNW_VERBOSE" = true ]; then
227233
echo "Found wget ... using wget"
228234
fi
229-
wget "$jarUrl" -O "$wrapperJarPath"
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
230240
elif command -v curl > /dev/null; then
231241
if [ "$MVNW_VERBOSE" = true ]; then
232242
echo "Found curl ... using curl"
233243
fi
234-
curl -o "$wrapperJarPath" "$jarUrl"
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+
235250
else
236251
if [ "$MVNW_VERBOSE" = true ]; then
237252
echo "Falling back to using Java to download"
238253
fi
239254
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
240259
if [ -e "$javaClass" ]; then
241260
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
242261
if [ "$MVNW_VERBOSE" = true ]; then
@@ -277,6 +296,11 @@ if $cygwin; then
277296
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
278297
fi
279298

299+
# Provide a "standardized" way to retrieve the CLI args that will
300+
# work with both Windows and non-Windows executions.
301+
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
302+
export MAVEN_CMD_LINE_ARGS
303+
280304
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
281305

282306
exec "$JAVACMD" \

0 commit comments

Comments
 (0)