Skip to content

Commit 85a2858

Browse files
authored
Merge pull request #518 from hazendaz/master
Build updates, maven updates,
2 parents cfda284 + 662e124 commit 85a2858

11 files changed

+244
-224
lines changed

.github/dependabot.yml

-27
This file was deleted.

.github/workflows/sonar.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Set up JDK
3434
uses: actions/setup-java@v3
3535
with:
36-
java-version: 11
36+
java-version: 17
3737
distribution: zulu
3838
- name: Analyze with SonarCloud
3939
run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_mybatis-dynamic-sql -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true

.github/workflows/sonatype.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up JDK
3131
uses: actions/setup-java@v3
3232
with:
33-
java-version: 11
33+
java-version: 17
3434
distribution: zulu
3535
- name: Deploy to Sonatype
3636
run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true

.mvn/extensions.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2016-2022 the original author or authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
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+
-->
19+
<extensions>
20+
<extension>
21+
<groupId>fr.jcgay.maven</groupId>
22+
<artifactId>maven-profiler</artifactId>
23+
<version>3.2</version>
24+
</extension>
25+
</extensions>

.mvn/maven.config

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5

.mvn/settings.xml

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2016-2020 the original author or authors.
4+
Copyright 2016-2022 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -16,13 +16,21 @@
1616
limitations under the License.
1717
1818
-->
19-
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20-
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
19+
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
2121
<servers>
2222
<server>
2323
<id>ossrh</id>
2424
<username>${env.CI_DEPLOY_USERNAME}</username>
2525
<password>${env.CI_DEPLOY_PASSWORD}</password>
2626
</server>
27+
<server>
28+
<id>gh-pages</id>
29+
</server>
30+
<server>
31+
<id>github</id>
32+
<username>${env.CI_DEPLOY_USERNAME}</username>
33+
<password>${env.GITHUB_TOKEN}</password>
34+
</server>
2735
</servers>
2836
</settings>
+124-79
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,162 @@
11
/*
2-
* Copyright 2007-present the original author or authors.
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
39
*
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
10+
* http://www.apache.org/licenses/LICENSE-2.0
711
*
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.
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.
1518
*/
16-
import java.net.*;
17-
import java.io.*;
18-
import java.nio.channels.*;
19+
20+
import java.io.IOException;
21+
import java.io.InputStream;
22+
import java.net.Authenticator;
23+
import java.net.PasswordAuthentication;
24+
import java.net.URL;
25+
import java.nio.file.Files;
26+
import java.nio.file.LinkOption;
27+
import java.nio.file.Path;
28+
import java.nio.file.Paths;
29+
import java.nio.file.StandardCopyOption;
30+
import java.nio.file.StandardOpenOption;
1931
import java.util.Properties;
2032

21-
public class MavenWrapperDownloader {
33+
public final class MavenWrapperDownloader
34+
{
35+
private static final String WRAPPER_VERSION = "3.1.1";
36+
37+
private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );
2238

23-
private static final String WRAPPER_VERSION = "0.5.6";
2439
/**
2540
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
2641
*/
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";
42+
private static final String DEFAULT_DOWNLOAD_URL =
43+
"https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/" + WRAPPER_VERSION
44+
+ "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
2945

3046
/**
31-
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32-
* use instead of the default one.
47+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the
48+
* default one.
3349
*/
34-
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35-
".mvn/wrapper/maven-wrapper.properties";
50+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";
3651

3752
/**
3853
* Path where the maven-wrapper.jar will be saved to.
3954
*/
40-
private static final String MAVEN_WRAPPER_JAR_PATH =
41-
".mvn/wrapper/maven-wrapper.jar";
55+
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
4256

4357
/**
4458
* Name of the property which should be used to override the default download url for the wrapper.
4559
*/
4660
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
4761

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());
62+
public static void main( String[] args )
63+
{
64+
if ( args.length == 0 )
65+
{
66+
System.err.println( " - ERROR projectBasedir parameter missing" );
67+
System.exit( 1 );
68+
}
69+
70+
log( " - Downloader started" );
71+
final String dir = args[0].replace( "..", "" ); // Sanitize path
72+
final Path projectBasedir = Paths.get( dir ).toAbsolutePath().normalize();
73+
if ( !Files.isDirectory( projectBasedir, LinkOption.NOFOLLOW_LINKS ) )
74+
{
75+
System.err.println( " - ERROR projectBasedir not exists: " + projectBasedir );
76+
System.exit( 1 );
77+
}
78+
79+
log( " - Using base directory: " + projectBasedir );
5280

5381
// If the maven-wrapper.properties exists, read it and check if it contains a custom
5482
// wrapperUrl parameter.
55-
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56-
String url = DEFAULT_DOWNLOAD_URL;
57-
if(mavenWrapperPropertyFile.exists()) {
58-
FileInputStream mavenWrapperPropertyFileInputStream = null;
59-
try {
60-
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61-
Properties mavenWrapperProperties = new Properties();
62-
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63-
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64-
} catch (IOException e) {
65-
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66-
} finally {
67-
try {
68-
if(mavenWrapperPropertyFileInputStream != null) {
69-
mavenWrapperPropertyFileInputStream.close();
70-
}
71-
} catch (IOException e) {
72-
// Ignore ...
73-
}
74-
}
75-
}
76-
System.out.println("- Downloading from: " + url);
83+
Path mavenWrapperPropertyFile = projectBasedir.resolve( MAVEN_WRAPPER_PROPERTIES_PATH );
84+
String url = readWrapperUrl( mavenWrapperPropertyFile );
7785

78-
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79-
if(!outputFile.getParentFile().exists()) {
80-
if(!outputFile.getParentFile().mkdirs()) {
81-
System.out.println(
82-
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83-
}
86+
try
87+
{
88+
Path outputFile = projectBasedir.resolve( MAVEN_WRAPPER_JAR_PATH );
89+
createDirectories( outputFile.getParent() );
90+
downloadFileFromURL( url, outputFile );
91+
log( "Done" );
92+
System.exit( 0 );
8493
}
85-
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86-
try {
87-
downloadFileFromURL(url, outputFile);
88-
System.out.println("Done");
89-
System.exit(0);
90-
} catch (Throwable e) {
91-
System.out.println("- Error downloading");
94+
catch ( IOException e )
95+
{
96+
System.err.println( "- Error downloading" );
9297
e.printStackTrace();
93-
System.exit(1);
98+
System.exit( 1 );
9499
}
95100
}
96101

97-
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+
private static void downloadFileFromURL( String urlString, Path destination ) throws IOException
103+
{
104+
log( " - Downloading to: " + destination );
105+
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
106+
{
107+
final String username = System.getenv( "MVNW_USERNAME" );
108+
final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
109+
Authenticator.setDefault( new Authenticator()
110+
{
102111
@Override
103-
protected PasswordAuthentication getPasswordAuthentication() {
104-
return new PasswordAuthentication(username, password);
112+
protected PasswordAuthentication getPasswordAuthentication()
113+
{
114+
return new PasswordAuthentication( username, password );
105115
}
106-
});
116+
} );
117+
}
118+
URL website = new URL( urlString );
119+
try ( InputStream inStream = website.openStream() ) {
120+
Files.copy( inStream, destination, StandardCopyOption.REPLACE_EXISTING );
121+
}
122+
log( " - Downloader complete" );
123+
}
124+
125+
private static void createDirectories(Path outputPath) throws IOException
126+
{
127+
if ( !Files.isDirectory( outputPath, LinkOption.NOFOLLOW_LINKS ) ) {
128+
Path createDirectories = Files.createDirectories( outputPath );
129+
log( " - Directories created: " + createDirectories );
130+
}
131+
}
132+
133+
private static String readWrapperUrl( Path mavenWrapperPropertyFile )
134+
{
135+
String url = DEFAULT_DOWNLOAD_URL;
136+
if ( Files.exists( mavenWrapperPropertyFile, LinkOption.NOFOLLOW_LINKS ) )
137+
{
138+
log( " - Reading property file: " + mavenWrapperPropertyFile );
139+
try ( InputStream in = Files.newInputStream( mavenWrapperPropertyFile, StandardOpenOption.READ ) )
140+
{
141+
Properties mavenWrapperProperties = new Properties();
142+
mavenWrapperProperties.load( in );
143+
url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, DEFAULT_DOWNLOAD_URL );
144+
}
145+
catch ( IOException e )
146+
{
147+
System.err.println( " - ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" );
148+
}
149+
}
150+
log( " - Downloading from: " + url );
151+
return url;
152+
}
153+
154+
private static void log( String msg )
155+
{
156+
if ( VERBOSE )
157+
{
158+
System.out.println( msg );
107159
}
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();
115160
}
116161

117162
}

.mvn/wrapper/maven-wrapper.properties

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
2-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

0 commit comments

Comments
 (0)