Class MavenWrapper
.mvn/wrapper/maven-wrapper.propertiesmvnw(POSIX launcher — must be LF; executable bit set)mvnw.cmd(Windows launcher — must be CRLF on Windows; see.gitattributes*.cmd text eol=crlfrule)
The mvnw / mvnw.cmd scripts are the standard
Apache Maven Wrapper launchers, vendored verbatim as plugin
resources under wrapper/. The only-script distribution
type is used — the scripts download Maven themselves, so no
maven-wrapper.jar binary is committed to a workspace repo.
The properties file carries the standard wrapperVersion,
distributionType, and distributionUrl keys, which is
what IDEs (IntelliJ) key on to auto-adopt the wrapper.
Used by ws:scaffold-init when scaffolding a new workspace,
and by ScaffoldConventionReconciler's mvnw step (run
as part of ws:scaffold-publish) — both to fill in missing
files and to replace the legacy custom "minimal bootstrap" wrapper
that earlier plugin versions generated (IKE-Network/ike-issues#405).
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisLegacyWrapper(Path wsDir) Report whether the workspace carries the legacy custom "minimal bootstrap"mvnwthat pre-standardization plugin versions generated.static StringreadPinnedVersion(Path wsDir) Read the pinned Maven version from an existing.mvn/wrapper/maven-wrapper.properties, or return null if the file does not exist or no version can be determined.static voidUnconditionally (re)write all three wrapper files, overwriting any that already exist.static intwriteMissingFiles(Path wsDir, String mavenVersion) Install any of the three wrapper files that are missing from the given workspace directory.static voidwriteMvnwCmdScript(Path mvnwCmd) Write the standard Apache Windowsmvnw.cmdlauncher script.static voidwriteMvnwScript(Path mvnw) Write the standard Apache POSIXmvnwlauncher script and mark it executable.static voidwritePropertiesFile(Path propsFile, String mavenVersion) Writemaven-wrapper.propertiesin the standardonly-scriptform for the given Maven version.
-
Field Details
-
WRAPPER_VERSION
Apache Maven Wrapper version of the vendoredmvnw/mvnw.cmdscripts. Written intowrapperVersionof the generatedmaven-wrapper.properties.- See Also:
-
DISTRIBUTION_TYPE
Wrapper distribution type.only-scriptkeeps the wrapper jar-free — the launcher scripts download Maven directly.- See Also:
-
-
Method Details
-
writeMissingFiles
Install any of the three wrapper files that are missing from the given workspace directory. Never overwrites an existing file — the user may have pinned a specific version inmaven-wrapper.propertiesor customized the launcher scripts. To replace a legacy wrapper in full, usewriteAll(Path, String).- Parameters:
wsDir- workspace rootmavenVersion- Maven version to write intomaven-wrapper.propertieswhen creating it- Returns:
- the number of files created (0 when all three already exist)
- Throws:
IOException- if writing any of the files fails
-
writeAll
Unconditionally (re)write all three wrapper files, overwriting any that already exist. Used to replace the legacy custom wrapper with the standard one — seeisLegacyWrapper(Path).- Parameters:
wsDir- workspace rootmavenVersion- Maven version to write intomaven-wrapper.properties- Throws:
IOException- if writing any of the files fails
-
isLegacyWrapper
Report whether the workspace carries the legacy custom "minimal bootstrap"mvnwthat pre-standardization plugin versions generated. Detected by theminimal bootstrapmarker in the script header — the standard Apache launcher does not carry it, and neither would a user's own hand-writtenmvnw.- Parameters:
wsDir- workspace root- Returns:
- true when
mvnwexists and is the legacy custom launcher; false when absent, standard, or user-authored - Throws:
IOException- ifmvnwexists but cannot be read
-
readPinnedVersion
Read the pinned Maven version from an existing.mvn/wrapper/maven-wrapper.properties, or return null if the file does not exist or no version can be determined.The version is parsed from the standard
distributionUrlkey. A legacy wrapper's explicitmaven.versionkey is used as a fallback so that migrating an old workspace preserves its pinned version.- Parameters:
wsDir- workspace root- Returns:
- the pinned Maven version, or null when not determinable
- Throws:
IOException- if the properties file exists but cannot be read
-
writePropertiesFile
Writemaven-wrapper.propertiesin the standardonly-scriptform for the given Maven version. Creates the parent directory as needed. Overwrites any existing file.- Parameters:
propsFile- target path (typically.mvn/wrapper/maven-wrapper.properties)mavenVersion- Maven version (e.g.4.0.0-rc-5)- Throws:
IOException- if writing fails
-
writeMvnwScript
Write the standard Apache POSIXmvnwlauncher script and mark it executable. The script readsdistributionUrlfrom.mvn/wrapper/maven-wrapper.propertiesat runtime and downloads Maven on first use. Overwrites any existing file.- Parameters:
mvnw- target path (typicallymvnwat workspace root)- Throws:
IOException- if writing fails
-
writeMvnwCmdScript
Write the standard Apache Windowsmvnw.cmdlauncher script. The workspace.gitattributes*.cmd text eol=crlfrule is what keeps this file usable on Windows after checkout — without it, cmd.exe chokes on LF line endings (IKE-Network/ike-issues#189). Overwrites any existing file.- Parameters:
mvnwCmd- target path (typicallymvnw.cmdat workspace root)- Throws:
IOException- if writing fails
-