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.
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:
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:
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:
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.