Skip to content

Modernise build system to align with apex-parser 5.x #6

@kjonescertinia

Description

@kjonescertinia

Context

apex-parser 5.x has moved to ANTLR 4.13.2 (Java) and the official antlr4 JS runtime (replacing the abandoned antlr4ts fork). Downstream consumers that pull both apex-parser and vf-parser now hit conflicting ANTLR runtimes — different Java versions, and on the JS side a different package altogether.

Possible end state is to merge the two libraries; this ticket scopes the modernisation of vf-parser's build system as a precursor so the merge is straightforward rather than a forced rewrite.

Scope

Build orchestration

  • Replace antlr4-maven-plugin (4.8-1) with exec-maven-plugin driving org.antlr.v4.Tool 4.13.2, plus build-helper-maven-plugin to add generated sources (mirror apex-parser/jvm/pom.xml).
  • Add a second pom.xml in npm/ to generate the TypeScript parser via the same Java tool with -Dlanguage=TypeScript.
  • Point both generators at the shared /antlr dir; remove the init-npm/init-jvm cp scripts and the per-target .g4 copies.
  • Rework root package.json scripts to init / init:jvm / init:npm / build:jvm / build:npm.

npm package — antlr4tsantlr4 migration (the risky bit)

  • Replace antlr4ts 0.5.0-alpha.4 with bundled antlr4 4.13.2 (bundleDependencies).
  • Rewrite npm/src/index.ts and ThrowingErrorListener.ts against the new runtime API; update __tests__/PageParserTest.ts.
  • Replace the node patch (shelljs sed) post-processing with patch-package + patches/antlr4+4.13.2.patch.
  • Move to ESM: "type": "module", exports map, .js import suffixes, dist/ output.
  • tsconfig: target: es2022, module: node20, strict: true.
  • Move tests to top-level test/ dir; update jestconfig.json regex to dist/test/.*Test.js$.
  • ESLint v7 legacy .eslintrc.js → ESLint v10 flat eslint.config.js with typescript-eslint v8.
  • Add npm/.npmrc with node-options='--experimental-vm-modules' for Jest ESM.

jvm package

  • Bump JUnit 5.1.0 → 5.14.3 (junit-jupiter-enginejunit-jupiter).
  • Bump Maven plugins (compiler, surefire, jar, source, gpg, javadoc, dependency) to current versions.
  • <source>1.8</source><target>1.8</target><release>8</release>.
  • Add antlr4 as <scope>provided</scope> dep so generator JAR is on the classpath.
  • Replace nexus-staging-maven-plugin (legacy OSSRH) with central-publishing-maven-plugin 0.10.0 (Sonatype Central Portal).
  • Drop the s01.oss.sonatype.org <repositories> block; add central-portal-snapshots.

CI / publishing

  • Bump GitHub Actions: checkout v3→v6, setup-node v3→v6, setup-java v3→v5; Node 14→22; JDK 8→11.
  • Drop submodules: recursive (no submodules).
  • Two-step build in Build.yml: npm run init then npm run build.
  • PublishMaven.yml: server-id: ossrhcentral to match the new publishing plugin.
  • Align PublishNPM.yml script names with the new init/build layout.

Dev tooling (additive)

  • Add husky + lint-staged (root + per-package configs).
  • Add prettier + prettier-plugin-java.
  • Add .github/dependabot.yml covering /, /npm, /jvm, and github-actions.
  • Add a root .gitignore (.metals/, .vscode/, .idea/, node_modules/).

Suggested PR ordering

  1. JVM pom modernisation + ANTLR 4.13.2 runtime — compiles independently.
  2. npm side: rewrite for antlr4 runtime + ESM/tsconfig/eslint modernisation (entangled, single PR).
  3. CI workflow bumps + Sonatype Central publishing switch.
  4. Husky/prettier/lint-staged/dependabot — purely additive.

Risk

The npm-side runtime swap (step 2) is a real rewrite, not a renumber — the generated TS classes have a different shape and the imports change substantially. Reference apex-parser/npm/src/{index,ApexErrorListener,ApexParserFactory}.ts as the template.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions