Skip to content

Commit

Permalink
feat(cli): add option to generate definitions for all classes inside …
Browse files Browse the repository at this point in the history
…a jar (#6)
  • Loading branch information
MarkusJx authored Feb 1, 2025
1 parent 65991bc commit ae64b16
Show file tree
Hide file tree
Showing 12 changed files with 1,536 additions and 1,268 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [22.x]

steps:
- uses: actions/checkout@v3
Expand Down
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ Options:

### Notes

- The classpath argument can be supplied multiple times to add multiple jars to the classpath
- Multiple class names can be supplied to generate definitions for multiple classes
- The generated typescript files will automatically import all classes once the module is loaded.
- The classpath argument can be supplied multiple times to add multiple jars to the classpath
- Multiple class names can be supplied to generate definitions for multiple classes
- The generated typescript files will automatically import all classes once the module is loaded.
- If a glob pattern, e.g. `com.github.*`, is supplied for the class names, all supplied jars will be searched against that glob pattern. Definitions for all matching classes will be generated. This does not work for classes supplied by the JVM.

### Examples

Expand Down Expand Up @@ -74,6 +75,14 @@ and save them to `./project`:
java-ts-gen ./project java.lang.String java.util.ArrayList
```

#### Generate definitions for all classes inside a JAR

Generate definitions for all classes inside the package `com.github` and save them to `./project`:

```bash
java-ts-gen --cp /path/to/my.jar ./project com.github.*
```

## Library usage

```ts
Expand All @@ -94,10 +103,10 @@ await TypescriptDefinitionGenerator.save('./project');

The java declaration tree can be generated using two generators:

- `JavaDefinitionGenerator`: This generator is the fastest, as it is written in Java.
Requires Java 11 or higher.
- `TsDefinitionGenerator`: This one is slower than the `JavaDefinitionGenerator` as it
is written in Typescript, but it works with any Java version.
- `JavaDefinitionGenerator`: This generator is the fastest, as it is written in Java.
Requires Java 11 or higher.
- `TsDefinitionGenerator`: This one is slower than the `JavaDefinitionGenerator` as it
is written in Typescript, but it works with any Java version.

The best generator is automatically picked when instantiating the `TypescriptDefinitionGenerator`
class. If you still want to choose the generator yourself, you can pass an instance of
Expand Down
8 changes: 4 additions & 4 deletions java-src/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ repositories {

dependencies {
implementation 'com.google.code.gson:gson:2.10.1'
compileOnly 'org.projectlombok:lombok:1.18.28'
annotationProcessor 'org.projectlombok:lombok:1.18.28'
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'

testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
testCompileOnly 'org.projectlombok:lombok:1.18.28'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.28'
testCompileOnly 'org.projectlombok:lombok:1.18.34'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
}

test {
Expand Down
Loading

0 comments on commit ae64b16

Please sign in to comment.