sqry_classpath/resolve/mod.rs
1//! Classpath resolution via build tool subprocesses.
2//!
3//! Each resolver extracts the list of dependency JARs from the project's build system.
4//! Resolvers support timeout, caching, and graceful fallback.
5
6pub mod bazel;
7pub mod gradle;
8pub mod maven;
9pub mod sbt;
10pub mod source_jars;
11
12use std::path::PathBuf;
13
14use serde::{Deserialize, Serialize};
15
16/// A resolved classpath entry.
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct ClasspathEntry {
19 /// Path to the JAR file.
20 pub jar_path: PathBuf,
21 /// Maven coordinates if known (e.g., `com.google.guava:guava:33.0.0`).
22 pub coordinates: Option<String>,
23 /// Whether this is a direct (compile) dependency vs transitive.
24 pub is_direct: bool,
25 /// Source JAR path if available.
26 pub source_jar: Option<PathBuf>,
27}
28
29/// Result of classpath resolution for a project or module.
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct ResolvedClasspath {
32 /// Module name (e.g., `app`, `lib`, or project root name).
33 pub module_name: String,
34 /// Concrete module root used to scope importer -> classpath resolution.
35 pub module_root: PathBuf,
36 /// Classpath entries.
37 pub entries: Vec<ClasspathEntry>,
38}
39
40/// Classpath resolution configuration.
41pub struct ResolveConfig {
42 /// Project root directory.
43 pub project_root: PathBuf,
44 /// Timeout for subprocess execution in seconds.
45 pub timeout_secs: u64,
46 /// Path to cached classpath directory (for fallback).
47 pub cache_path: Option<PathBuf>,
48}
49
50impl Default for ResolveConfig {
51 fn default() -> Self {
52 Self {
53 project_root: PathBuf::new(),
54 timeout_secs: 60,
55 cache_path: None,
56 }
57 }
58}