Updated on 2024-05-30 GMT+08:00

Configuring the Release to Self-hosted Repos

Configuration Description

By default, CodeArts Build uses the self-hosted repos as the download source of private dependency. The configuration is required for uploading build products to the self-hosted repos and store the build products as dependencies for other projects.

  • Release repo is used to archive software packages for deployment or other purposes.
  • Self-hosted repo is used to store tool packages that other projects depend on.

    Self-hosted Maven repositories are classified into release and snapshot repositories.

    • For private dependency packages released for debugging, add the -SNAPSHOT suffix to the dependency version (for example, 1.0.0-SNAPSHOT). During each release, the dependency is automatically released to the snapshot repository. The version does not need to be updated each time the dependency is released. You can add the -U parameter to the build command to obtain the latest version.
    • For officially released private dependency packages, do not add the -SNAPSHOT suffix to the dependency version (for example, 1.0.0). During each release, the dependency is automatically released to the release repository. The version must be updated each time the dependency is released. Otherwise, the latest dependency package cannot be obtained during the build.

Pay attention to their differences. If you upload a dependency to a release repo, it cannot be downloaded during building.

Procedure

  1. Create a self-hosted repo. (Skip this step if the repository is available.)
  2. Use the Maven template to create a code repository.
  3. Click the name of the code repository. On the Files page that is displayed, configure the self-hosted repo coordinate information (groupId, artifactId, and version) in the pom.xml file.

    Modify the self-hosted project to be built. The coordinates specified in the pom.xml file are as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    <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/maven-v4_0_0.xsd"> 
        <modelVersion>4.0.0</modelVersion> 
        <groupId>come.test.demo</groupId> 
        <artifactId>javaMavenDemo</artifactId> 
        <packaging>jar</packaging> 
        <version>1.0</version> 
        <name>maven_demo</name> 
        <url>http://maven.apache.org</url> 
        <dependencies> 
            <dependency> 
                <groupId>junit</groupId> 
                <artifactId>junit</artifactId> 
                <version>3.8.1</version> 
                <scope>test</scope> 
            </dependency> 
        </dependencies>
    

  4. In the build with Maven action, configure Build with Maven, expand Release to Self-hosted Repos, and select Configure all POMs.

    • Do not configure POM: Private dependencies do not need to be released to the self-hosted repo.
    • Configure all POMs: Deployment configurations are added to all pom.xml files of the project. The mvn deploy command is used to upload the built dependency package to the self-hosted repo.

  5. In the command window, use # to comment out the mvn package -Dmaven.test.skip=true -U -e -X -B command.

  6. Delete # before the #mvn deploy -Dmaven.test.skip=true -U -e -X -B command.

  7. Run the build task. After the execution is successful, the dependency package is released to the self-hosted repo.
  8. In the navigation pane, choose Artifact > Self-hosted Repos. On the displayed page, search for and view the uploaded dependency.

    After the upload is successful, add the following coordinates to other projects for reference.

    1
    2
    3
    4
    5
    <dependency>
        <groupId>com.test.demo</groupId>
        <artifactId>javaMavenDemo</artifactId>
        <version>1.0</version>
    </dependency>