May 26, 2021 Maven
In general, in an engineering development process, the process of deploying at once requires the following steps:
Typically, there will be many different people involved in the above deployment process. O ne team can be responsible for the code's joining, the other can be responsible for building, and so on. A ny of these steps may not have been performed for human reasons. For example, older versions are not updated on network machines, and the team responsible for deployment has once again deployed older versions.
Automate deployment by combining:
We'll use the plug-ins published by Maven to create an automated publishing process:
For example: the POM of the bus-core-api .xml as follows
<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>
<scm>
<url>http://www.svn.com</url>
<connection>scm:svn:http://localhost:8080/svn/jrepo/trunk/
Framework</connection>
<developerConnection>scm:svn:${username}/${password}@localhost:8080:
common_core_api:1101:code</developerConnection>
</scm>
<distributionManagement>
<repository>
<id>Core-API-Java-Release</id>
<name>Release repository</name>
<url>http://localhost:8081/nexus/content/repositories/
Core-Api-Release</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<goals>deploy</goals>
<scmCommentPrefix>[bus-core-api-release-checkin]-<
/scmCommentPrefix>
</configuration>
</plugin>
</plugins>
</build>
</project>
In pom .xml, the important elements we often use are the following table:
Elements | Describe |
---|---|
Scm | Configure the path to the SVN from which Maven will remove the code. |
Warehouse | The path to storage of the successfully built WAR/EAR/JAR or other build results. |
Plug - ins | maven-release-plugin is used to automate the deployment process. |
Maven uses maven-release-plugin to perform the following useful tasks:
mvn release:clean
Clean up the workspace to ensure that the latest release process is successful.
mvn release:rollback
Rolling back the modified workspace code and configuration ensures that the release process is successful.
mvn release:prepare
Do the following several times:
mvn release:perform
Switch the code to a previously marked place, run the Maven deployment target to deploy the WAR file, or build the appropriate structure into the warehouse.
Open the command terminal and go to C: Under the MVN and bus-core-api directory, then execute the following mvn command.
C:\MVN\bus-core-api>mvn release:prepare
Maven began to build the entire project. Once the build is complete, you can run the following mvn command.
C:\MVN\bus-core-api>mvn release:perform
Once the build is successful, you can verify that the JAR file uploaded under your repository is in effect.