Skip to content

Unify typespec-java emitter and emitter-tests into one npm project - #5019

Open
XiaofeiCao wants to merge 11 commits into
Azure:mainfrom
XiaofeiCao:unify-typespec-java-emitter-tests
Open

Unify typespec-java emitter and emitter-tests into one npm project#5019
XiaofeiCao wants to merge 11 commits into
Azure:mainfrom
XiaofeiCao:unify-typespec-java-emitter-tests

Conversation

@XiaofeiCao

@XiaofeiCao XiaofeiCao commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #5008

What

Unify the @azure-tools/typespec-java emitter and its emitter-tests into a single npm project, matching how typespec-go and typespec-python are structured. Previously emitter-tests/ was a standalone npm + Maven project, deliberately excluded from the pnpm workspace, that consumed the emitter via a packed .tgz and pinned peer versions with npm overrides.

Why

typespec-java was the only language emitter whose e2e tests lived in a separate npm project. This required a bespoke pack + npm install flow (Build-TypeSpec.ps1), a second package.json/package-lock.json, an overrides block, and a core-driven version sync. Consolidating removes that maintenance overhead and makes Java consistent with the other emitters.

How

  • One npm project. The e2e scripts (regenerate, test:java:e2e, spector-*, sync-tests) and the spector/http-specs devDependencies (workspace:^) now live in the root packages/typespec-java/package.json. Removed emitter-tests/package.json, package-lock.json, and Build-TypeSpec.ps1/Setup.ps1/setup.py.
  • Emitter resolved by self-reference. Because emitter-tests/ no longer has its own package.json, emit: ["@azure-tools/typespec-java"] in emitter-tests/tspconfig.yaml resolves to the parent package via Node package self-reference (no .tgz, no --emit argument). tsp compile <spec>.tsp works directly.
  • Harness scripts moved to the package root (Generate.ps1, Spector-Tests.ps1, SyncTests.ps1); they Push-Location/Set-Location into emitter-tests/ for the Maven/tsp work.
  • CI/ADO run via pnpm run regenerate / pnpm run test:java:e2e with working-directory: packages/typespec-java (ci-java.yml, nightly-e2e.yml, spector-coverage.yml).
  • Updated .gitignore/.prettierignore and developer docs; removed an orphaned tsp-checkout.sh.

Behavioral note

The e2e tests now run against the workspace/dev peer versions (via the catalog), like typespec-go/python, instead of the previously pinned released versions. CONTRIBUTING.md now documents the unified workspace build using the repository’s safe Turbo wrapper.

Validation

  • pnpm build (Maven jar + tsc) succeeds.
  • pnpm run regenerate generates the full local + http-specs/azure-http-specs suites through the self-reference emitter (2800+ Java files).
  • pnpm install --frozen-lockfile is consistent.

XiaofeiCao and others added 4 commits July 22, 2026 17:07
emitter-tests is no longer a standalone npm project consuming a packed
.tgz; it is now part of the @azure-tools/typespec-java workspace package.
The e2e Maven+tsp assets remain under emitter-tests/, but the harness
scripts (Generate.ps1, Spector-Tests.ps1, SyncTests.ps1) moved to the
package root and run against the workspace build, resolving the locally
built emitter via an explicit --emit <package-root> (like typespec-go).

- package.json: add regenerate/test:java:e2e/spector-* scripts and
  spector/http-specs workspace:^ devDeps; drop overrides/.tgz flow
- remove Build-TypeSpec.ps1, emitter-tests/{package.json,Setup.ps1,setup.py}
- CI/ADO: run via pnpm scripts with working-directory packages/typespec-java
- update .gitignore/.prettierignore and developer docs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bdf71a18-d69d-45d1-a513-08b63a71d4e3
…-emitter-tests

# Conflicts:
#	packages/typespec-java/emitter-tests/package.json
The upstream backmerge (Azure#5014) modified emitter-tests/package.json while
this branch had deleted it; the take-incoming merge resurrected it. Remove
it again to keep the unified single-npm-project layout, and restore the
../node_modules spec-copy paths in Generate.ps1 that the merge reverted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bdf71a18-d69d-45d1-a513-08b63a71d4e3
Unused one-off sparse-checkout helper for an external repo; not referenced
by any script, CI, or pom, and not part of the core sync source.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bdf71a18-d69d-45d1-a513-08b63a71d4e3
@microsoft-github-policy-service microsoft-github-policy-service Bot added eng emitter:java Issues for @azure-tools/typespec-java emitter labels Jul 22, 2026
@azure-sdk-automation

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @azure-tools/typespec-java
Show changes

@azure-tools/typespec-java - internal ✏️

Unify the emitter and its e2e tests into a single npm project: emitter-tests is no longer a standalone npm project consuming a packed .tgz, but part of the @azure-tools/typespec-java workspace package. The e2e tests now run against the workspace build via pnpm run regenerate / pnpm run test:java:e2e, resolving the locally built emitter by package name through Node self-reference (the emitter-tests folder has no package.json, so emit: ["@azure-tools/typespec-java"] in its tspconfig.yaml resolves to the parent package).

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-java@5019

commit: fb7b7d9

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

XiaofeiCao and others added 5 commits July 23, 2026 11:00
Spector JUnit tests (Multipart/File/Encode/SharedRoute) read
node_modules/@typespec/http-specs/assets/image.{jpg,png} relative to the
Maven working directory (emitter-tests/). After unifying into one npm
project, node_modules moved to the typespec-java package root, so the
assets resolved from emitter-tests/ no longer exist (FileNotFoundException).

FileUtils.java is synced verbatim from core, so carry the Azure-specific
edit (../node_modules) as core.test.patch, applied by SyncTests.ps1 after
each sync (mirroring Copy-Sources.ps1's core.patch). Unlike core.patch, the
patched sources are committed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bdf71a18-d69d-45d1-a513-08b63a71d4e3
…-emitter-tests

# Conflicts:
#	pnpm-lock.yaml
Comment thread packages/typespec-java/core.test.patch
…-emitter-tests

# Conflicts:
#	packages/typespec-java/Generate.ps1
#	packages/typespec-java/emitter-tests/package.json
#	packages/typespec-java/package.json
#	pnpm-lock.yaml
@XiaofeiCao
XiaofeiCao added this pull request to the merge queue Jul 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:java Issues for @azure-tools/typespec-java emitter eng

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typespec-java, eng, Consider use same npm project for emitter and emitter-test

3 participants