### Setup Test Environment for Installer Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/InstallerTest.html Initializes the test directory, wrapper configuration, and mocks for dependencies like Downloader, Verifier, and PathAssembler. This setup is crucial for isolating and testing the Installer's behavior. ```java @BeforeEach void setup() throws Exception { testDir = tempFolder.toPath(); configuration.setZipBase(PathAssembler.PROJECT_STRING); configuration.setZipPath(Paths.get("someZipPath")); configuration.setDistributionBase(PathAssembler.MAVEN_USER_HOME_STRING); configuration.setDistributionPath(Paths.get("someDistPath")); configuration.setDistribution(new URI("http://server/maven-0.9.zip")); configuration.setAlwaysDownload(false); configuration.setAlwaysUnpack(false); configuration.setDistributionSha256Sum(""); distributionDir = testDir.resolve("someDistPath"); mavenHomeDir = distributionDir.resolve("maven-0.9"); zipStore = testDir.resolve("zips"); zipDestination = zipStore.resolve("maven-0.9.zip"); download = mock(Downloader.class); verifier = mock(Verifier.class); pathAssembler = mock(PathAssembler.class); localDistribution = mock(PathAssembler.LocalDistribution.class); when(localDistribution.getZipFile()).thenReturn(zipDestination); when(localDistribution.getDistributionDir()).thenReturn(distributionDir); when(pathAssembler.getDistribution(configuration)).thenReturn(localDistribution); install = new Installer(download, verifier, pathAssembler); } ``` -------------------------------- ### execute(String[] args, Installer install, BootstrapMainStarter bootstrapMainStarter) Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/WrapperExecutor.html Executes the Maven wrapper with the provided arguments, installer, and bootstrap starter. ```APIDOC ## execute(String[] args, Installer install, BootstrapMainStarter bootstrapMainStarter) ### Description Executes the Maven wrapper with the provided arguments, installer, and bootstrap starter. ### Method public ### Parameters - **args** (String[]) - The command line arguments to pass to Maven. - **install** (Installer) - The installer component for creating the Maven distribution. - **bootstrapMainStarter** (BootstrapMainStarter) - The starter component for bootstrapping the Maven process. ``` -------------------------------- ### Test Execute Install and Launch Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/WrapperExecutorTest.html Verifies the execution flow where the wrapper installs and then launches a distribution. It checks if the install and start methods are called with the correct arguments. ```java void executeInstallAndLaunch() throws Exception { WrapperExecutor wrapper = WrapperExecutor.forProjectDirectory(propertiesFile); wrapper.execute(new String[] {"arg"}, install, start); verify(install).createDist(Mockito.any(WrapperConfiguration.class)); verify(start).start(new String[] {"arg"}, mockInstallDir); } ``` -------------------------------- ### start(String[] args, Path mavenHome) Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/BootstrapMainStarter.html Starts Maven using the provided arguments and Maven home directory. ```APIDOC ## start(String[] args, Path mavenHome) ### Description Starts Maven using the provided arguments and Maven home directory. ### Method `void start(String[] args, Path mavenHome)` ### Parameters #### Path Parameters - **args** (String[]) - Description not available - **mavenHome** (Path) - Description not available ### Throws - `Exception` ``` -------------------------------- ### Installer Constructor Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/Installer.html Initializes a new instance of the Installer class with the specified Downloader, Verifier, and PathAssembler. ```APIDOC ## Installer Constructor ### Description Initializes a new instance of the Installer class. ### Constructor `Installer(Downloader download, Verifier verifier, PathAssembler pathAssembler)` ### Parameters * **download** (Downloader) - The Downloader component to use for fetching distributions. * **verifier** (Verifier) - The Verifier component to use for validating downloaded files. * **pathAssembler** (PathAssembler) - The PathAssembler component to use for constructing file paths. ``` -------------------------------- ### Execute Maven Wrapper Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/WrapperExecutor.html Executes the Maven wrapper with the given arguments. This method handles the installation of the Maven distribution and then starts the Maven process. ```java public void execute(String[] args, Installer install, BootstrapMainStarter bootstrapMainStarter) throws Exception { Path mavenHome = install.createDist(config); bootstrapMainStarter.start(args, mavenHome); } ``` -------------------------------- ### Installer Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/allclasses-index.html Installs Maven distributions, potentially using a Downloader first. ```APIDOC ## Class Installer ### Description Maven distribution installer, eventually using a `Downloader` first. ### Type Class ``` -------------------------------- ### Installer Class Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/index-all.html Handles the installation of Maven distributions, potentially using a Downloader and Verifier. ```APIDOC ## Installer ### Description Maven distribution installer, eventually using a `Downloader` first. ### Constructor Installer(Downloader, Verifier, PathAssembler) ``` -------------------------------- ### BootstrapMainStarter.start(String[], Path) Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/index-all.html Starts the Maven wrapper bootstrap process with the given arguments and base path. ```APIDOC ## start(String[], Path) ### Description Starts the Maven wrapper bootstrap process. ### Method N/A (Method signature) ### Parameters - **args** (String[]) - Description not provided - **basePath** (Path) - Description not provided ``` -------------------------------- ### BootstrapMainStarter Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/allclasses-index.html Starts the Maven bootstrap process from a provided Maven home directory. ```APIDOC ## Class BootstrapMainStarter ### Description Maven starter, from a provided Maven home directory. ### Type Class ``` -------------------------------- ### BeforeFirstSubCommand onStartOption Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/cli/CommandLineParser.html Handles the start of an option within the 'BeforeFirstSubCommand' state. It creates an OptionString and retrieves the corresponding CommandLineOption. ```java @Override public OptionParserState onStartOption(String arg, String option) { OptionString optionString = new OptionString(arg, option); CommandLineOption commandLineOption = optionsByString.get(option); ``` -------------------------------- ### Start Maven from Maven Home Directory Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/BootstrapMainStarter.html Initiates the Maven process by finding the launcher JAR, setting up a custom classloader, configuring system properties for Maven home and configuration, and invoking the main method of the Maven launcher class. ```java /* * 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. */ package org.apache.maven.wrapper; import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.Iterator; import java.util.Locale; /** * Maven starter, from a provided Maven home directory. * * @author Hans Dockter */ public class BootstrapMainStarter { public void start(String[] args, Path mavenHome) throws Exception { final Path mavenJar = findLauncherJar(mavenHome); URLClassLoader contextClassLoader = new URLClassLoader( new URL[] {mavenJar.toUri().toURL()}, ClassLoader.getSystemClassLoader().getParent()); Thread.currentThread().setContextClassLoader(contextClassLoader); Class mainClass = contextClassLoader.loadClass("org.codehaus.plexus.classworlds.launcher.Launcher"); System.setProperty("maven.home", mavenHome.toAbsolutePath().toString()); System.setProperty( "classworlds.conf", mavenHome.resolve("bin/m2.conf").toAbsolutePath().toString()); Method mainMethod = mainClass.getMethod("main", String[].class); mainMethod.invoke(null, new Object[] {args}); } private Path findLauncherJar(Path mavenHome) throws IOException { final Path mavenBoot = mavenHome.resolve("boot"); if (Files.isDirectory(mavenBoot)) { try (DirectoryStream ds = Files.newDirectoryStream(mavenBoot, "plexus-classworlds-*.jar")) { Iterator iterator = ds.iterator(); if (iterator.hasNext()) { return iterator.next(); } } } throw new FileNotFoundException(String.format( Locale.ROOT, "Could not locate the Maven launcher JAR" + " in Maven distribution '%s'.", mavenHome)); } } ``` -------------------------------- ### WrapperExecutor.execute Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/WrapperExecutor.html Executes the Maven wrapper with the provided arguments, installer, and bootstrap starter. This method initiates the Maven build process. ```APIDOC ## WrapperExecutor.execute ### Description Executes the Maven wrapper with the provided arguments, installer, and bootstrap starter. This method initiates the Maven build process. ### Method instance ### Parameters #### Path Parameters - **args** (String[]) - Required - The command-line arguments to pass to Maven. - **install** (Installer) - Required - The installer component responsible for preparing the Maven distribution. - **bootstrapMainStarter** (BootstrapMainStarter) - Required - The starter component for the Maven bootstrap process. ### Throws - **Exception** - If any error occurs during the execution of the wrapper. ``` -------------------------------- ### Maven Wrapper Installer Class Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/Installer.html The Installer class is responsible for managing Maven distribution installations. It uses Downloader, Verifier, and PathAssembler to ensure distributions are correctly obtained and prepared. ```java package org.apache.maven.wrapper; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.nio.file.DirectoryStream; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardCopyOption; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.Locale; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; /** * Maven distribution installer, eventually using a {@link Downloader} first. * * @author Hans Dockter */ public class Installer { public static final Path DEFAULT_DISTRIBUTION_PATH = Paths.get("wrapper", "dists"); private final Downloader download; private final Verifier verifier; private final PathAssembler pathAssembler; public Installer(Downloader download, Verifier verifier, PathAssembler pathAssembler) { this.download = download; this.verifier = verifier; this.pathAssembler = pathAssembler; } public Path createDist(WrapperConfiguration configuration) throws Exception { URI distributionUrl = configuration.getDistribution(); boolean alwaysDownload = configuration.isAlwaysDownload(); boolean alwaysUnpack = configuration.isAlwaysUnpack(); boolean verifyDistributionSha256Sum = !configuration.getDistributionSha256Sum().isEmpty(); PathAssembler.LocalDistribution localDistribution = pathAssembler.getDistribution(configuration); Path localZipFile = localDistribution.getZipFile(); if (alwaysDownload || alwaysUnpack || Files.notExists(localZipFile)) { Logger.info("Installing Maven distribution " + localDistribution.getDistributionDir().toAbsolutePath()); } boolean downloaded = false; if (alwaysDownload || Files.notExists(localZipFile)) { Logger.info("Downloading " + distributionUrl); Path tmpZipFile = localZipFile.resolveSibling(localZipFile.getFileName() + ".part"); Files.deleteIfExists(tmpZipFile); download.download(distributionUrl, tmpZipFile); Files.move(tmpZipFile, localZipFile, StandardCopyOption.REPLACE_EXISTING); downloaded = Files.exists(localZipFile); } Path distDir = localDistribution.getDistributionDir(); List dirs = listDirs(distDir); if (downloaded || alwaysUnpack || dirs.isEmpty()) { if (verifyDistributionSha256Sum) { verifier.verify( localZipFile, "distributionSha256Sum", Verifier.SHA_256_ALGORITHM, configuration.getDistributionSha256Sum()); } for (Path dir : dirs) { Logger.info("Deleting directory " + dir.toAbsolutePath()); deleteDir(dir); } Logger.info("Unzipping " + localZipFile.toAbsolutePath() + " to " + distDir.toAbsolutePath()); unzip(localZipFile, distDir); dirs = listDirs(distDir); if (dirs.isEmpty()) { ``` -------------------------------- ### getZipFile Method Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/PathAssembler.LocalDistribution.html Retrieves the location where the distribution ZIP file will be installed. ```APIDOC ## Method: getZipFile ### Description Returns the location to install the distribution ZIP file to. ### Returns * **Path** - The location to install the distribution ZIP file to. ``` -------------------------------- ### Installer.createDist Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/index-all.html Method to create a distribution, likely for the Maven Wrapper. This method is part of the Installer class. ```APIDOC ## Method Installer.createDist ### Description Creates a distribution for the Maven Wrapper. ### Parameters - `WrapperConfiguration configuration` - The configuration for the distribution. ``` -------------------------------- ### getPropertyOptionDescription Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/AbstractPropertiesCommandLineConverter.html Abstract method to get the description for the property command line option. ```APIDOC ## getPropertyOptionDescription ### Description Abstract method to get the description for the property command line option. ### Method `getPropertyOptionDescription()` ### Returns * `String` - The description of the property option. ``` -------------------------------- ### Get Wrapper Configuration Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/WrapperExecutor.html Returns the current configuration of the Maven wrapper. This includes settings like the distribution URL and other properties. ```java public WrapperConfiguration getConfiguration() { return config; } ``` -------------------------------- ### Parsing Command Line Arguments Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/cli/CommandLineParser.html This snippet demonstrates the core logic for parsing command-line arguments. It handles various formats for options, including those starting with '--' or '-', with or without arguments, and chained single-character options. ```java if ("--".equals(arg)) { parseState = new AfterOptions(parsedCommandLine); } else if (arg.matches("--[^=]+")) { OptionParserState parsedOption = parseState.onStartOption(arg, arg.substring(2)); parseState = parsedOption.onStartNextArg(); } else if (arg.matches("--[^=]+=.*")) { int endArg = arg.indexOf('='); OptionParserState parsedOption = parseState.onStartOption(arg, arg.substring(2, endArg)); parseState = parsedOption.onArgument(arg.substring(endArg + 1)); } else if (arg.matches("-[^=]=.*")) { OptionParserState parsedOption = parseState.onStartOption(arg, arg.substring(1, 2)); parseState = parsedOption.onArgument(arg.substring(3)); } else { assert arg.matches("-[^-].*"); String option = arg.substring(1); if (optionsByString.containsKey(option)) { OptionParserState parsedOption = parseState.onStartOption(arg, option); parseState = parsedOption.onStartNextArg(); } else { String option1 = arg.substring(1, 2); OptionParserState parsedOption; if (optionsByString.containsKey(option1)) { parsedOption = parseState.onStartOption("-" + option1, option1); if (parsedOption.getHasArgument()) { parseState = parsedOption.onArgument(arg.substring(2)); } else { parseState = parsedOption.onComplete(); for (int i = 2; i < arg.length(); i++) { String optionStr = arg.substring(i, i + 1); parsedOption = parseState.onStartOption("-" + optionStr, optionStr); parseState = parsedOption.onComplete(); } } } else { if (allowUnknownOptions) { // if we are allowing unknowns, just pass through the whole arg parsedOption = parseState.onStartOption(arg, option); parseState = parsedOption.onComplete(); } else { // We are going to throw a CommandLineArgumentException below, but want the message // to reflect that we didn't recognise the first char (i.e. the option specifier) parsedOption = parseState.onStartOption("-" + option1, option1); parseState = parsedOption.onComplete(); } } } } } else { parseState = parseState.onNonOption(arg); } } parseState.onCommandLineEnd(); return parsedCommandLine; ``` -------------------------------- ### Creating a Jar File Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/InstallerTest.html Illustrates creating a JAR file with a manifest and an entry using JarOutputStream. ```java try (OutputStream os = Files.newOutputStream(mavenLib); JarOutputStream jar = new JarOutputStream(os, new Manifest())) { jar.putNextEntry(new ZipEntry("test")); jar.closeEntry(); } ``` -------------------------------- ### getDistributionDir Method Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/PathAssembler.LocalDistribution.html Retrieves the location where the distribution will be installed. ```APIDOC ## Method: getDistributionDir ### Description Returns the location to install the distribution into. ### Returns * **Path** - The location to install the distribution into. ``` -------------------------------- ### Execute Maven Build (Linux/macOS) Source: https://maven.apache.org/tools/wrapper/index.html Once the Maven Wrapper is set up, users can execute Maven commands using the provided wrapper script. ```bash ./mvnw clean install ``` -------------------------------- ### getPropertyOption Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/AbstractPropertiesCommandLineConverter.html Abstract method to get the command line option for properties. ```APIDOC ## getPropertyOption ### Description Abstract method to get the command line option for properties. ### Method `getPropertyOption()` ### Returns * `String` - The property option string. ``` -------------------------------- ### Create Directories Source: https://maven.apache.org/tools/wrapper/maven-wrapper-plugin/xref/org/apache/maven/plugins/wrapper/WrapperMojo.html Creates the necessary directories for the wrapper distribution. ```java private void createDirectories(Path dir) throws MojoExecutionException { try { Files.createDirectories(dir); } catch (IOException e) { throw new MojoExecutionException("Failed to create directories: " + dir, e); } } ``` -------------------------------- ### getPropertyOptionDetailed Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/AbstractPropertiesCommandLineConverter.html Abstract method to get the detailed description for the property command line option. ```APIDOC ## getPropertyOptionDetailed ### Description Abstract method to get the detailed description for the property command line option. ### Method `getPropertyOptionDetailed()` ### Returns * `String` - The detailed description of the property option. ``` -------------------------------- ### Display Help Information for Maven Wrapper Plugin Source: https://maven.apache.org/tools/wrapper/maven-wrapper-plugin/plugin-info.html Use this command to display help information for the Maven Wrapper Plugin. Add '-Ddetail=true' and '-Dgoal=' to see parameter details for a specific goal. ```bash mvn wrapper:help -Ddetail=true -Dgoal= ``` -------------------------------- ### Installer.unzip Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/index-all.html Unzips a file from a source path to a destination path. ```APIDOC ## Method public void unzip(Path source, Path destination) ### Description Unzips a file from a source path to a destination path. ### Parameters #### Path Parameters - **source** (Path) - Description of the source path. - **destination** (Path) - Description of the destination path. ``` -------------------------------- ### main Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/MavenWrapperMain.html The main entry point for the Maven Wrapper. This static method delegates wrapper execution to WrapperExecutor. ```APIDOC ## main ### Description Main entry point for the Maven Wrapper, delegating wrapper execution to `WrapperExecutor`. ### Method `static void main(String[] args)` ### Parameters * **args** (String[]) - The command line arguments. ### Throws * `Exception` - If an error occurs during wrapper execution. ``` -------------------------------- ### ParserState isOption Check Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/cli/CommandLineParser.html Checks if a given argument string represents an option by verifying if it starts with a hyphen. ```java boolean isOption(String arg) { return arg.matches("-.+"); ``` -------------------------------- ### Get Wrapper Property Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/WrapperExecutor.html Retrieves a specific property from the wrapper configuration. If the property is not found, it returns null. ```java private String getProperty(String propertyName) { return getProperty(propertyName, null); } ``` -------------------------------- ### DefaultDownloader Constructor and Authentication Configuration Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/DefaultDownloader.html Initializes the DefaultDownloader and configures proxy and basic authentication based on system properties and environment variables. ```java public DefaultDownloader(String applicationName, String applicationVersion) { this.applicationName = applicationName; this.applicationVersion = applicationVersion; configureProxyAuthentication(); configureAuthentication(); } ``` -------------------------------- ### Test Zip Slip Vulnerability Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/InstallerTest.html Validates that the installer correctly throws an exception when encountering a zip-slip vulnerability in the archive. ```java configuration.setAlwaysUnpack(true); try { install.createDist(configuration); fail("Should fail as it contains a zip slip."); } catch (Exception ex) { assertTrue(ex instanceof ZipException); } ``` -------------------------------- ### BootstrapMainStarter() Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/BootstrapMainStarter.html Constructs a new BootstrapMainStarter object. ```APIDOC ## BootstrapMainStarter() ### Description Constructs a new BootstrapMainStarter object. ### Constructor `BootstrapMainStarter()` ``` -------------------------------- ### Load Wrapper Metadata from Properties File Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/WrapperExecutorTest.html Tests loading wrapper configuration properties from a specified properties file. Verifies that distribution URL, base, path, and zip store details are correctly parsed. ```java @Test void loadWrapperMetadataFromFile() throws Exception { WrapperExecutor wrapper = WrapperExecutor.forWrapperPropertiesFile(propertiesFile); assertEquals(new URI("http://server/test/maven.zip"), wrapper.getDistribution()); assertEquals( new URI("http://server/test/maven.zip"), wrapper.getConfiguration().getDistribution()); assertEquals("testDistBase", wrapper.getConfiguration().getDistributionBase()); assertEquals( "testDistPath", wrapper.getConfiguration().getDistributionPath().toString()); assertEquals("testZipBase", wrapper.getConfiguration().getZipBase()); assertEquals("testZipPath", wrapper.getConfiguration().getZipPath().toString()); } ``` -------------------------------- ### WrapperExecutor.getConfiguration Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/WrapperExecutor.html Gets the current configuration for the Maven wrapper. This includes settings like download preferences and unpack locations. ```APIDOC ## WrapperExecutor.getConfiguration ### Description Gets the current configuration for the Maven wrapper. This includes settings like download preferences and unpack locations. ### Method instance ### Returns - **WrapperConfiguration** - The configuration object for this wrapper. ``` -------------------------------- ### CommandLineOption Constructor Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/CommandLineOption.html Initializes a new instance of the CommandLineOption class with the specified options. ```APIDOC ## CommandLineOption(Iterable options) ### Description Constructs a new CommandLineOption with the given set of string options. ### Parameters * **options** (Iterable) - The collection of string options for this command line option. ``` -------------------------------- ### Generate Maven Wrapper with Source Distribution Source: https://maven.apache.org/tools/wrapper/index.html Use this command to generate the Maven Wrapper with the source distribution, which includes a .mvn/wrapper/MavenWrapperDownloader.java file instead of a binary JAR. ```bash mvn wrapper:wrapper -Dtype=source ``` -------------------------------- ### Get Wrapper Property with Default Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/WrapperExecutor.html Retrieves a specific property from the wrapper configuration, providing a default value if the property is not found. ```java private String getProperty(String propertyName, String defaultValue) { String value = properties.getProperty(propertyName, defaultValue); if (value == null) { reportMissingProperty(propertyName); } return value; } ``` -------------------------------- ### getPropertyOptionDescription Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/SystemPropertiesCommandLineConverter.html Retrieves the description of the system property command-line option. ```APIDOC ## getPropertyOptionDescription() ### Description Retrieves a brief description of the command-line option for system properties. ### Method `protected String getPropertyOptionDescription()` ### Returns A string with the description of the system property option. ``` -------------------------------- ### Initialize Maven Wrapper with Specific Version Source: https://maven.apache.org/tools/wrapper/index.html Use this command to initialize the Maven Wrapper with a specific Maven version. This command works for any version, including snapshots. ```bash mvn wrapper:wrapper -Dmaven=3.5.4 ``` -------------------------------- ### OptionString Display Name Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/cli/CommandLineParser.html Generates the display name for an option string, prefixing with '--' for arguments starting with '--' and '-' otherwise. ```java public String getDisplayName() { return arg.startsWith("--") ? "--" + option : "-" + option; ``` -------------------------------- ### Generate Maven Wrapper with Lite Script Implementation Source: https://maven.apache.org/tools/wrapper/index.html Use this command to generate the Maven Wrapper with a lite script implementation. This type downloads Maven directly using wget, curl, or PowerShell and does not use maven-wrapper.jar or MavenWrapperDownloader.java. ```bash mvn wrapper:wrapper -Dtype=only-script ``` -------------------------------- ### Get Maven Distribution URI Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/WrapperExecutor.html Retrieves the Maven distribution URI configured for the wrapper. Returns null if no wrapper meta-data is found. ```java public URI getDistribution() { return config.getDistribution(); } ``` -------------------------------- ### Clone Maven Wrapper Repository (Anonymous) Source: https://maven.apache.org/tools/wrapper/maven-wrapper-distribution/scm.html Use this command to check out the source code anonymously from Git. Ensure you have Git installed and configured. ```bash $ git clone --branch maven-wrapper-3.3.4 https://gitbox.apache.org/repos/asf/maven-wrapper.git ``` -------------------------------- ### DefaultDownloader Constructor Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/DefaultDownloader.html Initializes a new instance of the DefaultDownloader class with the specified application name and version. ```APIDOC ## DefaultDownloader Constructor ### Description Initializes a new instance of the DefaultDownloader class. ### Parameters * **applicationName** (String) - The name of the application. * **applicationVersion** (String) - The version of the application. ``` -------------------------------- ### SystemPropertiesCommandLineConverter Constructor Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/SystemPropertiesCommandLineConverter.html Initializes a new instance of the SystemPropertiesCommandLineConverter class. ```APIDOC ## SystemPropertiesCommandLineConverter() ### Description Initializes a new instance of the SystemPropertiesCommandLineConverter class. ### Constructor `SystemPropertiesCommandLineConverter()` ``` -------------------------------- ### AfterOptions State in CommandLineParser Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/cli/CommandLineParser.html This state is reached after all options have been processed. It does not allow starting new options and adds any subsequent arguments as non-option values. ```java public boolean maybeStartOption(String arg) { return false; } public OptionParserState onStartOption(String arg, String option) { return new UnknownOptionParserState(arg, commandLine, this); } public ParserState onNonOption(String arg) { commandLine.addExtraValue(arg); return this; ``` -------------------------------- ### Test Create Distribution with Always Download True Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/InstallerTest.html Tests distribution creation with 'alwaysUnpack' true, verifying existing files are handled and downloads are simulated. ```java configuration.setAlwaysUnpack(true); Path homeDir = install.createDist(configuration); assertEquals(mavenHomeDir, homeDir); assertTrue(Files.isDirectory(mavenHomeDir)); assertTrue(Files.exists(homeDir.resolve("bin/mvn"))); assertFalse(Files.exists(homeDir.resolve("garbage"))); assertTrue(Files.exists(zipDestination)); assertEquals(localDistribution, pathAssembler.getDistribution(configuration)); assertEquals(distributionDir, localDistribution.getDistributionDir()); assertEquals(zipDestination, localDistribution.getZipFile()); ``` -------------------------------- ### Define Command Line Option Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/cli/CommandLineParser.html Defines a new command-line option. It validates that the option string does not start with a hyphen and that the option is not already defined. ```java public CommandLineOption option(String... options) { for (String option : options) { if (optionsByString.containsKey(option)) { throw new IllegalArgumentException(String.format("Option '%s' is already defined.", option)); } if (option.startsWith("-")) { throw new IllegalArgumentException( String.format("Cannot add option '%s' as an option cannot" + " start with '-'.", option)); } } CommandLineOption option = new CommandLineOption(Arrays.asList(options)); for (String optionStr : option.getOptions()) { this.optionsByString.put(optionStr, option); } return option; ``` -------------------------------- ### Configure Maven Wrapper Distribution URL Source: https://maven.apache.org/tools/wrapper/index.html Modify the `distributionUrl` in `.mvn/wrapper/maven-wrapper.properties` to change the Maven version. This example shows a stable release URL. ```properties distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip ``` -------------------------------- ### Format Command Line Options Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/cli/CommandLineParser.html Formats and prints command-line options with their descriptions. It calculates the maximum width for option keys to align descriptions. ```java String key = join(prefixedStrings, ", "); String value = option.getDescription(); if (value == null || value.length() == 0) { value = ""; } lines.put(key, value); } int max = 0; for (String optionStr : lines.keySet()) { max = Math.max(max, optionStr.length()); } for (Map.Entry entry : lines.entrySet()) { if (entry.getValue().length() == 0) { formatter.format("%s%n", entry.getKey()); } else { formatter.format("%-" + max + "s %s%n", entry.getKey(), entry.getValue()); } } formatter.flush(); ``` -------------------------------- ### PathAssembler.getDistribution Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/PathAssembler.html Determines the local locations for the distribution to use given the supplied configuration. It calculates the directory where the distribution should be installed and the path to the distribution ZIP file. ```APIDOC ## getDistribution ### Description Determines the local locations for the distribution to use given the supplied configuration. ### Method Signature `LocalDistribution getDistribution(WrapperConfiguration configuration)` ### Parameters * `configuration` (WrapperConfiguration) - The wrapper configuration object containing distribution details. ### Returns * `LocalDistribution` - An object containing the paths for the distribution directory and the distribution ZIP file. ### Inner Class: LocalDistribution #### Description Represents the local paths for a Maven distribution. #### Fields * `distDir` (Path) - The directory where the distribution should be installed. * `distZip` (Path) - The path to the distribution ZIP file. #### Methods * `Path getDistributionDir()` - Returns the location to install the distribution into. * `Path getZipFile()` - Returns the location to install the distribution ZIP file to. ``` -------------------------------- ### getPropertyOptionDetailed Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/SystemPropertiesCommandLineConverter.html Retrieves the detailed description of the system property command-line option. ```APIDOC ## getPropertyOptionDetailed() ### Description Retrieves a detailed explanation of the command-line option for system properties. ### Method `protected String getPropertyOptionDetailed()` ### Returns A string containing the detailed description of the system property option. ``` -------------------------------- ### Test Distribution Zip File with Project Base Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/PathAssemblerTest.html Tests the assembly of the distribution zip file path when the base is set to the project directory. ```java @Test void distZipWithProjectBase() throws Exception { configuration.setZipBase(PathAssembler.PROJECT_STRING); configuration.setDistribution(new URI("http://server/dist/maven-1.0.zip")); Path dist = pathAssembler.getDistribution(configuration).getZipFile(); assertThat(dist.getFileName().toString(), equalTo("maven-1.0.zip")); ``` -------------------------------- ### Get Maven Version from pom.properties Source: https://maven.apache.org/tools/wrapper/maven-wrapper-plugin/xref/org/apache/maven/plugins/wrapper/WrapperMojo.html Retrieves the Maven version from the pom.properties file located in the classpath. It falls back to a default version if the property is not found or invalid. ```Java private String getVersion(String defaultVersion, Class clazz, String path) { String version = defaultVersion; if (version == null || version.trim().length() == 0 || "true".equals(version)) { Properties props = new Properties(); try (InputStream is = clazz.getResourceAsStream("/META-INF/maven/" + path + "/pom.properties")) { if (is != null) { props.load(is); version = props.getProperty("version"); } } catch (IOException e) { // noop } } return version; } ``` -------------------------------- ### ProjectPropertiesCommandLineConverter Constructor Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/ProjectPropertiesCommandLineConverter.html Initializes a new instance of the ProjectPropertiesCommandLineConverter class. ```APIDOC ## Constructor ### ProjectPropertiesCommandLineConverter public ProjectPropertiesCommandLineConverter() **Description** Initializes a new instance of the ProjectPropertiesCommandLineConverter class. ``` -------------------------------- ### Get Distribution Type from Maven Wrapper Properties Source: https://maven.apache.org/tools/wrapper/maven-wrapper-plugin/xref/org/apache/maven/plugins/wrapper/WrapperMojo.html Reads the distribution type from the maven-wrapper.properties file if it exists. Returns null if the file is not found or the property is missing. ```java private String distributionTypeFromExistingMavenWrapperProperties(final Path wrapperDir) { final Path mavenWrapperProperties = wrapperDir.resolve(WRAPPER_PROPERTIES_FILENAME); try (InputStream inputStream = Files.newInputStream(mavenWrapperProperties)) { Properties properties = new Properties(); properties.load(inputStream); return properties.getProperty(DISTRIBUTION_TYPE_PROPERTY_NAME); } catch (IOException e) { return null; } } ``` -------------------------------- ### Get Base Name from URI Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/PathAssembler.html Extracts the base file name from a URI. It handles both 'file' scheme URIs and general URIs by parsing the path component. ```java private String getBaseName(URI distUrl) { if (distUrl.getScheme().equals("file")) { return Paths.get(distUrl).getFileName().toString(); } else { return Paths.get(distUrl.getPath()).getFileName().toString(); } } ``` -------------------------------- ### DefaultDownloader Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/allclasses-index.html Default implementation for downloading Maven distributions. ```APIDOC ## Class DefaultDownloader ### Description Represents the default downloader. ### Type Class ``` -------------------------------- ### Help Mojo Source: https://maven.apache.org/tools/wrapper/maven-wrapper-plugin/apidocs/org/apache/maven/plugins/maven_wrapper_plugin/HelpMojo.html Displays help information about the maven-wrapper-plugin. Users can call `mvn wrapper:help -Ddetail=true -Dgoal=` to display parameter details for specific goals. ```APIDOC ## Help Mojo ### Description Displays help information about the maven-wrapper-plugin. Users can call `mvn wrapper:help -Ddetail=true -Dgoal=` to display parameter details for specific goals. ### Method `execute()` ### Parameters #### Query Parameters - **detail** (boolean) - Optional - If true, displays parameter details for goals. - **goal** (string) - Optional - The name of the goal for which to display parameter details. ``` -------------------------------- ### Set Maven User Home Directory Source: https://maven.apache.org/tools/wrapper/index.html Set the `MAVEN_USER_HOME` environment variable to specify a custom base path for Maven distribution installations. By default, it uses `$HOME/.m2`. ```bash export MAVEN_USER_HOME=/path/to/custom/maven/home ``` -------------------------------- ### WrapperExecutor Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/allclasses-index.html Executes the Maven Wrapper, preparing the distribution and launching the bootstrap. ```APIDOC ## Class WrapperExecutor ### Description Wrapper executor, running `Installer` to get a Maven distribution ready, followed by `BootstrapMainStarter` to launch the Maven bootstrap. ### Type Class ``` -------------------------------- ### Helper Method to Get Current Directory Path Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/PathAssemblerTest.html A private helper method to retrieve the current working directory path of the system. This is commonly used for setting up relative paths in tests. ```java private String currentDirPath() { return System.getProperty("user.dir"); } ``` -------------------------------- ### Get Distribution Path Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/PathAssembler.html Calculates the local distribution directory and ZIP file path based on the wrapper configuration. It uses hashing to create unique directory names for different distribution versions. ```java public LocalDistribution getDistribution(WrapperConfiguration configuration) { String baseName = getBaseName(configuration.getDistribution()); String distName = removeExtension(baseName); Path rootDirName = rootDirName(distName, configuration); Path distDir = getBaseDir(configuration.getDistributionBase()) .resolve(configuration.getDistributionPath()) .resolve(rootDirName); Path distZip = getBaseDir(configuration.getZipBase()) .resolve(configuration.getZipPath()) .resolve(rootDirName) .resolve(baseName); return new LocalDistribution(distDir, distZip); } ``` -------------------------------- ### Load Wrapper Metadata from Project Directory Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/WrapperExecutorTest.html Tests loading wrapper configuration by specifying the project's root directory. Assumes the maven-wrapper.properties file is located within the standard Maven wrapper directory structure. ```java @Test void loadWrapperMetadataFromDirectory() throws Exception { WrapperExecutor wrapper = WrapperExecutor.forProjectDirectory(testDir); assertEquals(new URI("http://server/test/maven.zip"), wrapper.getDistribution()); assertEquals( new URI("http://server/test/maven.zip"), wrapper.getConfiguration().getDistribution()); assertEquals("testDistBase", wrapper.getConfiguration().getDistributionBase()); assertEquals( "testDistPath", wrapper.getConfiguration().getDistributionPath().toString()); assertEquals("testZipBase", wrapper.getConfiguration().getZipBase()); assertEquals("testZipPath", wrapper.getConfiguration().getZipPath().toString()); } ``` -------------------------------- ### Helper Method to Prepare WrapperExecutor with Environment Variables Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/WrapperExecutorTest.html A private helper method to create a WrapperExecutor instance that simulates specific environment variables for testing purposes. ```java private WrapperExecutor prepareWrapperExecutorWithEnvironmentVariables( final Map environmentVariables) { return new WrapperExecutor(propertiesFile, new Properties()) { @Override protected String getEnv(String key) { return environmentVariables.get(key); } }; } ``` -------------------------------- ### ProjectPropertiesCommandLineConverter Methods Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/ProjectPropertiesCommandLineConverter.html Methods for retrieving command-line option details related to project properties. ```APIDOC ## Methods ### getPropertyOption protected String getPropertyOption() **Description** Retrieves the command-line option for project properties. **Specified by:** `getPropertyOption` in class `AbstractPropertiesCommandLineConverter` ``` ```APIDOC ### getPropertyOptionDetailed protected String getPropertyOptionDetailed() **Description** Retrieves the detailed command-line option for project properties. **Specified by:** `getPropertyOptionDetailed` in class `AbstractPropertiesCommandLineConverter` ``` ```APIDOC ### getPropertyOptionDescription protected String getPropertyOptionDescription() **Description** Retrieves the description for the project properties command-line option. **Specified by:** `getPropertyOptionDescription` in class `AbstractPropertiesCommandLineConverter` ``` -------------------------------- ### getPropertyOption Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/SystemPropertiesCommandLineConverter.html Retrieves the command-line option for system properties. ```APIDOC ## getPropertyOption() ### Description Retrieves the command-line option used to specify system properties. ### Method `protected String getPropertyOption()` ### Returns A string representing the system property option. ``` -------------------------------- ### WrapperConfiguration.isAlwaysDownload Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/index-all.html Checks if the wrapper is configured to always download the distribution. ```APIDOC ## isAlwaysDownload() ### Description Returns true if the wrapper is configured to always download the distribution. ### Method Method ### Response #### Success Response (boolean) - **boolean** - true if always downloading, false otherwise. ``` -------------------------------- ### Execute Maven Build (Windows) Source: https://maven.apache.org/tools/wrapper/index.html On Windows systems, the `mvnw.cmd` script is used to execute Maven commands with the wrapper. ```bash mvnw.cmd clean install ``` -------------------------------- ### newInstance Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/AbstractPropertiesCommandLineConverter.html Creates a new instance of the properties map. ```APIDOC ## newInstance ### Description Creates a new instance of the properties map. ### Method `newInstance()` ### Returns * `Map` - A new map to hold properties. ``` -------------------------------- ### Test Default Metadata Without Properties File Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/WrapperExecutorTest.html Verifies the default wrapper configuration when no properties file is present. Asserts that distribution and configuration details are null or set to default values. ```java void useDefaultMetadataNoProeprtiesFile() throws Exception { WrapperExecutor wrapper = WrapperExecutor.forProjectDirectory(testDir.resolve("unknown")); assertNull(wrapper.getDistribution()); assertNull(wrapper.getConfiguration().getDistribution()); assertEquals( PathAssembler.MAVEN_USER_HOME_STRING, wrapper.getConfiguration().getDistributionBase()); assertEquals( Installer.DEFAULT_DISTRIBUTION_PATH, wrapper.getConfiguration().getDistributionPath()); assertEquals( PathAssembler.MAVEN_USER_HOME_STRING, wrapper.getConfiguration().getZipBase()); assertEquals( Installer.DEFAULT_DISTRIBUTION_PATH, wrapper.getConfiguration().getZipPath()); } ``` -------------------------------- ### option(String... options) Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/CommandLineParser.html Defines a new command-line option. ```APIDOC ## Method: option(String... options) ### Description Defines a new command-line option. By default, the option takes no arguments and has no description. This method returns the option object, which can be further configured. ### Parameters * `options` (String...) - The string values representing the option (e.g., `"-h"`, `"--help"`). ### Returns * `CommandLineOption` - The newly defined option, which can be further configured. ``` -------------------------------- ### getOptions Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/CommandLineOption.html Retrieves the set of options associated with this command line option. ```APIDOC ## getOptions() ### Description Returns the set of string options associated with this command line option. ### Returns * **Set** - A set containing all the options for this command line option. ``` -------------------------------- ### Internal Download Logic Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/DefaultDownloader.html Handles the actual download process, setting User-Agent, and managing temporary files for atomic move. ```java private void downloadInternal(URI address, Path destination) throws IOException { URL url = address.toURL(); URLConnection conn = url.openConnection(); addBasicAuthentication(address, conn); final String userAgentValue = calculateUserAgent(); conn.setRequestProperty("User-Agent", userAgentValue); Path temp = destination .getParent() .resolve(destination.getFileName() + "." + Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp"); try (InputStream inStream = conn.getInputStream()) { Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING); Files.move(temp, destination, StandardCopyOption.REPLACE_EXISTING); } finally { Files.deleteIfExists(temp); } } ``` -------------------------------- ### convert Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/AbstractPropertiesCommandLineConverter.html Converts parsed command line options into a map of properties. ```APIDOC ## convert ### Description Converts parsed command line options into a map of properties. ### Method `convert(ParsedCommandLine options, Map properties)` ### Parameters * **options** (ParsedCommandLine) - The parsed command line options. * **properties** (Map) - The map to populate with properties. ### Throws * `CommandLineArgumentException` - If there is an error parsing the command line arguments. ``` -------------------------------- ### Maven Wrapper Distribution 'bin' Strategy Structure Source: https://maven.apache.org/tools/wrapper/maven-wrapper-distribution/index.html This structure is used for the 'bin' distribution strategy, where 'maven-wrapper.jar' is provided directly from the project source tree. ```text .mvn/wrapper/maven-wrapper.jar ``` -------------------------------- ### configure Source: https://maven.apache.org/tools/wrapper/maven-wrapper/apidocs/org/apache/maven/wrapper/cli/AbstractPropertiesCommandLineConverter.html Configures the command line parser with options specific to this converter. ```APIDOC ## configure ### Description Configures the command line parser with options specific to this converter. ### Method `configure(CommandLineParser parser)` ### Parameters * **parser** (CommandLineParser) - The command line parser to configure. ``` -------------------------------- ### Configure Basic Authentication Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref/org/apache/maven/wrapper/DefaultDownloader.html Configures default authentication using environment variables for username and password if proxy user is not set. ```java private void configureAuthentication() { if (System.getenv(MVNW_USERNAME) != null && System.getenv(MVNW_PASSWORD) != null && System.getProperty("http.proxyUser") == null) { Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication( System.getenv(MVNW_USERNAME), System.getenv(MVNW_PASSWORD).toCharArray()); } }); } } ``` -------------------------------- ### Create Test Zip File Structure Source: https://maven.apache.org/tools/wrapper/maven-wrapper/xref-test/org/apache/maven/wrapper/InstallerTest.html Helper method to create a dummy zip file for testing purposes. It ensures the parent directory exists and creates placeholder files for the Maven script and core JAR. ```java private void createTestZip(Path zipDestination) throws Exception { Path explodedZipDir = testDir.resolve("explodedZip"); Files.createDirectories(explodedZipDir); Files.createDirectories(zipDestination.getParent()); Path mavenScript = explodedZipDir.resolve("maven-0.9/bin/mvn"); Path mavenLib = explodedZipDir.resolve("maven-0.9/lib/maven-core-0.9.jar"); ``` -------------------------------- ### Maven Wrapper Distribution 'source' Strategy Structure Source: https://maven.apache.org/tools/wrapper/maven-wrapper-distribution/index.html This structure is used for the 'source' distribution strategy, where 'MavenWrapperDownloader.java' is compiled to download 'maven-wrapper.jar' on environments lacking wget or curl. ```text .mvn/wrapper/MavenWrapperDownloader.java ``` -------------------------------- ### WrapperMojo Parameters Source: https://maven.apache.org/tools/wrapper/maven-wrapper-plugin/xref/org/apache/maven/plugins/wrapper/WrapperMojo.html Configuration parameters for the WrapperMojo, including checksums, download behavior, and distribution URL. ```java @Parameter(property = "wrapperSha256Sum") private String wrapperSha256Sum; /** * The expected SHA-256 checksum of the Maven distribution that is * executed by the installed wrapper. * * @since 3.2.0 */ @Parameter(property = "distributionSha256Sum") private String distributionSha256Sum; /** * Determines if the Maven distribution should be downloaded * on every execution of the Maven wrapper. * * @since 3.2.0 */ @Parameter(defaultValue = "false", property = "alwaysDownload") private boolean alwaysDownload; /** * Determines if the Maven distribution should be unpacked * on every execution of the Maven wrapper. * * @since 3.2.0 */ @Parameter(defaultValue = "false", property = "alwaysUnpack") private boolean alwaysUnpack; /** * The URL to download the Maven distribution from. * If not specified, the URL will be constructed based on the Maven version * and repository URL. * * @since 3.3.0 */ @Parameter(property = "distributionUrl") private String distributionUrl; ```