Maven – 项目管理利器
Upcoming SlideShare
Loading in...5
×
 

Maven – 项目管理利器

on

  • 1,836 views

Maven – 项目管理利器

Maven – 项目管理利器

Statistics

Views

Total Views
1,836
Slideshare-icon Views on SlideShare
1,836
Embed Views
0

Actions

Likes
2
Downloads
27
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Maven – 项目管理利器 Maven – 项目管理利器 Presentation Transcript

    • Maven – 项目管理利器
    • Comparation … <property name=&quot;src&quot; location=&quot;src/main/java&quot;/> <property name=&quot;build&quot; location=&quot;target/classes&quot;/> <target name=&quot;compile&quot; depends=&quot;init&quot; description=&quot;compile the source &quot; > <javac srcdir=&quot;${src}&quot; destdir=&quot;${build}&quot;/> </target> … <project> <modelVersion>4.0.0</modelVersion> <groupId>com.kaiqi</groupId> <artifactId>wap</artifactId> <version>1.0</version> </project>
    • … What is it ?
      • Maven 是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model - pom.xml) ,一组标准集合,一个项目生命周期 (Project Lifecycle) ,一个依赖管理系统 (Dependency Management System) ,和用来运行定义在生命周期阶段 (phase) 中插件 (plugin) 目标 (goal) 的逻辑。
    • Maven Features
      • 依赖管理 ( Dependcy Management )
        • 清晰的依赖关系管理
        • 最大程度的实现代码重用
      • 约定优先于配置 ( Convention Over Configuration )
      • 丰富插件资源 ( plugins )
    • Summary Of Tools
      • Builds
      • Documentation
      • Reporting
      • Dependencies
      • SCMs
      • Releases
      • Distribution
      • ……
    • POM – Project Of Model
      • <project >
      • <modelVersion>4.0.0</modelVersion>
      • <groupId>com.kaiqi</groupId>
      • <artifactId>wap</artifactId>
      • <packaging>jar</packaging>
      • <version>1.0‐SNAPSHOT</version>
      • <name>simple</name>
      • <url>http://maven.apache.org</url>
      • <dependencies>
      • <dependency>
      • <groupId>junit</groupId>
      • <artifactId>junit</artifactId>
      • <version>3.8.1</version>
      • <scope>test</scope>
      • </dependency>
      • </dependencies>
      • </project>
    • Maven Plugins and Goals
      • mvn archetype:create -DgroupId=com.kaiqi - DarticleId=example
      • 插件( Plugin ) archetype
      • 目标 ( Goals ) create
    • Maven Lifecycle Mvn package mvn resources:resources compiler:compile resources:testResources compiler:testCompile surefire:test jar:jar
    • Maven Coordinates
      • <project >
      • <modelVersion>4.0.0</modelVersion>
      • <groupId>com.kaiqi</groupId>
      • <artifactId>wap</artifactId>
      • <packaging>jar</packaging>
      • <version>1.0‐SNAPSHOT</version>
      • <name>simple</name>
      • <url>http://maven.apache.org</url>
      • <dependencies>
      • <dependency>
      • <groupId>junit</groupId>
      • <artifactId>junit</artifactId>
      • <version>3.8.1</version>
      • <scope>test</scope>
      • </dependency>
      • </dependencies>
      • </project>
      坐标
    • Maven Repositories
      • 本地仓库 ( Local repository )
        • setting.xml 可配置路径
        • Maven install 可安装本地仓库
      • 远程仓库 ( Remote repository)
        • Maven deploy
        • Maven release : perform
    • Maven Dependency Management
      • 通过坐标依赖
      • 依赖具有传递性
      [INFO] com.kaiqi:wap-game:war:1.1-SNAPSHOT [INFO] +- com.kaiqi:wap-service:jar:1.1-SNAPSHOT:compile [INFO] | +- com.kaiqi:wap-dao:jar:1.1-SNAPSHOT:compile [INFO] | | +- org.hibernate:hibernate-validator:jar:3.1.0.GA:compile [INFO] | | | +- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile [INFO] | | | | +- antlr:antlr:jar:2.7.6:compile [INFO] | | | | - javax.transaction:jta:jar:1.1:compile [INFO] | | | - org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile [INFO] | | +- org.slf4j:slf4j-log4j12:jar:1.5.8:compile [INFO] | | +- org.slf4j:slf4j-api:jar:1.5.8:compile [INFO] | | +- javax.persistence:persistence-api:jar:1.0:compile [INFO] | | - org.apache.ibatis:ibatis-sqlmap:jar:2.3.4.726:compile
    • Version Management Tag 1.0 2.0 branch 1.0.1 Trunk 1.0.1 branch 1.0.2 1.0.2 Maven 版本规则 < 主版本 >.< 次版本 >.< 增量版本 >
    • Why using SNAPSHOT? TMD ,用的不是我最新代码,当然不行。 靠,你的程序编译不过去啊! Fighting Before Now 每次代码更新都 mvn deploy 。 现在用的快照版本,肯定是最新代码。
    • SCMs with Maven
      • 从 1.0-SNAPSHOT 到 1.1-SNAPSHOT
      • pom.xml 里添加 svn 地址
      • Mvn release:prepare
        • 将 snapshot1.0 升级为正式版 1.0
        • 正式版 1.0 提交到 svn ,打 tag1.0
        • 生成 snapshot1.1 开发版本
        • 开发版本 snapshot1.1 提交到 trunk 中
      • Mvn relese:perform
        • 从 tag1.0 中 check 出代码
        • 打包发布到远程仓库中
      <scm> <connection>scm:svn:http:// svn.kaiqi.com /svn/wap/trunk/</connection> <developerConnection>scm:svn:https://svn.kaiqi.com/svn/wap/trunk/</developerConnection> </scm>
    • Make a branch with Maven
      • mvn release:branch -DbranchName=1.1.x -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
        • 1.0-SNAPSHOP 升级成 1.0.1-SNAPSHOT
        • 开发版本 1.0.1-SNAPSHOT 提交到 Branches 中
    • KaiQi-WAP Tech Team
      • 项目模块化,减少重复劳动
      • 做好版本控制,每次 release 记录版本变化
      • 充分利用分支,避免旧版本有 bug 无法修复
      • 全程自动化,减少人为错误操作
      • 确保数据一致性,提高服务质量
    • Just Do It!
      • 创建工程
      • 打包
      • Install
      • Deploy
      • Release
      • Branch
      • Q&A