.jar, .war, or .ear files. However, you’ll get the best results if you explicitly pin or lock dependencies to stable versions.
Recommended Steps
-
Pin Versions in pom.xml
Make sure each dependency in<dependencies>includes a specific version number: -
Use a Lockfile-Like Approach
While Maven doesn’t have an official universal lockfile, certain plugins or pinned version strategies replicate the effect.- Dependency Management: Use
<dependencyManagement>in your parent pom to centralize version definitions. - Versions Maven Plugin: Tools like
versions:lock-snapshotsorversions:use-releasescan help freeze your dependencies. - Maven Enforcer: Consider using the enforcer plugin to ban dependency version ranges.
- Dependency Management: Use
-
Generate Flattened POM
The Maven Flatten Plugin creates a simplified POM with all versions resolved: -
Store pom.xml in Repo
This ensures that the entire team, and CybeDefend, see the exact dependency versions.
Why You Should Use Lockfiles
Using a lockfile is critical for secure and predictable builds. A lockfile contains a fixed version and a hash for each dependency and sub-dependency in your project.- Supply Chain Protection
Lockfiles prevent malicious package injections. This is crucial as supply chain attacks are rising. - Predictable Builds
Everyone uses the exact same package versions, avoiding “it works on my machine” inconsistencies. - Performance Gains
With dependency versions locked, build tools skip the usual resolution step, making builds faster.
Lockfiles are never edited manually. They’re generated and updated by your package manager and committed to your repository, ensuring consistent environments for all teammates.
For advanced usage, some teams generate
.flattened-pom.xml or use ephemeral lock plugins. The key is to produce a stable, pinned set of dependencies that CybeDefend can accurately scan.Supported Files for Java/Maven
| File Examples |
|---|
pom.xml, .jar, .war, .ear, .flattened-pom.xml |