For faster navigation, this Iframe is preloading the Wikiwand page for Apache Maven.

Apache Maven

Apache Maven
開發者Apache软件基金会
当前版本
  • 3.9.7 (2024年5月22日;穩定版本)[1][2]
編輯維基數據鏈接
源代码库 編輯維基數據鏈接
编程语言Java
操作系统跨平台
类型构建自动化
许可协议Apache许可证 2.0
网站maven.apache.org(英文)
Maven中心仓库中的组建数目呈指数级增长

Apache Maven,是一个软件(特别是Java软件)项目管理自动构建工具,由Apache软件基金会所提供。Maven也可被用于构建和管理各种项目,例如C#RubyScala和其他语言编写的项目。Maven曾是Jakarta项目的子项目,现为由Apache软件基金会主持的独立Apache项目。

Maven解决了软件构建的两方面问题:一是软件是如何构建的,二是软件的依赖关系。不同于Apache Ant等早期工具,Maven设定了构建流程的标准,在此之外只需要指定例外情况。XML文件描述了正在构建的软件项目、它对其他外部模块和组件的依赖关系、构建顺序、目录和所需的插件。该文件通常有预设的目标任务,例如代码编译和打包。Maven从一个或多个代码仓库(例如Maven 2 Central Repository)动态地下载Java库与Maven插件,并将其存储在本地缓存区中[3]

Maven是以基于插件的架构构建的,这使其能够使用任何能用标准输入控制的应用程序。Maven 2同时维护了为C/C++准备的原生插件[4]

尽管Gradlesbt等替代技术并不依赖于XML,但他们仍然保留了Maven引入的关键概念。Apache Ivy还开发了一个专用的依赖管理器,同时支持Maven仓库[5]

Apache Maven也包括对可重现构建的支持[6][7]

示例

Maven项目使用项目对象模型(Project Object Model,POM)来配置。

项目对象模型存储在名为 pom.xml 的文件中。

以下是一个简单的示例:

<project>
  <!-- model version is always 4.0.0 for Maven 2.x POMs -->
  <modelVersion>4.0.0</modelVersion>
  
  <!-- project coordinates, i.e. a group of values which
       uniquely identify this project -->
  
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0</version>

  <!-- library dependencies -->
  
  <dependencies>
    <dependency>
    
      <!-- coordinates of the required library -->
      
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      
      <!-- this dependency is only used for running and compiling tests -->
      
      <scope>test</scope>
      
    </dependency>
  </dependencies>
</project>

参见

补充阅读

有免费的PDF供下载和在线阅读:http://www.sonatype.com/documentation/books(页面存档备份,存于互联网档案馆(英文)

參考資料

  1. ^ https://maven.apache.org/docs/3.9.7/release-notes.html.
  2. ^ "Release Notes - Maven 3.9.7".
  3. ^ Index of /maven2/. [2009-04-15]. (原始内容存档于2018-09-17). 
  4. ^ Laugstol, Trygve. MojoHaus Native Maven Plugin. [2022-07-26]. (原始内容存档于2016-10-29). 
  5. ^ IBiblio Resolver | Apache Ivy™. [2022-07-26]. (原始内容存档于2021-06-16). 
  6. ^ Reproducible/Verifiable Builds - Apache Maven - Apache Software Foundation. cwiki.apache.org. [2022-07-26]. (原始内容存档于2022-07-26). 
  7. ^ Reproducible Builds in Java - DZone Java. dzone.com. [2022-07-26]. (原始内容存档于2021-05-06). 

外部链接

{{bottomLinkPreText}} {{bottomLinkText}}
Apache Maven
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?