import Base_java from "./base_java.js"; export type Provider = import('../provider.js').Provider; export type Provided = import('../provider.js').Provided; /** * This class provides common functionality for Groovy and Kotlin DSL files. */ export default class Java_gradle extends Base_java { #private; constructor(); _getManifestName(): void; _parseAliasForLibsNotation(): void; _extractDepToBeIgnored(): void; /** * @param {string} manifestName - the subject manifest name-type * @returns {boolean} - return true if the manifest name-type is the supported type (example build.gradle) */ isSupported(manifestName: string): boolean; /** * @param {string} manifestDir - the directory where the manifest lies */ validateLockFile(): boolean; /** * Gradle manifests (build.gradle, build.gradle.kts) have no standard license field. * @param {string} manifestPath - path to manifest * @returns {null} */ readLicenseFromManifest(manifestPath: string): null; /** * Provide content and content type for stack analysis. * @param {string} manifest - the manifest path or name * @param {{}} [opts={}] - optional various options to pass along the application * @returns {Provided} */ provideStack(manifest: string, opts?: {}): Provided; /** * Provide content and content type for maven-maven component analysis. * @param {string} manifest - path to pom.xml for component report * @param {{}} [opts={}] - optional various options to pass along the application * @returns {Provided} */ provideComponent(manifest: string, opts?: {}): Provided; /** * @param {string} line - the line to parse * @returns {number} the depth of the dependency in the tree starting from 1. -1 if the line is not a dependency. * @private */ private #getIndentationLevel; /** * Process the dependency tree and add dependencies to the SBOM * @param {string[]} config - the configuration lines to process * @param {Object} parentPurl - the parent package URL * @param {Sbom} sbom - the SBOM object to add dependencies to * @param {Set} processedDeps - set of already processed dependencies * @param {string} scope - the dependency scope * @param {Map>} [hashMap] - map of "group:name@version" to CycloneDX hashes * @private */ private #processDependencyTree; /** * Create a Dot Graph dependency tree for a manifest path. * @param {string} manifest - path for pom.xml * @param {{}} [opts={}] - optional various options to pass along the application * @returns {string} the Dot Graph content * @private */ private #buildSbom; /** * Create a Dot Graph dependency tree for a manifest path. * @param {string} manifest - path for pom.xml * @param {{}} [opts={}] - optional various options to pass along the application * @returns {string} the Dot Graph content * @private */ private #createSbomStackAnalysis; /** * Create a dependency list for a manifest content. * @param {{}} [opts={}] - optional various options to pass along the application * @returns {string} - sbom string of the direct dependencies of build.gradle * @private */ private #getSbomForComponentAnalysis; /** * Get a list of dependencies from gradle dependencies command. * @param {string} manifest - path for build.gradle * @returns {string} Multi-line string contain all dependencies from gradle dependencies command * @private */ private #getDependencies; /** * Hash a file using SHA-256 with streaming to handle large files efficiently. * @param {string} filePath - path to the file to hash * @returns {Promise} hex-encoded SHA-256 digest * @private */ private #hashFileStream; /** * Compute SHA-256 hashes for the resolved artifacts of a Gradle manifest. * * Rather than scanning the local Gradle cache, this asks Gradle itself for * the resolved artifact files via an init script (mirroring the pattern used * by {@link discoverGradleSubprojects}), then hashes each file with the * Node.js `crypto` module. The result is keyed by the canonical PURL string * built via {@link Base_java#toPurl} — the same builder {@link parseDep} uses * for the lookup — so the stored key and the lookup key cannot drift. * * Degrades gracefully: if Gradle cannot be invoked, the init script fails, or * an artifact has no readable file (e.g. BOM/`platform()` dependencies), the * hash for that component is omitted rather than throwing. A warning is emitted * on every degradation path so incomplete hash coverage is visible even without * `TRUSTIFY_DA_DEBUG` (mirroring the pip/cargo providers). * * @param {string} manifest - path to build.gradle[.kts] * @param {{}} [opts={}] - optional various options to pass along the application * @returns {Promise>>} map of canonical PURL string to CycloneDX hashes */ parseGradleHashes(manifest: string, opts?: {}): Promise>>; /** * Extracts runtime and compile configurations from the dependency tree * @param {string} content - the dependency tree content * @returns {[string[], string[]]} tuple of [runtimeConfig, compileConfig] * @private */ private #extractConfigurations; /** * This method gets build.gradle manifest, and extracts from it all artifacts marks for exclusion using an //exhortignore comment. * @param {string} manifestPath the build.gradle manifest path * @return {string[]} an array with all dependencies to ignore - contains 'stringified' purls as elements * @private */ private #getIgnoredDeps; } /** * Discover all build.gradle[.kts] manifest paths in a Gradle multi-project build. * Uses a custom init script to get structured project listing. * * @param {string} workspaceRoot - Absolute or relative path to workspace root (must contain settings.gradle[.kts]) * @param {import('../index.js').Options} [opts={}] * @returns {Promise} Paths to build.gradle[.kts] files (absolute) */ export declare function discoverGradleSubprojects(workspaceRoot: string, opts?: import('../index.js').Options): Promise; /** * Parse the structured output from the Gradle init script. * * @param {string} raw - Raw stdout from gradle * @returns {{ path: string, dir: string }[]} */ export declare function parseGradleInitScriptOutput(raw: string): { path: string; dir: string; }[]; /** * Parse the structured output from the Gradle hash init script. * Each recognised line has the form `::DA_HASH::group:name:version::`. * * @param {string} raw - Raw stdout from gradle * @returns {{ id: string, file: string }[]} component id (`group:name:version`) and absolute artifact file path */ export declare function parseGradleHashScriptOutput(raw: string): { id: string; file: string; }[]; /** * Parse a Gradle module component id (`group:name:version`) into its coordinate * parts. The caller builds the canonical PURL key from these parts using the same * builder {@link parseDep} uses, so the stored key and the lookup key cannot drift. * * @param {string} id - the Gradle component id * @returns {{group: string, name: string, version: string}|null} the parsed coordinate, or null when the id is malformed */ export declare function parseComponentId(id: string): { group: string; name: string; version: string; } | null;