Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GHA, maven, automated fixes on build #581

Merged
merged 4 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
* text=auto
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
java: [11, 17, 19, 20-ea]
java: [11, 17, 20, 21-ea]
distribution: ['zulu']
fail-fast: false
max-parallel: 4
Expand All @@ -38,4 +38,4 @@ jobs:
java-version: ${{ matrix.java }}
distribution: ${{ matrix.distribution }}
- name: Test with Maven
run: ./mvnw test -B -D"license.skip=true"
run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true"
6 changes: 3 additions & 3 deletions .github/workflows/coveralls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: zulu
- name: Report Coverage to Coveralls for Pull Requests
if: github.event_name == 'pull_request'
run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER
run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- name: Report Coverage to Coveralls for General Push
if: github.event_name == 'push'
run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github
run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
java-version: 17
distribution: zulu
- name: Analyze with SonarCloud
run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_guice -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true
run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_guice -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/sonatype.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
java-version: 17
distribution: zulu
- name: Deploy to Sonatype
run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true
run: ./mvnw deploy -DskipTests -B -V --no-transfer-progress --settings ./.mvn/settings.xml -Dlicense.skip=true
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2009-2022 the original author or authors.
Copyright 2009-2023 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5
-Daether.connector.smartChecksums=false
9 changes: 7 additions & 2 deletions .mvn/settings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2009-2022 the original author or authors.
Copyright 2009-2023 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -24,8 +24,13 @@
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
<!-- Used for gh-pages-scm publish via maven-scm-publish-plugin -->
<server>
<id>gh-pages</id>
<id>gh-pages-scm</id>
<configuration>
<scmVersionType>branch</scmVersionType>
<scmVersion>gh-pages</scmVersion>
</configuration>
</server>
<server>
<id>github</id>
Expand Down
106 changes: 21 additions & 85 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand All @@ -23,85 +23,50 @@
import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.Properties;

public final class MavenWrapperDownloader
{
private static final String WRAPPER_VERSION = "3.1.1";
private static final String WRAPPER_VERSION = "3.2.0";

private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );

/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/" + WRAPPER_VERSION
+ "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the
* default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";

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

public static void main( String[] args )
{
if ( args.length == 0 )
{
System.err.println( " - ERROR projectBasedir parameter missing" );
System.exit( 1 );
}
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );

log( " - Downloader started" );
final String dir = args[0].replace( "..", "" ); // Sanitize path
final Path projectBasedir = Paths.get( dir ).toAbsolutePath().normalize();
if ( !Files.isDirectory( projectBasedir, LinkOption.NOFOLLOW_LINKS ) )
if ( args.length != 2 )
{
System.err.println( " - ERROR projectBasedir not exists: " + projectBasedir );
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
System.exit( 1 );
}

log( " - Using base directory: " + projectBasedir );

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
Path mavenWrapperPropertyFile = projectBasedir.resolve( MAVEN_WRAPPER_PROPERTIES_PATH );
String url = readWrapperUrl( mavenWrapperPropertyFile );

try
{
Path outputFile = projectBasedir.resolve( MAVEN_WRAPPER_JAR_PATH );
createDirectories( outputFile.getParent() );
downloadFileFromURL( url, outputFile );
log( " - Downloader started" );
final URL wrapperUrl = new URL( args[0] );
final String jarPath = args[1].replace( "..", "" ); // Sanitize path
final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
downloadFileFromURL( wrapperUrl, wrapperJarPath );
log( "Done" );
System.exit( 0 );
}
catch ( IOException e )
{
System.err.println( "- Error downloading" );
e.printStackTrace();
System.err.println( "- Error downloading: " + e.getMessage() );
if ( VERBOSE )
{
e.printStackTrace();
}
System.exit( 1 );
}
}

private static void downloadFileFromURL( String urlString, Path destination ) throws IOException
private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
throws IOException
{
log( " - Downloading to: " + destination );
log( " - Downloading to: " + wrapperJarPath );
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
{
final String username = System.getenv( "MVNW_USERNAME" );
Expand All @@ -115,40 +80,11 @@ protected PasswordAuthentication getPasswordAuthentication()
}
} );
}
URL website = new URL( urlString );
try ( InputStream inStream = website.openStream() ) {
Files.copy( inStream, destination, StandardCopyOption.REPLACE_EXISTING );
}
log( " - Downloader complete" );
}

private static void createDirectories(Path outputPath) throws IOException
{
if ( !Files.isDirectory( outputPath, LinkOption.NOFOLLOW_LINKS ) ) {
Path createDirectories = Files.createDirectories( outputPath );
log( " - Directories created: " + createDirectories );
}
}

private static String readWrapperUrl( Path mavenWrapperPropertyFile )
{
String url = DEFAULT_DOWNLOAD_URL;
if ( Files.exists( mavenWrapperPropertyFile, LinkOption.NOFOLLOW_LINKS ) )
try ( InputStream inStream = wrapperUrl.openStream() )
{
log( " - Reading property file: " + mavenWrapperPropertyFile );
try ( InputStream in = Files.newInputStream( mavenWrapperPropertyFile, StandardOpenOption.READ ) )
{
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load( in );
url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, DEFAULT_DOWNLOAD_URL );
}
catch ( IOException e )
{
System.err.println( " - ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" );
}
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
}
log( " - Downloading from: " + url );
return url;
log( " - Downloader complete" );
}

private static void log( String msg )
Expand Down
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
Expand Down
2 changes: 1 addition & 1 deletion mvnw
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
Expand Down
2 changes: 1 addition & 1 deletion mvnw.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2009-2022 the original author or authors.
Copyright 2009-2023 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions src/site/site.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2009-2022 the original author or authors.
Copyright 2009-2023 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,4 +41,4 @@

<menu ref="reports"/>
</body>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
package org.mybatis.guice.customsqlsessionfactory;

import static com.google.inject.name.Names.bindProperties;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.inject.Guice;
import com.google.inject.Injector;
Expand Down