English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A large software application usually contains multiple modules, and the usual scenario is that multiple teams develop different modules of the same application. For example, imagine a team developing the frontend of the application, with the project as app-ui(app-ui.jar:1).0), while another team is developing the backend of the application, using the project data-service(data-service.jar:1)).
Now it may be the case that development of data-The service team is working on bug fixes or project improvements at a fast pace, and they almost release libraries to the remote repository every other day. Now if data-If the service team uploads a new version every other day, the following issues may arise:
data-The service team must inform the app each time they release updated code.-UI team.
app-The UI team needs to frequently update their pom.xml file to the latest version.
To solve this situation,SnapshotThe concept comes into play.
Snapshot is a special version that specifies a copy of the current development progress. Unlike regular versions, Maven checks for new snapshots in the remote repository each time it builds. Now data-The service team will release updated code snapshots to the repository each time, such as data-[INFO] Downloading data1.0-SNAPSHOT instead of the old snapshot jar package.
For versions, if Maven has previously downloaded the specified version file, such as data-[INFO] Downloading data1.0, Maven will no longer download new available 1.0 file. To download the updated code, data-The version of service needs to be upgraded to1.1.
In the case of snapshot, each app-When the ui team builds their project, Maven will automatically retrieve the latest snapshot (data-[INFO] Downloading data1.0-SNAPSHOT).
app-The ui project uses data-The service project's 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-ui</groupId> <artifactId>app-ui</artifactId> <version>1.0</version> <packaging>jar</packaging> <name>health</name> <url>http://maven.apache.org</url> <properties>UTF-8properties>/<project.build.sourceEncoding>UTF properties>/project.build.sourceEncoding> <dependencies> <dependency> <groupId>data-service</groupId> <artifactId>data-service</artifactId> <version>1.0-SNAPSHOT</version> <scope>test</scope> properties>/dependency> properties>/dependencies> properties>/<
data-The service project is released for each small change 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>data-service</groupId> <artifactId>data-service</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>health</name> <url>http://maven.apache.org</url> <properties>UTF-8properties>/<project.build.sourceEncoding>UTF properties>/project.build.sourceEncoding> properties>/<
project> -Although, in the case of snapshots, Maven will automatically get the latest snapshot in daily work, you can also use it in any maven command
U parameter forces Maven to build the latest snapshot now. -ui>mvn clean package
mvn clean package-Let's open the command console, go to C:\ > MVN > app
ui directory, and then execute the following mvn command.-C:\MVN\app -ui>mvn clean package
U-Maven will download data
After the latest snapshot of service, start building the project. [INFO] ------------------------------------------------------------------- [INFO] Scanning for projects... [INFO] Building consumerBanking-[INFO] task [INFO] ------------------------------------------------------------------- segment: [clean, package]-[INFO] Downloading data1.0-service: [INFO] 29SNAPSHOT 0K downloaded.-[INFO] [clean:clean {execution: default clean}]-[INFO] Deleting directory C:\MVN\app ui\target-[INFO] [resources:resources {execution: default [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory C:\MVN\app-resources}] resources ui\src\main\-[INFO] [compiler:compile {execution: default [INFO] Compiling 1 source file to C:\MVN\app-ui\target\classes [INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory C:\MVN\app-ui\src\test\ resources [INFO] [compiler:testCompile {execution: default}-testCompile}] [INFO] Compiling 1 source file to C:\MVN\app-ui\target\test-classes [INFO] [surefire:test {execution: default}-test}] [INFO] Surefire report directory: C:\MVN\app-ui\target\ surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.companyname.bank.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec Results: Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [jar:jar {execution: default}-jar}] [INFO] Building jar: C:\MVN\app-ui\target\ app-ui-1.0-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Tue Jul 10 16:52:18 IST 2012 [INFO] Final Memory: 16M/89M [INFO] ------------------------------------------------------------------------