Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-java"
---

Replace the Java emitter's PowerShell build and test automation with native TypeScript scripts.
2 changes: 1 addition & 1 deletion .github/workflows/ci-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: pnpm install

# The emitter compiles against these peer packages; `pnpm run regenerate`
# (Generate.ps1) runs `pnpm build` for the emitter, which needs them already
# (eng/scripts/generate.ts) runs `pnpm build` for the emitter, which needs them already
# built.
- name: Build dependencies
run: pnpm turbo run --filter "@azure-tools/typespec-java^..." build
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/jobs/spector-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ jobs:
# then regenerates the SDK from the spector specs. `pnpm run test:java:e2e`
# starts the mock server, runs the JUnit tests and produces
# tsp-spector-coverage-java.json.
- pwsh: pnpm run regenerate
- script: pnpm run regenerate
displayName: "Regenerate Java test code"
workingDirectory: packages/typespec-java

- pwsh: pnpm run test:java:e2e
- script: pnpm run test:java:e2e
displayName: "Run Java spector tests"
workingDirectory: packages/typespec-java

Expand Down
31 changes: 0 additions & 31 deletions packages/typespec-java/Build-Generator.ps1

This file was deleted.

22 changes: 11 additions & 11 deletions packages/typespec-java/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio

Only `src/options.ts` (the Azure-specific emitter options) is committed in this package. The rest of
the emitter TypeScript (and tests) is copied from `core/packages/http-client-java/emitter/{src,test}`
at build time by `Copy-Sources.ps1` (excluding `options.ts`). The Java `emitter.jar` is
built by `Build-Generator.ps1` from a patched copy of `core/packages/http-client-java/generator`
at build time by `eng/scripts/copy-sources.ts` (excluding `options.ts`). The Java `emitter.jar` is
built by `eng/scripts/build-generator.ts` from a patched copy of `core/packages/http-client-java/generator`
(see below) and staged into `generator/http-client-generator/target/`.

### Azure customization patch

`Copy-Sources.ps1` copies the Java generator sources out of the `core/` submodule into this
`eng/scripts/copy-sources.ts` copies the Java generator sources out of the `core/` submodule into this
package's `./generator` folder and applies `core.patch` to that **copy** — never to `core/` itself.
The patch swaps the unbranded customization engine in `http-client-generator-core` for Azure's
`com.azure.tools:azure-autorest-customization` (resolved from Maven Central), so the
`customization-class` emitter option runs against the Azure customization base. `Build-Generator.ps1`
`customization-class` emitter option runs against the Azure customization base. `eng/scripts/build-generator.ts`
then builds `emitter.jar` from the patched `./generator`. Because the patch is only ever applied to
the copy, the `core/` submodule working tree stays clean. When the `core/` submodule is bumped,
refresh `core.patch` if its context no longer applies.
Expand All @@ -48,7 +48,7 @@ pnpm run-all --filter "@azure-tools/typespec-java..." build

### Pinning the core commit (`core-commit.json`)

`Copy-Sources.ps1` reads the emitter/generator sources from the `core/` submodule's current checkout.
`eng/scripts/copy-sources.ts` reads the emitter/generator sources from the `core/` submodule's current checkout.
The optional `core-commit.json` pins a specific upstream `core` commit to read from instead:

```json
Expand All @@ -68,7 +68,7 @@ If `pnpm turbo ...` fails with `'turbo' is not recognized as an internal or exte
after `pnpm install`, the local install tree is missing Turbo's binary shim. From the repo root,
force pnpm to refresh the local install state and rerun the command:

```powershell
```bash
pnpm install --force
pnpm run-all --filter "@azure-tools/typespec-java..." build
```
Expand All @@ -95,7 +95,7 @@ Attach a debugger to port 9229 and set breakpoints in `src/emitter.ts`,
TypeScript passes the code model and emitter options to Java through the generated
`emitter-tests/tsp-output/code-model.yaml` file. To debug the Java generator directly:

1. Build the package so `Copy-Sources.ps1` creates the patched generator copy under `generator/`.
1. Build the package so `eng/scripts/copy-sources.ts` creates the patched generator copy under `generator/`.
2. Update `DEFAULT_OUTPUT_DIR` in
`generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/Main.java`
to the directory containing the `code-model.yaml` to debug.
Expand Down Expand Up @@ -134,8 +134,8 @@ Pulls the fix in from core; **no version bump**. Example:
`sha` in [`core-commit.json`](./core-commit.json) to the target microsoft/typespec commit
(e.g. the HEAD of core `main`). Build and sync scripts transiently check this commit out without
moving the submodule pointer.
2. **Sync tests from core.** Run `pwsh ./SyncTests.ps1` in [`emitter-tests`](./emitter-tests): it
copies the tests/specs from the pinned core commit and aligns `emitter-tests/package.json`.
2. **Sync tests from core.** Run `pnpm sync-tests`: it copies the tests/specs from the pinned core
commit.
3. **Add a `fix` changelog entry** for the fix (`pnpm change add`).

Open the PR against `release/<sprint>` (not `main`) and merge it. _(Optional)_ Before merging,
Expand All @@ -149,8 +149,8 @@ Bumps the version and publishes, after Part A merges. Example:
[#4990](https://github.com/Azure/typespec-azure/pull/4990). Prepare the version bump per the
`hotfix-release` skill (creates the `publish/hotfix/<name>-<sprint>` branch off `release/<sprint>`
and runs `pnpm chronus version --ignore-policies`, consuming the changeset from Part A). The `core`
submodule stays unchanged. The bump must also be reflected in `emitter-tests/package.json` (its
`version` and the `*.tgz` dependency) — rerun `pwsh ./SyncTests.ps1` or update it manually.
submodule stays unchanged. The `emitter-tests/` folder is part of the parent workspace package, so
it requires no separate version update.

Open the PR against `release/<sprint>`. After it merges:

Expand Down
76 changes: 0 additions & 76 deletions packages/typespec-java/Copy-Sources.ps1

This file was deleted.

151 changes: 0 additions & 151 deletions packages/typespec-java/CoreCommit.ps1

This file was deleted.

Loading
Loading