หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ CodeArts Build/ Best Practices/ Building with Maven to Generate a Private Dependency for Another Build (Built-in Executors, GUI)

Building with Maven to Generate a Private Dependency for Another Build (Built-in Executors, GUI)

Updated on 2024-11-21 GMT+08:00

Scenario

In this practice, you upload the artifact of a Maven build project to a self-hosted repo and include it as a second-party or third-party dependency within another Maven build project, which then downloads and uses this artifact to build an application in CodeArts Build. You will need:

  • dependency_task: This build project releases the resulting dependencyProject-1.0.jar package defined in the pom.xml file to the self-hosted repo. The package will be used for build project release_task.
  • release_task: This build project looks for the dependencyProject-1.0.jar package released by build project dependency_repo in the self-hosted repo, includes the package as a dependency in the build process, and releases the final application.
  • dependency_libs: This self-hosted repo stores the dependencyProject-1.0.jar package released by build project dependency_task. Build project release_task will download the package from this repo.

    These steps depend on the following services:

Requirements

  • You have permissions for CodeArts Artifact.
  • You have permissions for CodeArts Repo.

Procedure

Table 1 Steps

Step

Description

Creating a Project

Create a project.

Creating a Self-hosted Repo

Create a self-hosted repo.

Creating Code Repository dependency_repo

Create the code repository for releasing the dependencyProject-1.0.jar package.

Creating Build Task dependency_task

Create the build task for releasing the dependencyProject-1.0.jar package.

Creating Code Repository release_repo

Create a code repository for releasing the application.

Creating Build Task release_task

Create the build task that depends on the dependencyProject-1.0.jar package to build and release the application.

Viewing the Build Results

Verify the build results.

Creating a Project

  1. Log in to the Huawei Cloud console with your Huawei Cloud account.
  2. Click in the upper left corner and choose Developer Services > CodeArts from the service list.
  3. Click Access Service. The homepage of CodeArts is displayed.
  4. Click Create Project, and select the Scrum template.
  5. Set the project name to build-bestpractice, and leave the other parameters as default.
  6. Click OK to access the project.

Creating a Self-hosted Repo

  1. In the navigation pane, choose Artifact > Self-hosted Repos.
  2. Click Create and set parameters according to Table 2.

    Table 2 Parameters for creating a self-hosted repo

    Parameter

    Description

    Repository Type

    Select Local Repository.

    Repository Name

    Assign a custom name to the repository, for example, dependency_libs.

    Package Type

    Select Maven.

    Project

    Leave the value as default. The field is autofilled with build-bestpractice in this practice.

    Include Patterns

    Leave it blank.

    Version Policy

    Specify the version of artifacts stored in the repository. Select either Release (the release version with stable functions) or Snapshot (the development version with unstable functions). You can also select both of them if needed. In this practice, select Release.

    Description

    Enter additional information to describe the repository. Use no more than 200 characters.

  3. Click Submit. The details page of dependency_libs is displayed. Figure 1 shows the created self-hosted repo.

    Figure 1 Self-hosted repo

Creating Code Repository dependency_repo

  1. In the navigation pane, choose Code > Repo.
  2. On the displayed page, click New Repository. Select Template, and click Next.
  3. On the template selection page, select the Java Maven Demo template and click Next.
  4. On the repository creation page, type dependency_repo in the Repository Name field, and leave the other parameters as default.
  5. Click OK. The code repository details page is displayed. Figure 2 shows the directory that stores files of the code repository.

    Figure 2 Directory

  6. Click the pom.xml file to enter its details page. In the right pane, Click to access the file editor.

    Figure 3 Editing the pom.xml file

  7. Change groupId to com.huawei.dependency, artifactId to dependencyProject, and name to dependency_project, as shown in Figure 4. Click OK to save your changes to the pom.xml file.

    Figure 4 Modifying the pom.xml file

Creating Build Task dependency_task

  1. In the navigation pane, choose CICD > Build.
  2. Click Create Task. On the displayed Basic Information page, set the following parameters. Leave the other parameters as default.

    • Name: Assign a custom name to the build task, for example, private_repository_task.
    • Code Source: Select Repo.
    • Repository: Select private_repository_repo, the code repository created in Creating Code Repository dependency_repo.

  3. Click Next. On the displayed page, select Blank Template. Click OK. The Build Actions page is displayed.
  4. On the Build Actions page, click the GUI tab. Then click Add Build Actions on the left and add the Build with Maven action.
  5. Click the Build with Maven action, and set the following parameters. Leave the other parameters as default.

    • Commands: Add a number sign (#) before the mvn package -Dmaven.test.skip=true -U -e -X -B command and delete the number sign before the #mvn deploy -Dmaven.test.skip=true -U -e -X -B command.
    • Release to Self-hosted Repos: Select Configure all POMs.
    • Release: Select the name (dependency_libs is used in this practice) of the created self-hosted repo.
      Figure 5 Configuring the action of building with Maven

  6. Click Save and Run in the upper right corner. In the displayed dialog box, click Confirm. The build task run page is displayed.
  7. After the build task is complete, check the build products. In the navigation pane, choose Artifact > Self-hosted Repos. On the displayed page, expand the directory of dependency_libs (Release) to check the released dependencies as build outputs, as shown in Figure 6.

    Figure 6 Checking dependencies

Creating Code Repository release_repo

  1. In the navigation pane, choose Code > Repo.
  2. On the displayed page, click New Repository. Select Template, and click Next.
  3. On the template selection page, select the Java Maven Demo template and click Next.
  4. On the repository creation page, type release_repo in the Repository Name field, and leave the other parameters as default.
  5. Click OK. The code repository details page is displayed.
  6. Click the pom.xml file to enter its details page. In the right pane, Click to access the file editor. Copy the following code to the red box shown in Figure 7. Click OK to save your changes to the pom.xml file.

    The following sample code adds the dependencyProject-1.0.jar package generated as the output of the build task dependency_task in the dependency element.

    <modelVersion>4.0.0</modelVersion>
      <groupId>com.huawei.release</groupId>
      <artifactId>releaseProject</artifactId>
      <packaging>jar</packaging>
      <version>1.0</version>
      <name>release_roject</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>com.huawei.dependency</groupId>
        <artifactId>dependencyProject</artifactId>
        <version>1.0</version>
        </dependency>
      </dependencies>
    Figure 7 Modifying the pom.xml file

Creating Build Task release_task

  1. In the navigation pane, choose CICD > Build.
  2. Click Create Task. On the displayed Basic Information page, set the following parameters. Leave the other parameters as default.

    • Name: Assign a custom name to the build task, for example, release_task.
    • Code Source: Select Repo.
    • Repository: Select release_repo, the code repository created in Creating Code Repository release_repo.

  3. Click Next. On the displayed page, select Blank Template. Click OK. The Build Actions page is displayed.
  4. On the Build Actions page, click the GUI tab. Then click Add Build Actions on the left and add the Build with Maven action. Leave the parameters as default.
  5. Click Save and Run in the upper right corner. In the displayed dialog box, click Confirm. The build task run page is displayed.

    Figure 8 Running a build task

Viewing the Build Results

On the Actions tab, check that the console displays the logs of the build task as it runs. The Build Logs window automatically scrolls down to show new entries. As shown in the following figure, the build log indicates that the dependencyProject-1.0.jar package produced as the output of the build task dependency_task is pulled as a dependency from the self-hosted repo dependency_libs.

Figure 9 Viewing the build log

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback