Skip to content

Commit 6cc14be

Browse files
committed
Merge branch 'develop'
2 parents 4c9d92f + c8e2f1f commit 6cc14be

File tree

76 files changed

+785
-224
lines changed

Some content is hidden

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

76 files changed

+785
-224
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Compiled class file
22
*.class
33

4+
# IDE
5+
.project
6+
.classpath
7+
*.iml
8+
.idea
9+
410
# Log file
511
*.log
612

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
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+
20+
import java.io.*;
21+
import java.net.*;
22+
import java.nio.channels.*;
23+
import java.util.Properties;
24+
25+
public class MavenWrapperDownloader {
26+
27+
/**
28+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
29+
*/
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";
32+
33+
/**
34+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
35+
* use instead of the default one.
36+
*/
37+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
38+
".mvn/wrapper/maven-wrapper.properties";
39+
40+
/**
41+
* Path where the maven-wrapper.jar will be saved to.
42+
*/
43+
private static final String MAVEN_WRAPPER_JAR_PATH =
44+
".mvn/wrapper/maven-wrapper.jar";
45+
46+
/**
47+
* Name of the property which should be used to override the default download url for the wrapper.
48+
*/
49+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
50+
51+
public static void main(String args[]) {
52+
System.out.println("- Downloader started");
53+
File baseDirectory = new File(args[0]);
54+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
55+
56+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
57+
// wrapperUrl parameter.
58+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
59+
String url = DEFAULT_DOWNLOAD_URL;
60+
if(mavenWrapperPropertyFile.exists()) {
61+
FileInputStream mavenWrapperPropertyFileInputStream = null;
62+
try {
63+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
64+
Properties mavenWrapperProperties = new Properties();
65+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
66+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
67+
} catch (IOException e) {
68+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
69+
} finally {
70+
try {
71+
if(mavenWrapperPropertyFileInputStream != null) {
72+
mavenWrapperPropertyFileInputStream.close();
73+
}
74+
} catch (IOException e) {
75+
// Ignore ...
76+
}
77+
}
78+
}
79+
System.out.println("- Downloading from: : " + url);
80+
81+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
82+
if(!outputFile.getParentFile().exists()) {
83+
if(!outputFile.getParentFile().mkdirs()) {
84+
System.out.println(
85+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
86+
}
87+
}
88+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
89+
try {
90+
downloadFileFromURL(url, outputFile);
91+
System.out.println("Done");
92+
System.exit(0);
93+
} catch (Throwable e) {
94+
System.out.println("- Error downloading");
95+
e.printStackTrace();
96+
System.exit(1);
97+
}
98+
}
99+
100+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
101+
URL website = new URL(urlString);
102+
ReadableByteChannel rbc;
103+
rbc = Channels.newChannel(website.openStream());
104+
FileOutputStream fos = new FileOutputStream(destination);
105+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
106+
fos.close();
107+
rbc.close();
108+
}
109+
110+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ jdk:
77
- oraclejdk8
88
- openjdk7
99

10-
install: mvn install -DskipTests=true -q
11-
script: mvn verify snyk:monitor -B -q
10+
install: ./mvnw install -DskipTests=true -q
11+
script: ./mvnw verify snyk:monitor -B -q

Jenkinsfile

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,45 @@ timeout(60) {
1414
def buildUrl = env.BUILD_URL
1515

1616
try {
17-
withEnv(["JAVA_HOME=${tool 'JDK8'}", "PATH+MAVEN=${tool 'Maven3'}/bin:${env.JAVA_HOME}/bin"]) {
1817

19-
// PRINT ENVIRONMENT TO JOB
20-
echo "workspace directory is $workspace"
21-
echo "build URL is $buildUrl"
22-
echo "build Number is $buildNumber"
23-
echo "branch name is $branchName"
24-
echo "PATH is $env.PATH"
18+
// PRINT ENVIRONMENT TO JOB
19+
echo "workspace directory is $workspace"
20+
echo "build URL is $buildUrl"
21+
echo "build Number is $buildNumber"
22+
echo "branch name is $branchName"
23+
echo "PATH is $env.PATH"
2524

26-
stage('Checkout') {
27-
checkout scm
28-
}
29-
stage('Build') {
30-
sh "mvn package -DskipUnitTests=true"
31-
}
25+
stage('Checkout') {
26+
checkout scm
27+
}
28+
stage('Build') {
29+
sh "./mvnw package -DskipUnitTests=true"
30+
}
3231

33-
stage('Unit-Tests') {
34-
sh "mvn test -Dmaven.test.failure.ignore"
35-
}
32+
stage('Unit-Tests') {
33+
sh "./mvnw test -Dmaven.test.failure.ignore"
34+
}
3635

37-
stage('Integration-Tests') {
38-
// TODO add for OWASP ZAP version 2.7.0
39-
}
36+
stage('Integration-Tests') {
37+
// TODO add for OWASP ZAP version 2.7.0
38+
}
4039

41-
stage('Deploy') {
42-
if (git.isProductionBranch()) {
43-
sh "mvn -Prelease package source:jar gpg:sign install:install deploy:deploy"
44-
} else {
45-
sh "mvn deploy"
46-
}
40+
stage('Deploy') {
41+
if (git.isProductionBranch()) {
42+
sh "./mvnw -Prelease package source:jar gpg:sign install:install deploy:deploy"
43+
} else {
44+
sh "./mvnw deploy"
45+
}
4746

48-
stage('Sonar') {
49-
sh "mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=hypery2k-github -Dsonar.login=${env['sonarcloud.io.token']}"
47+
stage('Sonar') {
48+
withSonarQubeEnv('sonarcloud.io') {
49+
sh "./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=hypery2k-github"
5050
}
5151
}
52-
53-
archiveArtifacts artifacts: '*/target/*.jar'
54-
junit healthScaleFactor: 1.0, testResults: '*/target/surefire-reports/TEST*.xml'
5552
}
53+
54+
archiveArtifacts artifacts: '*/target/*.jar'
55+
junit healthScaleFactor: 1.0, testResults: '*/target/surefire-reports/TEST*.xml'
5656
} catch (e) {
5757
mail subject: "${env.JOB_NAME} (${env.BUILD_NUMBER}): Error on build", to: '[email protected]', body: "Please go to ${env.BUILD_URL}."
5858
throw e

Jenkinsfile_release

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
properties properties: [
22
[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '10']],
33
parameters([
4-
string(defaultValue: '', description: '', name: 'releaseVersion')]
5-
),
4+
string(defaultValue: '', description: 'Version to release', name: 'releaseVersion'),
5+
string(defaultValue: '', description: 'Next development version', name: 'developmentVersion')
6+
]),
67
disableConcurrentBuilds()
78
]
89

@@ -14,24 +15,21 @@ timeout(20) {
1415
def buildUrl = env.BUILD_URL
1516

1617
try {
17-
withEnv(["JAVA_HOME=${tool 'JDK8'}", "PATH+MAVEN=${tool 'Maven3'}/bin:${env.JAVA_HOME}/bin"]) {
1818

19-
// PRINT ENVIRONMENT TO JOB
20-
echo "workspace directory is $workspace"
21-
echo "build URL is $buildUrl"
22-
echo "build Number is $buildNumber"
23-
echo "branch name is $branchName"
24-
echo "PATH is $env.PATH"
19+
// PRINT ENVIRONMENT TO JOB
20+
echo "workspace directory is $workspace"
21+
echo "build URL is $buildUrl"
22+
echo "build Number is $buildNumber"
23+
echo "branch name is $branchName"
24+
echo "PATH is $env.PATH"
2525

26-
stage('Checkout') {
27-
checkout scm
28-
}
29-
30-
stage('Start Release') {
31-
echo "releaseVersion: ${releaseVersion}"
32-
sh "mvn gitflow:release -DreleaseVersion=${releaseVersion} -DskipITs=true "
33-
}
26+
stage('Checkout') {
27+
checkout scm
28+
}
3429

30+
stage('Start Release') {
31+
echo "releaseVersion: ${releaseVersion}"
32+
sh "./mvnw gitflow:release -DreleaseVersion=${releaseVersion} -DdevelopmentVersion=${developmentVersion} -DskipITs=true "
3533
}
3634
} catch (e) {
3735
mail subject: "${env.JOB_NAME} (${env.BUILD_NUMBER}): Error on build", to: '[email protected]', body: "Please go to ${env.BUILD_URL}."

0 commit comments

Comments
 (0)