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 /// Classpath entries.
35 pub entries: Vec<ClasspathEntry>,
36}
37
38/// Classpath resolution configuration.
39pub struct ResolveConfig {
40 /// Project root directory.
41 pub project_root: PathBuf,
42 /// Timeout for subprocess execution in seconds.
43 pub timeout_secs: u64,
44 /// Path to cached classpath file (for fallback).
45 pub cache_path: Option<PathBuf>,
46}
47
48impl Default for ResolveConfig {
49 fn default() -> Self {
50 Self {
51 project_root: PathBuf::new(),
52 timeout_secs: 60,
53 cache_path: None,
54 }
55 }
56}