|0.2.3||Jan 3, 2022|
|0.2.2||Oct 21, 2021|
|0.2.1||Oct 21, 2021|
|0.2.0||Aug 10, 2021|
|0.1.0||Aug 3, 2021|
#785 in Command line utilities
22 downloads per month
Maven Clean Up
mcup /m'kʌp/ (maven clean up) is a command line tool to keep your local maven repository small 📦 and tidy 🧹.
Maven is a great tool to build software for Java and other languages running on the JVM. At its core Maven is a dependency manager which downloads and stores dependencies in a local repository. Over time, this repository grows and takes up more and more space on the hard disk. It often contains obsolete versions or dependencies that are no longer needed.
mcup helps you to clean up your local repository. It uses filters to select artifacts based on the Maven coordinates
version. It knows three modes:
- analyze and report the size of the artifacts selected by the filters
- remove all artifacts selected by the filters and keep the rest
- keep all artifacts selected by the filters and remove the rest
Support for various package managers is wip.
Precompiled binaries are available for Windows, macOS and Linux.
The release binaries are packaged with a man page and shell completion files for bash, fish, zsh, elvish and Powershell. To install them:
- for bash, move
- for fish, move
- for zsh, move
completions/_mcupto one of your
- for elvish, install
- for PowerShell, add
completions/_mcup.ps1to your PowerShell profile.
If you're a Rust programmer, mcup can also be installed using
$ cargo install mcup
mcup [FLAGS] [OPTIONS] <SUBCOMMAND>
-r, --releasesSelects released artifacts only
-s, --snapshotsSelects snapshot artifacts only
-h, --helpPrints help information
-V, --versionPrints version information
-g, --groups <GROUPS>Selects artifacts based on the group ID.
Subgroups are included by default.
Group Selection org All groups starting with 'org' (including 'org') org.wildfly All groups starting with 'org.wildfly' (includes 'org.wildfly) org.wildfly.core All groups starting with 'org.wildfly.core' (includes 'org.wildfly.core')
-a, --artifacts <ARTIFACTS>Selects artifacts based on the artifact ID.
Supports globbing like in
maven-*-plugin(see https://docs.rs/glob/0.3.0/glob/ for more details).
Artifact Selection wildfly-core Artifact 'wildfly-core' only *wildfly* All artifacts containing 'wildfly'
-v, --versions <VERSIONS>Selects artifacts based on version (ranges).
<n>..to select the n most recent versions,
..<n>to select the n oldest versions and
<version>to select one specific version only.
Version Selection 1.. The latest version 5.. The 5 most recent versions ..1 The oldest version ..4 The 4 oldest versions 1.2.3 Version 1.2.3
-l, --local-repository <LOCAL_REPOSITORY>Sets the location of the local maven repository.
mcuprespects the configuration of the local repository according to https://maven.apache.org/guides/mini/guide-configuring-maven.html#configuring-your-local-repository.
The location of the local repository is computed in this order:
- The value of the option
- The value of
- Fall back to
- The value of the option
Disk Usage (
Use this subcommand to analyze the disk usage of the artifacts selected by the filters. The subcommand accepts the same filters as the
rm subcommands, but does not remove any artifacts. Instead, it selects the artifacts matched by the filters and calculates the size of the groups, artifacts and versions.
The subcommand accepts the following options:
-o, --output <OUTPUT>Defines whether (g)roups, (a)rtifacts and (v)ersions are included in the usage summary. Defaults to
See the DU page for more information and sample outputs.
Keep / Remove (
Use one of these subcommands to remove artifacts selected by the filters:
keepKeeps the artifacts matched by the filters and removes the rest
rmRemoves the artifacts matched by the filters and keeps the rest
The subcommands accept the following flags:
-d, --dry-runDoes not remove artifacts
--listPrints the full path to the artifacts that will be removed.
Use this flag together with
--dry-runto review or post-process artifacts that will be removed:
mcup --versions '3..' keep --dry-run --list > artifacts.txt
rm at least one of
--versions is required, where
--snapshots are mutually exclusive.
du has the same semantics as
rm, but doesn't require a filter.
--groups is specified together with any other filter, only artifacts below the matched (sub)groups are
subject to the subcommands (
rm). Artifacts outside the matched (sub)groups won't be touched.
The following table explains the different filter combinations and describes which artifacts are analyzed, kept or removed.
||Analyzes the specified (sub)groups.||Keeps the specified (sub)groups and removes anything else.||Removes the specified (sub)groups.|
||Analyzes the specified artifacts.||Keeps the specified artifacts and removes anything else.||Removes the specified artifacts.|
||Analyzes the specified versions.||Keeps the specified versions and removes anything else.||Removes the specified versions.|
||Analyzes the artifacts matched by the filters below the specified (sub)groups.||Keeps the artifacts matched by the filters below the specified (sub)groups and removes anything else.||Removes the artifacts matched by the filters below the specified (sub)groups and keeps anything else.|
|All other combinations w/o
||Analyzes the artifacts matched by the filters.||Keeps the artifacts matched by the filters and removes anything else.||Removes the artifacts matched by the filters.|
Get a quick overview which groups take the most space
mcup du -og
Show the usage of all artifacts ending with '-build'. Include groups, artifacts and versions in the usage summary.
mcup --artifacts '*-build' du -ogav
Keep the three most recent versions
mcup --versions '3..' keep
Remove the three oldest versions
mcup --versions '..3' rm
Keep the latest releases (doesn't touch snapshots)
mcup --releases --version '1..' keep
Remove all snapshots
mcup --snapshots rm
Remove all artifacts starting with group ID 'edu'
mcup --groups edu rm
Keep the latest maven plugins. Don't remove anything outside group 'org.apache.maven.plugins'
mcup --groups 'org.apache.maven.plugins' --versions '1..' keep
Remove all artifacts (across all groups) starting with 'junit'
mcup --artifacts 'junit*' rm