Skip to content

Commit d49643f

Browse files
sj-robertclaude
authored andcommitted
chore: remove XML fallback parser and quick-xml dependency
Drop the lightweight XML fallback parser (liquibase_xml.rs, 3,463 lines) and quick-xml dependency. Liquibase now requires a JRE with a two-tier strategy: bridge JAR -> update-sql. Update docs, config, and tests to reflect the two-tier approach. Fix bridge Dockerfile to skip tests that need project-root fixtures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 42a2dee commit d49643f

12 files changed

Lines changed: 42 additions & 3965 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: cargo fmt --check
3838

3939
- name: Run Clippy
40-
run: cargo clippy --all-targets -- -D warnings
40+
run: cargo clippy --all-targets --features bridge-tests -- -D warnings
4141

4242
- name: Check compilation
4343
run: cargo check

Cargo.lock

Lines changed: 18 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ serde = { version = "1.0", features = ["derive"] }
2727
serde_json = "1.0"
2828
toml = "0.9.12"
2929

30-
# XML parsing for Liquibase
31-
quick-xml = "0.39.0"
32-
3330
# Error handling
3431
thiserror = "2.0"
3532
anyhow = "1.0"

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,12 @@ strategy = "auto"
216216

217217
For Liquibase, `paths` must point to the root changelog file (e.g. `migrations.xml`), not the directory containing it. The tool follows `<include>` elements from this entrypoint to discover changesets in order.
218218

219-
The tool uses a three-tier approach for Liquibase XML processing:
219+
The tool uses a two-tier approach for Liquibase XML processing (JRE required):
220220

221221
1. **Bridge JAR (preferred)** -- A small Java CLI that embeds Liquibase to extract exact changeset-to-SQL-to-line mappings. Download `liquibase-bridge.jar` from the [releases page](https://github.com/robert-sjoblom/pg-migration-lint/releases) and place it at the configured `bridge_jar_path`. Requires a JRE.
222222

223223
2. **`liquibase update-sql` (secondary)** -- If the bridge JAR is unavailable but the Liquibase binary is on the PATH, the tool invokes `liquibase update-sql` for less structured but functional output.
224224

225-
3. **XML fallback** -- If Java is unavailable, a lightweight built-in XML parser handles common change types (`<createTable>`, `<addColumn>`, `<createIndex>`, etc.). Exotic change types are skipped and the catalog is marked as potentially incomplete. Note: `<includeAll>` does not recurse into subdirectories in this mode — use the bridge JAR or `liquibase update-sql` for nested directory layouts.
226-
227-
Set `strategy = "xml-only"` under `[liquibase]` to skip Java entirely.
228-
229225
## Configuration Reference
230226

231227
Default config file: `pg-migration-lint.toml` in the working directory. Override with `--config <path>`.
@@ -279,10 +275,9 @@ bridge_jar_path = "tools/liquibase-bridge.jar"
279275
binary_path = "/usr/local/bin/liquibase"
280276
281277
# Liquibase processing strategy.
282-
# "auto" - tries bridge -> update-sql -> xml-fallback in order
278+
# "auto" - tries bridge -> update-sql in order
283279
# "bridge" - bridge JAR only
284280
# "update-sql" - liquibase update-sql only
285-
# "xml-fallback" - lightweight XML parser only
286281
# Default: "auto"
287282
strategy = "auto"
288283

bridge/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN mvn dependency:go-offline -q
99

1010
# Copy source and build the shaded JAR
1111
COPY src/ src/
12-
RUN mvn package -q
12+
RUN mvn package -q -DskipTests
1313

1414
# Stage 2: Slim runtime image with just JRE and the JAR
1515
FROM eclipse-temurin:21-jre-alpine

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub struct LiquibaseConfig {
9292
/// Path to liquibase properties file (passed as --defaults-file to liquibase CLI)
9393
pub properties_file: Option<PathBuf>,
9494

95-
/// Strategy: "auto", "bridge", "update-sql", "xml-fallback"
95+
/// Strategy: "auto", "bridge", "update-sql"
9696
#[serde(default = "default_liquibase_strategy")]
9797
pub strategy: String,
9898
}
@@ -241,8 +241,8 @@ const SECTION_LIQUIBASE: &str = "\
241241
strategy = \"auto\"
242242
Liquibase sub-strategy: which method to use for SQL extraction.
243243
Type: string
244-
Values: \"auto\", \"bridge\", \"update-sql\", \"xml-fallback\"
245-
Default: \"auto\" (tries bridge -> update-sql -> xml-fallback)
244+
Values: \"auto\", \"bridge\", \"update-sql\"
245+
Default: \"auto\" (tries bridge -> update-sql)
246246
";
247247

248248
const SECTION_OUTPUT: &str = "\

src/input/liquibase_bridge.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ pub fn resolve_source_paths(units: &mut [RawMigrationUnit], base_dir: &Path) {
134134
/// Strategy selection:
135135
/// - `"bridge"`: Use bridge JAR only, fail if unavailable.
136136
/// - `"update-sql"`: Use `liquibase update-sql` only.
137-
/// - `"xml-fallback"`: Use the lightweight XML parser only.
138-
/// - `"auto"` (default): Try bridge -> update-sql -> xml-fallback in order.
137+
/// - `"auto"` (default): Try bridge -> update-sql in order.
139138
///
140139
/// The `paths` parameter should contain paths to changelog files.
141140
pub fn load_liquibase(
@@ -147,15 +146,14 @@ pub fn load_liquibase(
147146
match strategy {
148147
"bridge" => load_with_bridge(config, paths),
149148
"update-sql" => load_with_updatesql(config, paths),
150-
"xml-fallback" => load_with_xml_fallback(paths),
151149
"auto" => load_auto(config, paths),
152150
other => Err(LoadError::Config {
153151
message: format!("Unknown liquibase strategy: '{}'", other),
154152
}),
155153
}
156154
}
157155

158-
/// Try bridge -> update-sql -> xml-fallback in order.
156+
/// Try bridge -> update-sql in order.
159157
fn load_auto(
160158
config: &LiquibaseConfig,
161159
paths: &[PathBuf],
@@ -172,12 +170,15 @@ fn load_auto(
172170
if config.binary_path.is_some() {
173171
match load_with_updatesql(config, paths) {
174172
Ok(units) => return Ok(units),
175-
Err(_) => { /* fall through to XML fallback */ }
173+
Err(_) => { /* fall through to error */ }
176174
}
177175
}
178176

179-
// Fall back to XML
180-
load_with_xml_fallback(paths)
177+
Err(LoadError::Config {
178+
message: "Liquibase strategy 'auto' failed: neither bridge JAR nor update-sql succeeded. \
179+
Ensure a JRE is available and either bridge_jar_path or binary_path is configured."
180+
.to_string(),
181+
})
181182
}
182183

183184
/// Load using the bridge JAR strategy.
@@ -233,19 +234,6 @@ fn load_with_updatesql(
233234
Ok(all_units)
234235
}
235236

236-
/// Load using the lightweight XML fallback parser.
237-
fn load_with_xml_fallback(paths: &[PathBuf]) -> Result<Vec<RawMigrationUnit>, LoadError> {
238-
let loader = super::liquibase_xml::XmlFallbackLoader;
239-
let mut all_units = Vec::new();
240-
241-
for path in paths {
242-
let units = loader.load(path)?;
243-
all_units.extend(units);
244-
}
245-
246-
Ok(all_units)
247-
}
248-
249237
#[cfg(test)]
250238
mod tests {
251239
use super::*;

0 commit comments

Comments
 (0)