Building and Packaging Java Projects using a Maven
- Compilation: Process of
- checks for errors in code
- converts to desired language (Byte code/machine code)
- Packaging:
- Combining compiled code into some packaging format
- java: jar/war/ear
- dotnet: dll/exe
- Combining compiled code into some packaging format
- Dependencies: will be downloaded
- java: maven/gradle
- dotnet: nuget
- python: pip
- nodejs: npm
- Maven: combines dependency resolution, compilation, unit test executions, packaging
- Maven expects a file called as pom.xml
- Steps:
- Get the latest code
- Pre-requisites:
- jdk version
- maven
- Execute
mvn <goal>
- compile
- test
- package
- In our case we will be using
mvn package
Setup a linux vm for building and packaging spring-petclinic
- pre-req’s
- git
- maven
- jdk 17
- SSH into the vm & execute the following
sudo apt update
sudo apt install openjdk-17-jdk -y
sudo apt install maven -y
git --version
java -version
mvn --version
* Build steps
cd ~
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
mvn package
Azure DevOps Pipelines
-
Azure DevOps has two ways of building pipelines
- Classic Pipelines: We rely on user interface
- Drawback:
- History will be missing
- Advantages:
- Easy to start
- Drawback:
- Azure Pipelines YAML: Pipeline as Code. We will define pipelines steps in a file
azure-pipelines.yaml
and add it to the version control system (git)- Advantage:
- History will be maintained
- Disadvantage:
- Learning curve for writing pipeline
- Advantage:
- Classic Pipelines: We rely on user interface
-
Azure DevOps has agents: Agent is where the build is executed. There are two types of agents
- Microsoft Hosted agents: These are machines which will be created on demand by Azure DevOps and will be delete upon build completion.
- Self Hosted Agents: These are machines managed by us, we add these machines as agents to Azure DevOps.
-
Azure DevOps plans
- Free:
- 1 Free Microsoft-hosted CI/CD (1800 minutes/month)
- 1 Free Self-Hosted CI/CD
- Azure Source Repos => free
- Azure Artifacts 2 GB
- Free:
Configuring Spring petclinic build on Azure DevOps
- Ensure you have some Azure DevOps Project
- Import the repository
- Lets setup build
- To solve this error we need to raise parallelism request Refer Here