import { Aspect , FP , sha256 , } from "@atomist/sdm-pack-fingerprint" ; import { findDependenciesFromEffectivePom , VersionedArtifact , } from "@atomist/sdm-pack-spring" ; const MavenDepsType = "maven-deps" ; /**
 * Emits direct and transitive dependencies.
 * Requires running Maven, so expensive
 */ export const allMavenDependenciesAspect = { name : MavenDepsType , displayName : "Maven dependency tree" , extract : async ( p ) => { const pom = await p . getFile ( "pom.xml" ) ; if ( ! pom ) { return undefined ; } const pomContent = await pom . getContent ( ) ; const allDeps = await findDependenciesFromEffectivePom ( p ) ; return allDeps . map ( dep => ( { ... dep , direct : pomContent . includes ( `<group>${ dep . group }</group>` ) && pomContent . includes ( `<artifact>${ dep . group }</artifact>` ) , } ) ) . map ( gavToFingerprint ) ; } , toDisplayableFingerprintName : name => name , toDisplayableFingerprint : fp => { const version = JSON . parse ( fp . data ) . version || "no version" ; return version ; } , } ; function gavToFingerprint ( gav ) { const data = JSON . stringify ( gav ) ; return { type : MavenDepsType , name : `${ gav . group }:${ gav . artifact }` , abbreviation : "mvn" , version : "0.1.0" , data , sha : sha256 ( data ) , } ; }