How to Launch a Scan on Java/Scala/Kotlin
Optimize SCA scanning by using Gradle lockfiles and pinned versions for Java, Scala, or Kotlin builds.
For Gradle-based projects in Java, Scala, or Kotlin, generating a gradle.lockfile
ensures consistent dependencies that CybeDefend can accurately scan. SBT-based Scala projects can also pin versions in .sbt.lock
or a centralized method.
Gradle Lockfiles
- Enable Gradle Locking
In yourgradle.properties
, set:
- Generate
Run./gradlew dependencies
or./gradlew --write-locks
to creategradle.lockfile
. - Commit
Check ingradle.lockfile
so that your entire team and CybeDefend sees fixed 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.
SBT Lock for Scala
- sbt-lock plugin can generate
.sbt.lock
. - Commit that lockfile to maintain pinned Scala library versions.
Supported Files
Lang | File Examples |
---|---|
Java | gradle.lockfile , pom.xml , .jar , .war , .ear |
Scala | build.sbt , plugins.sbt , .sbt.lock , dependencies.scala , .scala |
Kotlin | gradle.lockfile , .kts files (Gradle Kotlin DSL) |
Some older build tools or frameworks may require additional steps. The primary goal is to produce a stable lock or pinned version set for each submodule.