Skip to content

Commit

Permalink
build(mvn): add mvn wrapper (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Sep 28, 2023
1 parent d22689c commit 0e4b84f
Show file tree
Hide file tree
Showing 6 changed files with 637 additions and 8 deletions.
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
*
* http://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 );
}
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
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
#
# http://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.1/apache-maven-3.9.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Run Requirements:
* Initialize submodules via: `git submodule init && git submodule update`

### Build project locally
* `mvn compile`
* `./mvnw compile`

### Build and run project locally in development hot-reload mode
* `sh devserver.sh` - this will start the Vert.x backend in hot-reload mode, so
Expand All @@ -73,28 +73,28 @@ the `web-client` frontend for hot-reload development, see
[cryostat-web Development Server](https://github.com/cryostatio/cryostat-web/blob/main/README.md#development-server).

### Build and push to local podman image registry
* `mvn package`
* Run `mvn -Dheadless=true clean package` to exclude web-client assets.
* `./mvnw package`
* Run `./mvnw -Dheadless=true clean package` to exclude web-client assets.
The `clean` phase should always be specified here, or else previously-generated
client assets will still be included into the built image.
* For other OCI builders, use the `imageBuilder` Maven property. For example, to
use docker, run: `mvn -DimageBuilder=$(which docker) clean verify`
use docker, run: `./mvnw -DimageBuilder=$(which docker) clean verify`

## TEST

### Unit tests
* `mvn test`
* `./mvnw test`

### Integration tests and analysis tools
* `mvn verify`
* `./mvnw verify`

### Skipping tests
* `-DskipUTs=true` to skip unit tests
* `-DskipITs=true` to skip integration tests
* `-DskipTests=true` to skip all tests

### Running integration tests without rebuild
* `mvn exec:exec@create-pod exec:exec@start-jfr-datasource
* `./mvnw exec:exec@create-pod exec:exec@start-jfr-datasource
exec:exec@start-grafana-dashboard exec:exec@start-container
exec:exec@wait-for-container failsafe:integration-test
exec:exec@stop-jfr-datasource exec:exec@stop-grafana exec:exec@stop-container
Expand All @@ -110,7 +110,7 @@ exec:exec@destroy-pod`
### Run on local podman*
* `run.sh`

Note: If you get a 'No plugin found' error, it is because maven has not downloaded all the necessary plugins. To resolve this error, manually run `mvn help:evaluate` to prompt maven to download the missing help plugin.
Note: If you get a 'No plugin found' error, it is because maven has not downloaded all the necessary plugins. To resolve this error, manually run `./mvnw help:evaluate` to prompt maven to download the missing help plugin.

### Run on local podman with Grafana, jfr-datasource and demo application*
* `smoketest.sh`
Expand Down
Loading

0 comments on commit 0e4b84f

Please sign in to comment.