DevOps Classroom notes 03/Apr/2025

Lab setup for building java projects

  • Create a free tier ubuntu vm on azure or aws

Tools helping Building java code

  • We have javac which is basic java compiler
  • For larger projects in very intitial phases, javac was used with make files
  • Apache Ant was introduced which helps in building java projects. Ant projects have build.xml which will have build instructions. The build.xml is configuration of what has to be done

Maven

  • Maven is a tool that is introduced to manage projects. Maven
    • manages dependencies
    • performs build, package, artifact management
    • create documentations
  • Maven uses Convention over Configuration model

Setup on Ubuntu

  • Install openjdk 17
sudo apt install openjdk-17-jdk -y
sudo apt install maven -y
mvn --version
  • Simple maven commands mvn <goal>
mvn compile
mvn test
mvn package
  • Conventions:
  • We have created a pom.xml file with following content
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.learningthoughts.projects</groupId>
    <artifactId>helloworld</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/software.amazon.awssdk/s3 -->
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
            <version>2.31.6</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

</project>
  • We have created the folder structure src/main/java
  • Now execute mvn compile
  • To package mvn package
  • Projects skeleton or structure can be created using archetypes
mvn archetype:generate \
  -DgroupId=io.learningthoughts \
  -DartifactId=generated \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DarchetypeVersion=1.5 \
  -DinteractiveMode=false
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%