首页 > 其他分享 >无涯教程-Maven - 构建自动化

无涯教程-Maven - 构建自动化

时间:2024-01-18 22:32:19浏览次数:34  
标签:INFO core 教程 bus app 无涯 Maven api ui

Build Automation定义了一种方案,一旦项目构建成功完成,相关项目的构建过程就会开始,以确保相关项目稳定。

考虑一个团队正在开发项目 bus-core-api ,另外两个项目 app-web-ui 和 app-desktop-ui 依赖。

app-web-ui 项目正在使用 bus-core-api 项目的1.0-SNAPSHOT。

<project xmlns = "http://maven.apache.org/POM/4.0.0"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>app-web-ui</groupId>
   <artifactId>app-web-ui</artifactId>
   <version>1.0</version>
   <packaging>jar</packaging>
   <dependencies>
      <dependency>
         <groupId>bus-core-api</groupId>
            <artifactId>bus-core-api</artifactId>
            <version>1.0-SNAPSHOT</version>
      </dependency>
   </dependencies>
</project>

app-desktop-ui 项目正在使用 bus-core-api 项目的1.0-SNAPSHOT。

<project xmlns = "http://maven.apache.org/POM/4.0.0" 
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>app_desktop_ui</groupId>
   <artifactId>app_desktop_ui</artifactId>
   <version>1.0</version>
   <packaging>jar</packaging>
   <name>app_desktop_ui</name>
   <url>http://maven.apache.org</url>
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
   <dependencies>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>3.8.1</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>bus_core_api</groupId>
         <artifactId>bus_core_api</artifactId>
         <version>1.0-SNAPSHOT</version>
         <scope>system</scope>
         <systemPath>C:\MVN\bus_core_api\target\bus_core_api-1.0-SNAPSHOT.jar</systemPath>
      </dependency>
   </dependencies>
</project>

bus-core-api 项目-

<project xmlns = "http://maven.apache.org/POM/4.0.0" 
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>bus_core_api</groupId>
   <artifactId>bus_core_api</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>   
</project>

现在,app-web-ui和app-desktop-ui项目团队要求每当bus-core-api项目更改时,其构建过程就应该开始。使用快照可确保使用最新的bus-core-api项目,但要满足上述要求,无涯教程需要做一些额外的工作。

使用Maven

更新 bus-core-api 项目pom.xml。

<project xmlns = "http://maven.apache.org/POM/4.0.0"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>bus-core-api</groupId>
   <artifactId>bus-core-api</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
   <build>
      <plugins>
         <plugin>
         <artifactId>maven-invoker-plugin</artifactId>
         <version>1.6</version>
         <configuration>
            <debug>true</debug>
            <pomIncludes>
               <pomInclude>app-web-ui/pom.xml</pomInclude>
               <pomInclude>app-desktop-ui/pom.xml</pomInclude>
            </pomIncludes>
         </configuration>
         <executions>
            <execution>
               <id>build</id>
               <goals>
                  <goal>run</goal>
               </goals>
            </execution>
         </executions>
         </plugin>
      </plugins>
   <build>
</project>

让无涯教程打开命令控制台,转到C:\> MVN> bus-core-api目录并执行以下mvn命令。

>mvn clean package -U

Maven将开始构建项目 bus-core-api 。

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------
[INFO] Building bus-core-api
[INFO] task-segment: [clean, package]
[INFO] ------------------------------------------------------------------
...
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\MVN\bus-core-ui\target\
bus-core-ui-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------

成功构建 bus-core-api 后,Maven将开始构建 app-web-ui 项目。

[INFO] ------------------------------------------------------------------
[INFO] Building app-web-ui
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------
...
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\MVN\app-web-ui\target\
app-web-ui-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------

成功构建 app-web-ui 之后,Maven将开始构建 app-desktop-ui 项目。

[INFO] ------------------------------------------------------------------
[INFO] Building app-desktop-ui
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------
...
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\MVN\app-desktop-ui\target\
app-desktop-ui-1.0-SNAPSHOT.jar
[INFO] -------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] -------------------------------------------------------------------

使用集成服务

对于开发人员而言,使用CI Server更可取。每次添加新项目(如,app-mobile-ui)作为 bus-core-api上的从属项目时,不需要更新 bus-core-api 项目。 api 项目。 Hudsion是一个用Java编写的持续集成工具,它在servlet容器中,如Apache tomcat和glassfish应用服务器。 Hudson使用Maven依赖性管理自动管理构建自动化。以下快照将定义Hudson工具的角色。

automated build


在上面的示例中,当在SVN中更新 bus-core-ui 源代码时,Hudson开始其构建。一旦构建成功,Hudson就会自动查找相关项目,并开始构建 app-web-ui 和 app-desktop-ui 项目。

参考链接

https://www.learnfk.com/maven/maven-build-automation.html

标签:INFO,core,教程,bus,app,无涯,Maven,api,ui
From: https://blog.51cto.com/u_14033984/9320809

相关文章

  • 无涯教程-SQLite - 连接Perl
    在本章中,您将学习如何在Perl程序中使用SQLite。安装可以使用PerlDBI模块将SQLite3与Perl集成,该模块是Perl编程语言的数据库访问模块。它定义了一组提供标准数据库接口的方法,变量和约定。以下是在Linux/UNIX计算机上安装DBI模块的简单步骤-$wgethttp://search.cpan.org/CPAN......
  • DrawIO安装及基本使用教程
    1、DrawIO简介DrawIO是一款开源免费且功能强大的绘图工具,可以用于绘制流程图、组织结构图、网络图、UML图等各种类型的图表;DrawIO支持多种文件格式,包括XML、PNG、SVG等,方便用户保存和分享图表;相比起客户端体积庞大的Visio和有免费图表文件数量限制的在线绘图工具Pro......
  • C# 数据类型与类型转换:包含教程与示例
    C#数据类型C#中的变量必须是指定的数据类型:intmyNum=5;//整数(整数)doublemyDoubleNum=5.99D;//浮点数charmyLetter='D';//字符boolmyBool=true;//布尔stringmyText="Hello";//字符串数据类型指定了变量值的......
  • 无涯教程-SQLite - 连接PHP
    在本章中,您将学习如何在PHP程序中使用SQLite。安装从PHP5.3.0起默认启用SQLite3扩展。可以在编译时使用-without-sqlite3禁用它。Windows用户必须启用php_sqlite3.dll才能使用此扩展名。从PHP5.3.0开始,此DLL包含在Windows的PHP发行版中。有关详细的安装说明,请查看无涯教程......
  • C# 数据类型与类型转换:包含教程与示例
    C#数据类型C#中的变量必须是指定的数据类型:intmyNum=5;//整数(整数)doublemyDoubleNum=5.99D;//浮点数charmyLetter='D';//字符boolmyBool=true;//布尔stringmyText="Hello";//字符串数据类型指定了变量值......
  • 无涯教程-SQLite - Autoincrement(自增)
    SQLiteAUTOINCREMENT是用于自动递增表中字段值的关键字,只能与INTEGER字段一起使用。AUTOINCREMENT-语法AUTOINCREMENT关键字的基本用法如下-CREATETABLEtable_name(column1INTEGERAUTOINCREMENT,column2datatype,column3datatype,.....colum......
  • 克魔助手工具详解、数据包抓取分析、使用教程
    摘要本文介绍了克魔助手工具的界面和功能,包括数据包的捕获和分析,以及抓包过滤器的使用方法。同时提供了一些代码案例演示,帮助读者更好地理解和使用该工具。引言克魔助手是一款功能强大的网络抓包工具,可以帮助开发人员进行网络数据包的捕获和分析。它提供了直观的界面和丰富的功......
  • 克魔助手抓包教程:网络数据包分析利器
    摘要本文详细介绍了克魔助手(Komoxo)的下载安装、抓包示例、过滤器使用以及TCP三次握手分析等内容。通过丰富的代码案例演示和详细的操作步骤,帮助读者快速掌握克魔助手的使用方法。引言克魔助手是一款流行的网络封包分析软件,广泛应用于开发测试过程中的网络数据包定位与分析。本......
  • Zoho 的POP、IMAP 和SMTP 设置教程,简单好用
    随着云计算技术的不断发展,越来越多的企业和个人选择使用云端服务来管理和存储电子邮件。Zoho作为一家领先的云服务提供商,其邮件服务备受青睐。本文将介绍如何使用Zoho的POP、IMAP和SMTP设置,并展示其简单而高效的操作方式。1.ZohoSMTP简介ZohoSMTP,即简单邮件传输协议,是一种用于在......
  • 无涯教程-SQLite - NULL语句
    SQLiteNULL是用于表示缺失值的术语,表中的NULL值是显示为空白的字段中的值。NULL-语法以下是在创建表时使用NULL的基本语法。SQLite>CREATETABLECOMPANY(IDINTPRIMARYKEYNOTNULL,NAMETEXTNOTNULL,AGEINTNOTN......