Project Icon

mcs

命令行快速搜索Maven中央仓库的开源工具

mcs是一个开源的命令行工具,用于在Maven中央仓库中快速搜索依赖坐标。它支持通配符、坐标和类名搜索,提供多种输出格式,并可显示安全漏洞信息。mcs支持主流操作系统,可通过多种包管理器安装。此外,它还提供自定义信任存储和代理设置功能,适应各种开发环境。

Maven Central Search

Build status Mutation testing badge Snapcraft.io status

Use Maven Central Repository Search from your command line!

Use mcs to quickly lookup dependency coordinates in Maven Central, without having to switch to your browser.

Usage

This tool supports the following modes of searching:

  1. Wildcard search

    mcs search plexus-utils
    

    This will give you all artifacts in Maven Central that have "plexus-utils" in their name. The output is in a tabular form, showing the exact coordinate of each artifact and the moment when its latest version was deployed.

  2. Coordinate search

    mcs search org.codehaus.plexus:plexus-utils
    mcs search org.codehaus.plexus:plexus-utils:3.4.1
    

    If there are multiple hits, you will get the same table output as above. But if there's only one hit, this will give you by default a pom.xml snippet for the artifact you searched for. Ready for copy & paste in your favourite IDE!
    If you require snippet in different format, use -f <type> or --format=<type>. Supported types are: maven, gradle, gradle-short, gradle-kotlin, sbt, ivy, grape, leiningen, buildr, jbang, gav.

  3. Class-name search

    mcs class-search CommandLine
    mcs class-search -f picocli.CommandLine
    

    This will give you all artifacts in Maven Central that contain a particular class. If you set the -f flag, the search term is considered a "fully classified" class name, so including the package name.

Flags

  • All modes recognise the -l <number> switch, which lets you specify how many results you want to see at most.
  • In Wildcard sarch and Coordinate search, you can pass along the -s (or --show-vulnerabilities) flag. It will cause MCS to show a summary of reported security vulnerabilities against each result. If there is only one search result, it will display the CVE numbers reported against that result. Note that this feature will probably soon hit the API limits for the Sonatype OSS Index. See their documentation for details on how this may impact your usage. You can specify your credentials using the system properties ossindex.username and ossindex.password. See under "Configuring MCS" on how to do this in the most convenient way.

Installation

You can install mcs using the package manager of your choice:

Package managerPlatformInstallationRemarks
Homebrew🍎 🐧brew install mthmulders/tap/mcs⚠️ 1
Snap🐧snap install maven-central-search
SDKMAN!🍎 🐧sdk install mcs
Chocolatey🪟choco install mcs
Scoop🪟scoop install mthmulders/mcs
  1. The Linux binaries only work on x86_64 CPU's. There Apple binaries for both x86_64 and Apple Silicon, so you don't need Rosetta.

Usage with custom trust store

In certain situations, such as when you work behind a TLS-intercepting (corporate) firewall, MCS may fail with

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

In layman's speak: the default, built-in trust store (the set of trusted X.509 certificates) does not contain anything that allows to trust the certificate(s) presented by the server. Maven Central uses a certificate that would've been trusted, but the culprit here is the TLS-intercepting (corporate) firewall that presents an internal certificate.

The solution is to create a trust store that has the "highest" certificate in the certificate chain, e.g. that of the (internal) certificate authority. You can use a tool like Portecle to create such a trust store. Next, point MCS to that trust store like so

mcs -Djavax.net.ssl.trustStore=/path/to/keystore search something

Usage Behind a Proxy

If you are running behind a proxy, MCS will respect the HTTP_PROXY and HTTPS_PROXY environment variables.

Configuring MCS

Some configuration for MCS is passed through system properties. You can do this every time you invoke MCS by adding -Dxxx=yyy. To make it more conveniently, you can create a configuration file that will automatically be read by MCS and interpreted as configuration settings.

To do so, create a directory .mcs in your user directory (typically C:\Users<your-user-name> on 🪟, /home/ on 🐧 or /Users/ on 🍎). Inside that folder, create a file mcs.config and write the following line in it:

javax.net.ssl.trustStore=/path/to/keystore
ossindex.username=xxx
ossindex.password=yyy

This way, you don't have to remember passing the -D.

Contributing

Probably the easiest way to get a working development environment is to use Gitpod:

Open in Gitpod

It will configure a workspace in your browser and show that everything works as expected by running mvn verify. This setup does not touch your computer - as soon as you close your browser tab, it's gone.

Checkout the issues if you're looking for something to work on. If you have a new idea, feel free to bring it up using the discussions.

Acknowledgements

  • Andres Almiray did a great job helping me set up JReleaser to make releasing mcs a real breeze!
  • Martin Goldhahn shared the idea of searching on class name, and provided some initial API and design ideas for this great feature.
  • Willem van Lent contributed a fix for a parameter whose name didn't match its behavior.
  • Hanno Embregts contributed a fix that makes it more clear why the results are truncated.
  • Jan Wedel contributed an improvement that lets MCS pick up the HTTP proxy environment variables.
项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

白日梦AI

白日梦AI提供专注于AI视频生成的多样化功能,包括文生视频、动态画面和形象生成等,帮助用户快速上手,创造专业级内容。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

讯飞绘镜

讯飞绘镜是一个支持从创意到完整视频创作的智能平台,用户可以快速生成视频素材并创作独特的音乐视频和故事。平台提供多样化的主题和精选作品,帮助用户探索创意灵感。

Project Cover

讯飞文书

讯飞文书依托讯飞星火大模型,为文书写作者提供从素材筹备到稿件撰写及审稿的全程支持。通过录音智记和以稿写稿等功能,满足事务性工作的高频需求,帮助撰稿人节省精力,提高效率,优化工作与生活。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号