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.
# 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
See instructions in https://maven.apache.org/install.html
I just used IntelliJ.
I prefer to use Node Version Manager.
Download page: https://www.jetbrains.com/idea/download/
The Community version has the needed tools.
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/
.
Config the pom.xml
file with the <build>
tag. Then:
mvn install
The .jar
file will be placed in ./target/
folder.
Managing dependencies:
pom.xml
build.gradle
Command to run a .jar
file:
java -jar <file.jar>
# 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?
# 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:
language | dependency manager |
---|---|
Java | Maven or Gradle |
JavaScript | npm or yarn |
Python | pip |
Pattern in all these tools:
Publish artifact into a artifact repository.
You don’t need to install npm or java on the server. Execute everything in the image.
Dockerfile
).Why should a DevOps Engineer know these build tools?