Skip to content

Commit fa8bab3

Browse files
feat: remove XMLBeans dependency from metaschema-testing module
Replace XMLBeans with Metaschema bindings in the metaschema-testing module: - Create YAML Metaschema module (unit-tests.yaml) to replace XSD schema - Configure metaschema-maven-plugin for binding class generation - Update AbstractTestSuite.java to use generated Metaschema bindings - Remove XMLBeans handler classes and configuration files - Remove XMLBeans from parent POM (dependencies, plugin, javadoc exclusions) - Clean up leftover XMLBeans artifacts in databind module - Update documentation to reflect YAML-first approach This completes the XMLBeans removal initiative. No XMLBeans references remain in the codebase.
1 parent 738faf0 commit fa8bab3

File tree

15 files changed

+350
-329
lines changed

15 files changed

+350
-329
lines changed

CLAUDE.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,18 @@ Metapath is an implementation of XPath 3.1. The [XPath 3.1 specification](https:
102102
### Generated Code
103103

104104
Code generation occurs during Maven build:
105-
- **XMLBeans**: Generated from XSD schemas in `core/metaschema/schema/xml`
105+
- **Metaschema bindings**: Generated from Metaschema modules via metaschema-maven-plugin
106106
- **ANTLR4**: Metapath parser from `core/src/main/antlr4`
107107

108108
Generated sources are placed in `target/generated-sources/` and excluded from style checks.
109109

110+
### Metaschema Module Authoring
111+
112+
**YAML-first approach**: When creating new Metaschema modules, prefer YAML format over XML.
113+
- YAML modules use `.yaml` extension and are stored in `src/main/metaschema/`
114+
- Use the JSON schema at `databind-metaschema/target/generated-resources/schema/json/metaschema-model_schema.json` for IDE validation
115+
- Reference existing YAML modules (e.g., `databind/src/main/metaschema/metaschema-bindings.yaml`) for structure examples
116+
110117
### Key Interfaces
111118

112119
- `IModule` - Represents a Metaschema module with definitions
@@ -168,7 +175,7 @@ Checkstyle enforces these rules (configured in [oss-maven checkstyle.xml](https:
168175
Exceptions (no Javadoc required):
169176
- `@Override` methods (inherit documentation)
170177
- `@Test` methods (use descriptive names)
171-
- Generated code (`*.xmlbeans`, `*.antlr` packages)
178+
- Generated code (`*.antlr` packages)
172179

173180
```bash
174181
# Check Javadoc compliance

PRDs/20251221-xmlbeans-removal/implementation-plan.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Use this schema for IDE validation when authoring the YAML Metaschema modules.
124124
| **Risk Level** | Low |
125125
| **Dependencies** | PR 1 |
126126
| **Target Branch** | develop |
127-
| **Status** | Pending |
127+
| **Status** | Ready for PR |
128128
| **Pull Request** | |
129129

130130
#### Files to Create
@@ -177,19 +177,19 @@ Use this schema for IDE validation when authoring the YAML Metaschema modules.
177177

178178
#### Acceptance Criteria
179179

180-
- [ ] Metaschema module created at `metaschema-testing/src/main/metaschema/unit-tests.yaml`
181-
- [ ] metaschema-maven-plugin configured in testing POM
182-
- [ ] `AbstractTestSuite.java` uses generated binding classes
183-
- [ ] No XMLBeans imports in metaschema-testing module
184-
- [ ] XMLBeans dependency removed from `metaschema-testing/pom.xml`
185-
- [ ] XMLBeans removed from parent `pom.xml`
186-
- [ ] XSD file deleted from `core/metaschema/test-suite/`
187-
- [ ] XMLBeans handler package deleted
188-
- [ ] Existing test suite files parse correctly
189-
- [ ] All metaschema-testing tests pass
190-
- [ ] All dependent module tests pass
191-
- [ ] Full CI build succeeds: `mvn install -PCI -Prelease`
192-
- [ ] No XMLBeans references remain in codebase (verify with grep)
180+
- [x] Metaschema module created at `metaschema-testing/src/main/metaschema/unit-tests.yaml`
181+
- [x] metaschema-maven-plugin configured in testing POM
182+
- [x] `AbstractTestSuite.java` uses generated binding classes
183+
- [x] No XMLBeans imports in metaschema-testing module
184+
- [x] XMLBeans dependency removed from `metaschema-testing/pom.xml`
185+
- [x] XMLBeans removed from parent `pom.xml`
186+
- [x] XSD file deleted from `core/metaschema/test-suite/`
187+
- [x] XMLBeans handler package deleted
188+
- [x] Existing test suite files parse correctly
189+
- [x] All metaschema-testing tests pass
190+
- [x] All dependent module tests pass
191+
- [x] Full CI build succeeds: `mvn install -PCI -Prelease`
192+
- [x] No XMLBeans references remain in codebase (verify with grep)
193193

194194
---
195195

databind/spotbugs-exclude.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
66
<Match>
77
<Or>
8-
<Package name="~gov\.nist\.secauto\.metaschema\.databind\.codegen\.xmlbeans\.*" />
98
<Bug pattern="EI_EXPOSE_REP" />
109
<Bug pattern="EI_EXPOSE_REP2" />
1110
</Or>

databind/src/main/java/org/apache/xmlbeans/metadata/system/metaschema/codegen/package-info.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/javadoc-style-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This guide defines the Javadoc requirements for the metaschema-java project, bas
77
The project's `pom.xml` configures `maven-javadoc-plugin` with:
88
- `failOnWarnings: false` - Javadoc warnings do not fail the build (currently)
99
- `failOnError: false` - Javadoc errors do not fail the build (currently)
10-
- Excluded packages: `*.xmlbeans`, `*.xmlbeans.*`, `*.antlr` (generated code)
10+
- Excluded packages: `*.antlr` (generated code)
1111

1212
**Important**: While these settings currently allow builds to pass with Javadoc issues, the goal is to progressively improve documentation coverage until these can be set to `true`.
1313

@@ -351,6 +351,6 @@ When working in a file, consider documenting nearby undocumented members, especi
351351
### Excluded Code
352352

353353
Do not add Javadoc to:
354-
- Generated code (`*.xmlbeans`, `*.antlr` packages)
354+
- Generated code (`*.antlr` packages)
355355
- `module-info.java` files
356356
- Test classes and methods (use descriptive method names instead)

metaschema-testing/pom.xml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
<groupId>${project.groupId}</groupId>
3333
<artifactId>metaschema-databind</artifactId>
3434
</dependency>
35-
<dependency>
36-
<groupId>org.apache.xmlbeans</groupId>
37-
<artifactId>xmlbeans</artifactId>
38-
</dependency>
3935
<dependency>
4036
<groupId>org.apache.logging.log4j</groupId>
4137
<artifactId>log4j-core</artifactId>
@@ -53,46 +49,50 @@
5349
</dependencies>
5450

5551
<build>
56-
<resources>
57-
<resource>
58-
<directory>src/main/resources</directory>
59-
</resource>
60-
<resource>
61-
<directory>${project.build.directory}/generated-resources/xmlbeans</directory>
62-
</resource>
63-
</resources>
6452
<pluginManagement>
6553
<plugins>
6654
<plugin>
6755
<groupId>org.apache.maven.plugins</groupId>
6856
<artifactId>maven-pmd-plugin</artifactId>
6957
<configuration>
7058
<excludeRoots>
71-
<excludeRoot>target/generated-sources/xmlbeans</excludeRoot>
59+
<excludeRoot>target/generated-sources/metaschema</excludeRoot>
7260
</excludeRoots>
7361
</configuration>
7462
</plugin>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-checkstyle-plugin</artifactId>
66+
<configuration>
67+
<excludes>**/gov/nist/secauto/metaschema/model/testing/binding/**/*</excludes>
68+
</configuration>
69+
</plugin>
70+
<plugin>
71+
<groupId>com.github.spotbugs</groupId>
72+
<artifactId>spotbugs-maven-plugin</artifactId>
73+
<configuration>
74+
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
75+
</configuration>
76+
</plugin>
7577
</plugins>
7678
</pluginManagement>
7779
<plugins>
7880
<plugin>
79-
<groupId>org.apache.xmlbeans</groupId>
80-
<artifactId>xmlbeans</artifactId>
81+
<groupId>${project.groupId}</groupId>
82+
<artifactId>metaschema-maven-plugin</artifactId>
83+
<version>${project.version}</version>
8184
<executions>
8285
<execution>
83-
<id>metaschema-testing-beans</id>
84-
<inherited>false</inherited>
86+
<id>generate-test-suite-bindings</id>
8587
<phase>generate-sources</phase>
8688
<goals>
87-
<goal>compile</goal>
89+
<goal>generate-sources</goal>
8890
</goals>
8991
<configuration>
90-
<xmlConfigs>${project.basedir}/src/schema/xmlconfig.xml</xmlConfigs>
91-
<sourceDir>${project.basedir}/../core/metaschema/test-suite</sourceDir>
92-
<sourceSchemas>unit-tests.xsd</sourceSchemas>
93-
<javaTargetDir>${project.build.directory}/generated-sources/xmlbeans</javaTargetDir>
94-
<classTargetDir>${project.basedir}/target/generated-resources/xmlbeans</classTargetDir>
95-
<name>metaschema.testing</name>
92+
<metaschemaDir>${project.basedir}/src/main/metaschema</metaschemaDir>
93+
<includes>
94+
<include>unit-tests.yaml</include>
95+
</includes>
9696
</configuration>
9797
</execution>
9898
</executions>
@@ -102,14 +102,14 @@
102102
<artifactId>build-helper-maven-plugin</artifactId>
103103
<executions>
104104
<execution>
105-
<id>add-xmlbeans-source</id>
105+
<id>add-generated-sources</id>
106106
<phase>generate-sources</phase>
107107
<goals>
108108
<goal>add-source</goal>
109109
</goals>
110110
<configuration>
111111
<sources>
112-
<source>${project.build.directory}/generated-sources/xmlbeans</source>
112+
<source>${project.build.directory}/generated-sources/metaschema</source>
113113
</sources>
114114
</configuration>
115115
</execution>

metaschema-testing/spotbugs-exclude.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
<Bug pattern="EI_EXPOSE_REP2" />
1010
</Or>
1111
</Match>
12+
<!-- Exclude generated binding classes -->
13+
<Match>
14+
<Package name="~gov\.nist\.secauto\.metaschema\.model\.testing\.binding.*" />
15+
</Match>
1216
</FindBugsFilter>

0 commit comments

Comments
 (0)