Help Center/ CodeArts Artifact/ Best Practices/ Releasing Maven Components and Archiving to a Self-Hosted Repo
Updated on 2024-11-11 GMT+08:00

Releasing Maven Components and Archiving to a Self-Hosted Repo

Background

CodeArts Artifact focuses on and manages the staging software packages (usually built by or packed from the source code) and their lifecycle metadata. The metadata includes basic properties such as the name and size, repository paths, code branch information, build tasks, creators, and build time. Throughout the development process, the software package is continuously refined across different versions.

The management of software packages and their properties is the basis of release management. Therefore, developers need to regularly review the version history of software packages.

Preparations

Creating a Maven Repository and Associating It with a Project

  1. Log in to the CodeArts homepage and click a card to access a project.
  2. Choose Artifact > Self-hosted Repos from the navigation pane.
  3. Click , select Local Repository as the repository type, enter the repository name, and select Maven as the package type.
  4. Click Submit. The created Maven repository is displayed in the Repository View.
  5. In the Repository View, click the name of the target repository and click Settings.
  6. Click the Project Associations tab, click in the Operation column of the target project, and select target self-hosted repos in the displayed dialog box.
  7. Click OK.

Configuring Component Versions in Repo

  1. Log in to CodeArts and go to a created project.
  2. Choose Services > Repo on the top navigation bar.
  3. Click New Repository.
  4. Select a project from the Project drop-down list, select Template, and click Next.
  5. Search for the Java Maven Demo template, and click Next.
  6. Enter the repository name and click OK.
  7. Go back to Repo and click pom.xml to view the component configuration.

  8. On the component configuration page, the <version> field displays the version number of the current component. The default version number is 1.0.

    Click in the upper right corner of the page to change the version number. Then, click OK to save the changes.

Releasing Maven Components to a Self-Hosted Repo Through CodeArts Build

  1. After configuring the component version in Repo, click Create Build Task in the upper right corner of the page.
  2. Select Blank Template and click OK.
  3. Click Add Build Actions. Search for and add the Build with Maven action.

  4. Edit the Build with Maven action.

    • Select the desired tool version. In this example, maven3.5.3-jdk8-open is used.
    • Find the following command and delete # in front of this command:
      #mvn deploy -Dmaven.test.skip=true -U -e -X -B
      Find the following command and add # in front of this command:
      mvn package -Dmaven.test.skip=true -U -e -X -B
    • Select Configure all POMs under Release to Self-hosted Repos, and select the Maven repository associated with the project.

  5. Click Save and Run on the right of the page to start the build task.

Viewing Archived Components in the Version View of the Maven Repository

  1. Go to the self-hosted repo page, locate the target maven repository, and find the Maven component uploaded by build task.

    Repeat the preceding steps to set the component version in Repo and archive components of multiple versions to self-hosted repos.

  2. Click the Version View tab.

    In the package list, view the number of versions and the latest version of the package obtained from build tasks.

  3. Click a name in the Package Name column. The Overview page for the latest version of the package is displayed.
  4. Click the Files tab, click in the Operation column of the target component to download it to your local host.
  5. After modifying a component and setting a new version number, click Upload in the right of the target self-hosted repo to upload the latest version of the component.

    The package list in the version view displays the latest uploaded version of each component and the number of archived versions.