Skip to content

Commit

Permalink
[GHA] Add maven wrapper / update other items in github actions (#931)
Browse files Browse the repository at this point in the history
* [GHA] Bump sonarqube to java 17 as 11 no longer supported

* [GHA] Run on ubuntu-latest (its the same currently)

* [mvn] Add maven wrapper so it runs off 3.9.6

github still uses 3.8.x which is more of less EOL.

* [mvn] Make sure we push more secure checksums as well as use them

* [GHA] Drop dependabot as renovate does all this

* [GHA] Put rest on maven wrapper

* [chmod] Add executable permission
  • Loading branch information
hazendaz authored Jan 15, 2024
1 parent 4656bcf commit 53b0ada
Show file tree
Hide file tree
Showing 8 changed files with 637 additions and 15 deletions.
9 changes: 0 additions & 9 deletions .github/dependabot.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
restore-keys: ${{ runner.os }}-sonar
- name: Build
run: |
mvn verify -B -e -V \
./mvnw verify -B -e -V \
-Dsonar.server.version=${{ matrix.SONAR_SERVER_VERSION }} \
-Dsonar-plugin-api.version=${{ matrix.SONAR_PLUGIN_API_VERSION }} \
-Dsonar-plugin-api.groupId=${{ matrix.SONAR_PLUGIN_API_GROUPID }} \
Expand All @@ -99,7 +99,7 @@ jobs:
gpg-passphrase: GPG_PASSPHRASE
- name: Deploy artifacts to Maven Central
run: |
mvn clean deploy -B -e -P deploy -DskipTests
./mvnw clean deploy -B -e -P deploy -DskipTests
env:
OSSRH_JIRA_USERNAME: eller86
OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
build:
# Forked repos do not have access to the Sonar account
if: github.repository == 'spotbugs/sonar-findbugs'
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
env:
# previous LTS version
SONAR_SERVER_VERSION: 8.9.9.56886
Expand All @@ -45,10 +45,10 @@ jobs:
with:
fetch-depth: 0
ref: ${{ steps.condval.outputs.value }}
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin
cache: 'maven'
- name: Cache SonarCloud packages
Expand All @@ -60,7 +60,7 @@ jobs:
restore-keys: ${{ runner.os }}-sonar
- name: Build
run: |
mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar -B -e -V -DskipITs \
./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar -B -e -V -DskipITs \
-Dsonar.server.version=${{ env.SONAR_SERVER_VERSION }} \
-Dsonar-plugin-api.version=${{ env.SONAR_PLUGIN_API_VERSION }} \
-Dsonar-plugin-api.groupId=${{ env.SONAR_PLUGIN_API_GROUPID }} \
Expand Down
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5
-Daether.connector.smartChecksums=false
98 changes: 98 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* 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
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.IOException;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

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

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

public static void main( String[] args )
{
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );

if ( args.length != 2 )
{
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
System.exit( 1 );
}

try
{
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" );
}
catch ( IOException e )
{
System.err.println( "- Error downloading: " + e.getMessage() );
if ( VERBOSE )
{
e.printStackTrace();
}
System.exit( 1 );
}
}

private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
throws IOException
{
log( " - Downloading to: " + wrapperJarPath );
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
{
final String username = System.getenv( "MVNW_USERNAME" );
final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
Authenticator.setDefault( new Authenticator()
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication( username, password );
}
} );
}
try ( InputStream inStream = wrapperUrl.openStream() )
{
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
}
log( " - Downloader complete" );
}

private static void log( String msg )
{
if ( VERBOSE )
{
System.out.println( msg );
}
}

}
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# 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
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Loading

0 comments on commit 53b0ada

Please sign in to comment.