4.0 Build Tools & Package Managers Flashcards

(68 cards)

1
Q

4.0 Build Tools & Package Managers

What configuration language does Gradle use?

A

Groovy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

4.0 Build Tools & Package Managers

What configuration language does Maven use?

A

XML

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

4.0 Build Tools & Package Managers

Where in the app directory structure does Gradle generate the JAR?

A

~/java-app/build/libs/

May look something like java-app-1.0-SNAPSHOT.jar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

4.0 Build Tools & Package Managers

Where in the app directory structure does Maven generate the JAR?

A

~/java-maven-app/target/maven-status/

May look something like java-manen-app-1.1.0-SNAPSHOT.jar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

4.0 Build Tools & Package Managers

What is an artifact?

A

A single packaged file containing application code and all its dependencies.

Artifacts are essential for deployment across different environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

4.0 Build Tools & Package Managers

What does building the code mean?

A

Compiling, compressing, and packaging many files into a single artifact.

This process prepares the application for deployment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

4.0 Build Tools & Package Managers

What is an artifact repository?

A

A storage system for artifacts, used for backups and redeployments (e.g., Nexus, JFrog Artifactory).

It helps manage versioned artifacts efficiently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

4.0 Build Tools & Package Managers

Why do we need artifacts?

A

To deploy applications to different environments (dev, test, prod) as a consistent, versioned file.

Artifacts ensure that the same version of the application is used across environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

4.0 Build Tools & Package Managers

What do Java artifacts typically look like?

A
  • JAR files
  • WAR files

These formats are used for packaging Java applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

4.0 Build Tools & Package Managers

What do JavaScript artifacts typically look like?

A
  • Zip files
  • Tar files

JavaScript does not have a special artifact type like Java.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

4.0 Build Tools & Package Managers

What are the Java build tools?

A
  • Maven
  • Gradle

These tools help automate the build process in Java projects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

4.0 Build Tools & Package Managers

What is the JavaScript package manager?

A

npm (and yarn)

These tools manage JavaScript libraries and dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

4.0 Build Tools & Package Managers

Where do Java developers find dependencies?

A

Maven Central Repository

This repository hosts a wide range of Java libraries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

4.0 Build Tools & Package Managers

What file stores Maven project dependencies?

A

pom.xml

This file defines the project structure and dependencies for Maven.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

4.0 Build Tools & Package Managers

What file stores Gradle project dependencies?

A

build.gradle

This file is used to configure Gradle builds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

4.0 Build Tools & Package Managers

What happens when you add a dependency to Maven/Gradle?

A

The dependency is downloaded to the local repository.

This allows for offline builds and faster access to dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

4.0 Build Tools & Package Managers

Where does Gradle put the built artifact?

A

In the build folder.

This is the default output directory for Gradle builds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

4.0 Build Tools & Package Managers

Where does Maven put the built artifact?

A

In the target folder.

This is the standard output directory for Maven builds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

4.0 Build Tools & Package Managers

How do you run a Java application locally?

A

java -jar <name-of-jar>

This command executes the JAR file containing the application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

4.0 Build Tools & Package Managers

How do you run a Java application on a server?

A

Copy the JAR to the server → run java -jar.

This process is common for deploying Java applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

4.0 Build Tools & Package Managers

Does JavaScript use build tools?

A

JS primarily uses package managers (npm, yarn) instead of build tools.

This reflects the different needs of JavaScript applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

4.0 Build Tools & Package Managers

Where are JS dependencies defined?

A

package.json

This file lists all dependencies and scripts for a JavaScript project.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

4.0 Build Tools & Package Managers

What commands does npm provide?

A
  • npm install
  • npm start
  • npm stop
  • npm test
  • npm publish

These commands facilitate various tasks in JavaScript development.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

4.0 Build Tools & Package Managers

What does a JS artifact (zip/tar) contain?

A

Application code without dependencies.

This is important for deploying JavaScript applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
# 4.0 Build Tools & Package Managers How do you deploy a **JavaScript app** to a server?
1. Copy zip/tar 2. Unpack 3. Install dependencies 4. Run the app ## Footnote This process ensures that the application runs correctly on the server.
26
# 4.0 Build Tools & Package Managers What tools package **frontend JavaScript code**?
Bundlers/build tools like **webpack**. ## Footnote These tools help optimize and prepare code for production.
27
# 4.0 Build Tools & Package Managers Why does **frontend JS code** need transpiling?
Browsers don’t support the latest JS features or JSX. ## Footnote Transpiling ensures compatibility across different browsers.
28
# 4.0 Build Tools & Package Managers What does **webpack** do?
Transpiles, minifies, bundles, and compresses frontend code. ## Footnote This process improves performance and reduces load times.
29
# 4.0 Build Tools & Package Managers How do you package full **frontend code** for deployment?
Bundle with webpack → package into a WAR or static assets folder. ## Footnote This prepares the application for deployment on a server.
30
# 4.0 Build Tools & Package Managers What are **build or package tools** for other languages?
* Python: pip * C/C++: conan * C#: NuGet * Golang: dep * Ruby: RubyGems ## Footnote These tools serve similar purposes across different programming languages.
31
# 4.0 Build Tools & Package Managers What common patterns exist across all **build tools**?
* Dependency file * Dependency repository * CLI tool * Commands to test, start, build, publish ## Footnote These patterns help standardize the build process.
32
# 4.0 Build Tools & Package Managers Why publish **artifacts** to a repository?
To store and download them for deployment on other servers. ## Footnote This practice ensures that artifacts are accessible when needed.
33
# 4.0 Build Tools & Package Managers Why are **artifacts** less commonly used today?
Docker images replaced many artifact types. ## Footnote This shift reflects changes in deployment practices.
34
# 4.0 Build Tools & Package Managers How does **Docker** change the build process?
* Only one artifact type: Docker image * No need to install Java/npm on servers * Build and run everything inside the image ## Footnote Docker simplifies deployment by encapsulating everything needed to run an application.
35
# 4.0 Build Tools & Package Managers Is **building** still required when using Docker?
Yes — the app must be built before the Docker image is created. ## Footnote This step is crucial for ensuring the application functions correctly.
36
# 4.0 Build Tools & Package Managers Why should **DevOps engineers** know build tools?
To configure CI/CD pipelines, run tests, build artifacts/images, and deploy apps. ## Footnote Understanding build tools is essential for effective DevOps practices.
37
# 4.0 Build Tools & Package Managers What steps are typically automated in **CI/CD**?
* Install dependencies * Run tests * Build/bundle app * Publish artifact or build Docker image * Push to repository ## Footnote Automation improves efficiency and reduces errors in the deployment process.
38
# 4.0 Build Tools & Package Managers Examples of **build automation commands**?
* `npm install`, `npm test`, `npm run build`, `npm publish` * `mvn test`, `mvn install`, `mvn package` * `docker build`, `docker push` ## Footnote These commands facilitate various tasks in the build and deployment process.
39
# 4.0 Build Tools & Package Managers What causes the **Maven error**: *“Could not resolve dependencies”*?
* Incorrect version * Missing repository * Offline mode enabled * Corporate proxy blocking Maven Central ## Footnote These issues prevent Maven from locating and downloading required dependencies.
40
# 4.0 Build Tools & Package Managers How do you **clear Maven's local dependency cache**?
* Delete `~/.m2/repository` * Run `mvn dependency:purge-local-repository` ## Footnote Clearing the cache can resolve issues with corrupted or outdated dependencies.
41
# 4.0 Build Tools & Package Managers What **Gradle command** re-downloads missing/corrupted dependencies?
`gradle --refresh-dependencies` ## Footnote This command forces Gradle to check for updated dependencies and download them again.
42
# 4.0 Build Tools & Package Managers Why does Maven produce *“Invalid target release: XX”*?
The installed JDK doesn't match `maven-compiler-plugin` settings ## Footnote Ensuring the correct JDK version is crucial for successful builds.
43
# 4.0 Build Tools & Package Managers What problem causes: *“JAVA_HOME is not set and no 'java' command could be found”*?
Java not installed or environment variables misconfigured ## Footnote Properly setting JAVA_HOME is essential for Java applications to run.
44
# 4.0 Build Tools & Package Managers What causes **Gradle's** *“PermGen space / OutOfMemoryError”*?
* Large dependency graph * Heavy annotation processing ## Footnote Adjusting `GRADLE_OPTS` can help manage memory usage.
45
# 4.0 Build Tools & Package Managers What issue causes *“command not found: mvn / gradle”*?
PATH is missing Maven/Gradle bin folder after installation ## Footnote Ensuring the PATH variable is correctly set is necessary for command-line access.
46
# 4.0 Build Tools & Package Managers What causes: *“module not found”* after an npm install?
* `node_modules` folder missing * Version mismatch ## Footnote Running `rm -rf node_modules && npm install` can resolve this issue.
47
# 4.0 Build Tools & Package Managers How do you fix **npm EACCES permission errors** on Linux?
Don’t use `sudo npm install -g`; instead configure npm prefix in your home directory ## Footnote This prevents permission issues when installing global packages.
48
# 4.0 Build Tools & Package Managers Why does an npm build fail with *“Out of memory”*?
Minifiers or bundlers exceed Node's default memory ## Footnote Fix this by using `node --max_old_space_size=4096` to allocate more memory.
49
# 4.0 Build Tools & Package Managers What causes *“package-lock.json conflicts”* in Git?
Multiple developers using different npm versions ## Footnote Standardizing Node/npm versions can prevent these conflicts.
50
# 4.0 Build Tools & Package Managers How do you verify exactly which **dependency version** was installed?
Run `npm ls ` ## Footnote This command lists the installed version of a specific package.
51
# 4.0 Build Tools & Package Managers Why do Node apps fail after deployment?
Dependencies not installed on the server ## Footnote Remember: artifacts **do not contain dependencies**; they must be installed separately.
52
# 4.0 Build Tools & Package Managers Why is **Docker** used instead of JAR/WAR/zip artifacts in modern DevOps?
Docker packages the app *and its runtime environment* ## Footnote This avoids dependency mismatches and simplifies deployment.
53
# 4.0 Build Tools & Package Managers What causes Docker builds to fail with *“file not found”* for artifacts?
Build steps run **outside** Docker, but Dockerfile expects them inside ## Footnote Performing the build inside the Dockerfile resolves this issue.
54
# 4.0 Build Tools & Package Managers What causes *“node: not found”* or *“java: not found”* during Docker builds?
Base image missing required runtime ## Footnote Use appropriate images like `node:20-alpine` or `eclipse-temurin:17`.
55
# 4.0 Build Tools & Package Managers Why must Docker builds use **.dockerignore**?
To avoid sending large files like `node_modules` to the Docker daemon ## Footnote This drastically speeds up builds by reducing context size.
56
# 4.0 Build Tools & Package Managers Why do **multi-stage Docker builds** improve CI/CD performance?
They reduce final image size and remove build-time tools from production images ## Footnote This leads to more efficient deployments.
57
# 4.0 Build Tools & Package Managers Why might a CI job fail with *“command not found: mvn/npm/gradle”*?
Wrong CI executor image ## Footnote Use images like `maven:3.9-eclipse-temurin-17`, `gradle:8-jdk17`, or `node:20-alpine`.
58
# 4.0 Build Tools & Package Managers What causes **flaky CI builds**?
* Race conditions * Non-deterministic tests * Network issues fetching dependencies * Cached dependency corruption ## Footnote These factors can lead to inconsistent build results.
59
# 4.0 Build Tools & Package Managers Why do pipelines run slower over time?
CI cache grows too large or contains stale artifacts ## Footnote Clearing or optimizing caching strategy can improve performance.
60
# 4.0 Build Tools & Package Managers What's the safest caching strategy for **node builds**?
Cache **only `~/.npm`**, not `node_modules` ## Footnote This prevents unnecessary bloat in the cache.
61
# 4.0 Build Tools & Package Managers Why do Java builds fail in CI but work locally?
Local machine has cached dependencies, but CI requires explicitly listed repositories ## Footnote Ensuring all dependencies are defined in the build configuration is crucial.
62
# 4.0 Build Tools & Package Managers Why should developers **pin exact dependency versions**?
Unpinned versions lead to unpredictable builds and “works on my machine” issues ## Footnote Pinning versions ensures consistent environments across different setups.
63
# 4.0 Build Tools & Package Managers What is the difference between dependency **version pinning** and **version ranges**?
* Pinning → reproducible builds * Ranges → risk of unexpected breaking changes ## Footnote Understanding this difference is key to managing dependencies effectively.
64
# 4.0 Build Tools & Package Managers What does a **lock file** ensure (package-lock.json / npm-shrinkwrap / gradle.lockfile)?
Guarantees identical dependency versions across machines and CI pipelines ## Footnote This is essential for maintaining consistency in builds.
65
# 4.0 Build Tools & Package Managers Why do dev and prod use different **dependency sets**?
Dev includes test/build tools; prod installs only runtime dependencies ## Footnote This reduces the attack surface in production environments.
66
# 4.0 Build Tools & Package Managers Why shouldn’t developers commit built artifacts (JAR/WAR/zip) to Git?
* Causes repo bloat * Breaks Git diffs * CI should produce artifacts, not dev machines ## Footnote This practice helps maintain a clean and efficient repository.
67
# 4.0 Build Tools & Package Managers Why must DevOps engineers understand **build tools**?
They configure pipelines that must install, test, package, and deploy the application ## Footnote Knowledge of build tools is essential for effective DevOps practices.
68
# 4.0 Build Tools & Package Managers What is the **DevOps golden rule** about build environments?
Builds must be **repeatable, immutable, and performed in CI**, never on personal laptops ## Footnote This ensures consistency and reliability in the build process.