I recommend using Maven’s central repository for publishing, but I’m using Github because it’s too cumbersome and requires review. To publish a central repository, refer to Maven to publish your own projects to the Maven central repository
Use Github to install or deploy to a local path, then git add && commit && push, or maven-plugins
Both solutions need to create the corresponding REPO on Github. The specific creation steps are not detailed.
1. maven-plugins
Reference stackoverflow.com/a/14013645
1. Modify the ~ /. M2 / Settings. The XML
<! --NOTE: MAKE SURE THAT settings.xml IS NOT WORLD READABLE! -->
<settings>
<servers>
<server>
<id>github</id>
<username>YOUR-USERNAME</username>
<password>YOUR-PASSWORD</password>
</server>
</servers>
</settings>
Copy the code
2. Modified pom. XML
<properties>
<! -- github server corresponds to entry in ~/.m2/settings.xml -->
<github.global.server>github</github.global.server>
</properties>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
</plugins>
</build>
Copy the code
3. Modify pom. XML and configure Maven-plugins
<build>
<plugins>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>Maven artifacts for ${project.version}</message> <! -- git commit message -->
<noJekyll>true</noJekyll> <! -- disable webpage processing -->
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory> <! -- matches distribution management repository url above -->
<branch>refs/heads/master</branch> <! -- remote branch name -->
<includes><include>/ * * *</include></includes>
<repositoryName>YOUR-REPOSITORY-NAME</repositoryName> <! -- github repo name -->
<repositoryOwner>YOUR-GITHUB-USERNAME</repositoryOwner> <! -- github username -->
<force>false</force> <! -- force commit or no -->
<merge>true</merge> <! -- merge or no -->
</configuration>
<executions>
<! -- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
Copy the code
4. Submit to Github
mvn clean deploy
Copy the code
2. mvn deploy && git add && commit && push
Reference blog.csdn.net/u010442302/…
1.clone github repo
git clone https://github.com/YOUR-USERNAME/YOUR-PROJECT-NAME /home/my/code/maven-repo/
Copy the code
2. Run the MVN deploy command
mvn deploy -DaltDeploymentRepository=my-mvn-repo::default::file:/home/my/code/maven-repo/
Copy the code
3. Push to making
cd /home/my/code/maven-repo/
git add .
git commit -m 'the Maven artifacts for 0.0.1'
git push -u origin master
Copy the code
3. Use the Github repO in your project
<repositories>
<repository>
<id>YOUR-PROJECT-NAME-mvn-repo</id>
<url>https://raw.githubusercontent.com/YOUR-USERNAME/YOUR-PROJECT-NAME/master/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
Copy the code
conclusion
If you can modify the POM, use maven-plugins. If you cannot modify the POM, use MVN to deploy&&git add&&commit&&push