The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Maven

Last updated: 2026-04-03 17:18:21
This document describes how to store Maven artifacts in CODING-AR, including how to create a repository and push and pull artifacts.
Note:
To read this document, prepare the following:
<Basic Operations>—Create a project.
Select Maven as the repository type.
The Maven repository type supports three file formats: Apache Maven, Gradle Groovy, and Gradle Kotlin DSL.




Configure Authentication Information

Before pushing or pulling Maven artifacts, you need to configure authentication information. Click in the operation guide Generate a personal token as credentials and add it to the settings.xml file.




Compile and Upload a Maven Artifact

This section describes how to push a demo Maven package to the repository created above.



1. On the repository guide page, copy the following configuration into the project's pom.xml file.



Generally, groupId, artifactId, and version configurations already exist for a Maven project. You only need to add distributionManagement to it.



2. Run the mvn deploy command.
mvn deploy
If the settings.xml file is not found, add the -s parameter at the end of the command to specify the path where you place the settings file. With the parameter added:
mvn deploy -s "/Users/somebody/software/apache-maven-3.6.2/conf/settings.xml"
3. After the mvn command prompts 'build success', refresh the artifact repository page to see the latest artifacts.

Upload a Maven Package Without Source Code

If a third-party Maven package is not officially released to a repository and only a JAR package is provided without source code, you can upload the JAR package to the repository by running the following command:
mvn deploy:deploy-file -Durl=file://C:\m2-repo \
-DrepositoryId=some.id \
-Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=test] \
[-DgeneratePom=true] \
[-DgeneratePom.description="My Project Description"] \
[-DrepositoryLayout=legacy]
If a third party provides pom.xml, you can extract the group, artifact, and version fields from it. For example, use the following command for the WeChat CPay Java SDK:
mvn deploy:deploy-file --settings ./settings.xml -Durl=https://coding-public-maven.pkg.coding.net/repository/tencent-cloud-pay-sdk-java/tencent/ \
-DrepositoryId=coding-public-tencent-cloud-pay-sdk-java-tencent \
-Dfile=../cloudpay.jar \
-DpomFile=pom.xml

WeChat CPay Java SDK settings.xml


WeChat CPay Java SDK jar upload page.

WeChat CPay Java SDK jar upload



Pull Maven Artifact

1. On the guide page, copy the configuration to settings.xml. For example, the configuration for the WeChat CPay Java SDK is as follows:
<settings>
<!-- omitted xml -->
<profiles>
<profile>
<id>Repository Proxy</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>coding-public-tencent-cloud-pay-sdk-java-tencent</id>
<name>tencent</name>
<url>https://coding-public-maven.pkg.coding.net/repository/tencent-cloud-pay-sdk-java/tencent/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
2. Configure the dependencies in the pom.xml file of your Java project. For example, for the WeChat CPay Java SDK, the configuration is as follows:
<project>
<dependencies>
<dependency>
<groupId>com.tencent</groupId>
<artifactId>cloudpay</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
</project>
3. Compile the project.
mvn install -s ./settings.xml
You can view the package is being pulled during the execution. Alternatively, view the pulled package in the local maven cache after the execution is completed.