Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft committed Jan 17, 2025
1 parent fdae342 commit 86e1d78
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions packages/http-client-java/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ Install [Java](https://docs.microsoft.com/java/openjdk/download) 17 or above. (V

Install [Maven](https://maven.apache.org/download.cgi). (Verify by running `mvn --version`)

## Project Structure

The TypeSpec Java Emitter Library is a Node.js package.
It publishes to [npm `@typespec/http-client-java`](https://www.npmjs.com/package/@typespec/http-client-java).

As a Node.js package, the entry of the library is written in TypeScript, under `emitter` folder.

As a Java code generator, part of the implementation is written in Java, under `generator` folder.
Java code is packaged into a JAR file, and included in the Node.js package. The JAR file is called at runtime by TypeScript code.

## Build and Pack

["Setup.ps1" script](https://github.com/microsoft/typespec/blob/main/packages/http-client-java/Setup.ps1) builds TypeScript code and Java code, and packs them into "typespec-http-client-java-[version].tgz".
Expand All @@ -29,23 +39,32 @@ Their folder structure is identical. In the following sub-sections, the script o

### Set-up the environment

"Setup.ps1" script builds the emitter, and sets up the test environment.
["Setup.ps1" script in test module](https://github.com/microsoft/typespec/blob/main/packages/http-client-java/generator/http-client-generator-clientcore-test/Setup.ps1) builds the emitter, and sets up the test environment.

Internally, it does

1. Build the `@typespec/http-client-java` tgz locally. See [Build and Pack](#build-and-pack).
2. Re-install the tgz (along with other dependencies) in the test module.

### Generate the test code

If the feature or bug fix involves code change on generated code, you will need to re-generate the test code in one or both of the test modules.

"Generate.ps1" script (internally it calls "Setup.ps1" script as 1st step) generates the code for end-to-end testing.
The code is generated from TypeSpec source in [`@typespec/http-specs` package](https://www.npmjs.com/package/@typespec/http-specs).
["Generate.ps1" script](https://github.com/microsoft/typespec/blob/main/packages/http-client-java/generator/http-client-generator-clientcore-test/Generate.ps1) (internally it calls the "Setup.ps1" script) generates the code for end-to-end testing.
The code is generated from TypeSpec source from [npm `@typespec/http-specs` package](https://www.npmjs.com/package/@typespec/http-specs).

### Run the end-to-end tests

1. Start the test server with `npm run spector-serve` (or `npm run spector-start` to start as a background process, `npm run spector-stop` to stop)
2. Run all the Java tests in the module
["Spector-Tests.ps1" script](https://github.com/microsoft/typespec/blob/main/packages/http-client-java/generator/http-client-generator-clientcore-test/Spector-Tests.ps1) starts the spector server, and run all the Java tests.

When writing / updating Java tests, you can manually

1. Start the test server with `npm run spector-serve` (or `npm run spector-start` to start as a background process, `npm run spector-stop` to stop).
2. Run the Java tests in the module.

## Format Code

Before creating pull request, you are required to format the code.
Before creating pull request, the code is required to be well-formatted.

Run `npm run format` in "packages/http-client-java" folder.
It formats TypeScript code as well as Java code.

0 comments on commit 86e1d78

Please sign in to comment.