What are Build and Package Manager Tools?
Once a developer builds an app, it must be deployed to a production server along with all the dependencies that were previously in the code repository to make it available to end users.
To do the same, you need to package all your application files and their dependencies into a single portable file. And you can get that file to your server and run it there.The packaged files are Artifact. Creating an artifact is also “building code”.
Building code involves compiling and compressing files. From hundreds of files he generates one file.
Artifacts are not typically deployed directly to a server. Save it for multiple deployments or to keep as a backup.
A storage that holds artifacts is called an artifact repository. Artifact repositories include “Nexus” and “JFrog Artifactory”.
What format do these artifacts have?
Artifact files look different for each programming language. For example, Java has an artifact in the form of a JAR (Java Archive) or WAR file that contains all of your code plus dependencies such as the Spring framework, DateTime library, and so on.
How to build artifacts?
They are built using specific tools. This is programming language specific. For example, Maven or Gradle for Java.
These tools will install dependencies, compile and minify your code.
The video above will help you create your first Java project.
Create a JAR FILE using the following command:
to run the application?
Once the artifact is created and deployed to the new server, use the following command:
java -jar <name of jar file>
What about JS applications?
following command is used for installing dependencies .
-> npm install
The npm repository is used for dependencies.
command line tool – npm
npm start -> start the application
npm stop -> stop the application
npm test -> runt the test
npm publish -> publish the artifact
If your project uses React on the front end and Java on the back end, how do you build your artifacts?
Artifacts can then be constructed in two ways:
1. Package frontend and backend separately (JAR and TAR)
2. Create a Common Artifact File (JAR)
If your project uses React on the front end and NodeJs on the back end, how do you build your artifacts?
Both are JS libraries, so you can build your artifacts in two ways:
1. Separate package.json files for frontend and backend.
2. Common package.json file
You need to transpile your frontend/React code!
Transpiled means making js code browser readable as browsers don’t support modern JS versions and other fancy code decorations like JSX. You have to minify/minify your code! There are different tools for that — build tools/bundles! An example is “WebPack”.
first install all the dependencies of the project .
-> cd api
-> npm install
Then use the run command
-> npm run build
server.bundle.js name file will be created in the node_moduled folder.
This will be the compiled and compressed code.
Package frontend code (if JAVA is the backend)
- Bundle your frontend app with Webpack
- Manage dependencies using npm or yarn
- Package everything into a WAR file
Build tools and Docker
You just need a repository that supports Docker images.