Opscraft
Build tools & artifact repositories · Lesson 9 of 9 · 3 min read

Interview questions and model answers

"Explain the Maven lifecycle. What's the difference between install and deploy?"

The default lifecycle runs phases in order — validate, compile, test, package, verify, install, deploy — and invoking one runs all earlier ones. install copies the built artifact into the local repository ~/.m2 so other local builds can use it; deploy uploads it to a remote repository such as Nexus for other teams and pipelines. In CI we normally run verify for PRs and deploy only on main or tags.

"SNAPSHOT vs release versions?"

A SNAPSHOT is a moving development version; every deploy creates a unique timestamped build and consumers get the latest, so it isn't reproducible. Releases are immutable — the repository rejects redeploying the same version. A release must not depend on SNAPSHOTs. For continuously deployed services I prefer unique versions per build, tied to the git SHA.

"How does Maven resolve version conflicts, and how do you fix one?"

Nearest wins: the version closest to the root of the dependency tree, first declaration on ties — which can select an older version and cause NoSuchMethodError. I run mvn dependency:tree to find the paths, then pin the version in dependencyManagement or import a BOM, add exclusions if needed, and add the enforcer plugin's dependencyConvergence rule so it can't regress. Gradle picks the highest version by default, and I'd use platforms, constraints and locking there.

"Why is Gradle faster than Maven?"

Incremental task execution based on declared inputs and outputs, a build cache that reuses task outputs locally and across machines through a remote cache, the configuration cache, a long-lived daemon, and parallel project execution. Maven rebuilds most things each time unless extensions add caching.

"Why put Nexus or Artifactory in front of Maven Central?"

Speed and resilience from caching, a single controlled entry point for all external dependencies so we can scan, block and audit them, a place to host internal artifacts with retention policies, and protection from dependency confusion through routing rules. CI and developers use one group URL; only CI can publish releases.

"How do you make builds reproducible?"

Pin dependency and plugin versions with no ranges, use lockfiles, pin the build tool with the wrapper and the JDK with toolchains or a fixed builder image, resolve only through the repository manager, avoid timestamps in archives, and build once then promote the same artifact or image digest through environments.

"How would you use CodeArtifact with GitHub Actions?"

The workflow assumes an IAM role via OIDC, calls get-authorization-token for a short-lived token and passes it as the password for user aws in Maven settings or Gradle credentials, with the endpoint from get-repository-endpoint. The repository has an external connection to Maven Central as an upstream, and a domain policy shares it across accounts. Publishing is allowed only for the CI role.