my-notes

Build and Package Manager Tools

What kind of file is the artifact?

Artifact file looks different for each programming language

Example, for Java, the artifact is a JAR file, which includes whole code plus dependencies.

Install Build Tools

Install Java:

# using the one from the package manager
sudo apt install default-jdk

# setting JAVA_HOME variable (seems to be important for some tools)
# put the code below in your ~/.profile
if [ -d "/usr/lib/jvm/default-java/bin" ]; then
    JAVA_HOME="/usr/lib/jvm/default-java"
    PATH="$JAVA_HOME/bin:$PATH"
fi

Install Maven

See instructions in https://maven.apache.org/install.html

Install Gradle

I just used IntelliJ.

Install Node + npm

I prefer to use Node Version Manager.

Download IntelliJ

Download page: https://www.jetbrains.com/idea/download/

The Community version has the needed tools.

Build an Artifact

With Gradle

The ./gradlew present in the Nana’s repo is enough to build the project.

Executing ./gradlew build will generate the ./build/ folder and the .jar file will be placed in ./build/libs/.

With Maven

Config the pom.xml file with the <build> tag. Then:

mvn install

The .jar file will be placed in ./target/ folder.

Build Tools for Development

Managing dependencies:

Run the Application

Command to run a .jar file:

java -jar <file.jar>

Build JS Application

Backend

# install dependencies (inside projects directory)
npm install

# when the package.json is properly configured
npm start   # start the application
npm stop    # stop the application
npm test    # run the tests
npm publish # publish the artifact

# create an artifact file
npm pack    # creates a tar file

What does the zip/tar file include?

Frontend

# install dependencies (inside projects directory)
npm install

# assuming webpack is installed and "build" in package.json calls webpack
# and it bundles the code minified/transpiled.
npm run build

When working with Java in the backend and React in the frontend, it’s possible to:

Common Concepts and Differences of Build Tools

language dependency manager
Java Maven or Gradle
JavaScript npm or yarn
Python pip

Pattern in all these tools:

Publish an Artifact

Publish artifact into a artifact repository.

Build Tools & Docker

Build Tools for DevOps

Why should a DevOps Engineer know these build tools?