-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Java support #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
eeb3aca
341be49
82687d9
225a06c
46a7697
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,39 @@ The output directory will include a python module that corresponds to the | |
| original module. This code depends on the following python modules: | ||
|
|
||
| - [jsii](https://pypi.org/project/jsii/) | ||
| - [publication](https://pypi.org/project/publication/) | ||
|
|
||
| ### Java Output | ||
|
|
||
| To produce a Java module from your source, use the `java` option: | ||
|
|
||
| ```ts | ||
| await srcmak('srcdir', { | ||
| java: { | ||
| outdir: '/path/to/project/root', | ||
| package: 'hello.world', | ||
| maven: { | ||
| groupId: 'hello', | ||
| artifactId: 'world', | ||
| }, | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| Or the `--java-*` switches in the CLI: | ||
|
|
||
| ```bash | ||
| $ jsii-srcmak /src/dir --java-outdir=dir --java-package-name=hello.world --java-maven-group-id hello --java-maven-artifact-id world | ||
| ``` | ||
|
|
||
| * The `outdir`/`--java-outdir` option points to the root directory of your Java project. | ||
| * The `packageName`/`--java-package-name` option is the java package name. | ||
|
campionfellin marked this conversation as resolved.
Outdated
|
||
| * The `maven { groupId }`/`--java-maven-group-id` option is the maven group id. | ||
| * The `maven { artifactId }`/`--java-maven-artifact-id` option is the maven artifact id. | ||
|
campionfellin marked this conversation as resolved.
Outdated
|
||
|
|
||
| The output directory will include a java module that corresponds to the | ||
| original module. This code depends on the following java modules: | ||
|
campionfellin marked this conversation as resolved.
Outdated
|
||
|
|
||
| - [jsii](https://mvnrepository.com/artifact/software.amazon.jsii) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also worth mentioning that the output will include a tarball resource that must be bundled in the project (maybe provide an example snippet from a |
||
|
|
||
| ### Entrypoint | ||
|
|
||
|
|
@@ -115,6 +147,21 @@ Or through the CLI: | |
| $ jsii-srcmak /src/dir --dep node_modules/@types/node --dep node_modules/constructs | ||
| ``` | ||
|
|
||
| ## Contributing | ||
|
campionfellin marked this conversation as resolved.
|
||
|
|
||
| To build this project, you must first generate the `package.json`: | ||
|
|
||
| ``` | ||
| npx projen | ||
| ``` | ||
|
|
||
| Then you can install your dependencies and build: | ||
|
|
||
| ``` | ||
| yarn install | ||
| yarn build | ||
| ``` | ||
|
|
||
| ## What's with this name? | ||
|
|
||
| It's a silly little pun that stems from another pun: jsii has `jsii-pacmak` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,12 @@ export interface Options { | |
| * @default - python is not generated | ||
| */ | ||
| python?: PythonOutputOptions; | ||
|
|
||
| /** | ||
| * Produce java code. | ||
| * @default - java is not generated | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a note here that says that the code will be produced under |
||
| */ | ||
| java?: JavaOutputOptions; | ||
| } | ||
|
|
||
| export interface JsiiOutputOptions { | ||
|
|
@@ -32,7 +38,7 @@ export interface JsiiOutputOptions { | |
| path: string; | ||
| } | ||
|
|
||
| export interface PythonOutputOptions { | ||
| export interface PythonOutputOptions { | ||
| /** | ||
| * Base root directory. | ||
| */ | ||
|
|
@@ -43,3 +49,31 @@ export interface PythonOutputOptions { | |
| */ | ||
| moduleName: string; | ||
| } | ||
|
|
||
| export interface JavaOutputOptions { | ||
| /** | ||
| * Base root directory. | ||
| */ | ||
| outdir: string; | ||
|
|
||
| /** | ||
| * The name of the java package to generate | ||
| */ | ||
| package: string; | ||
|
|
||
| /** | ||
| * The maven info for this package | ||
|
campionfellin marked this conversation as resolved.
Outdated
|
||
| */ | ||
| maven: { | ||
|
|
||
| /** | ||
| * The maven group id | ||
| */ | ||
| groupId: string; | ||
|
|
||
| /** | ||
| * The maven artifact id | ||
| */ | ||
| artifactId?: string; | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,5 +33,12 @@ export async function srcmak(srcdir: string, options: Options = { }) { | |
| const target = path.join(options.python.outdir, reldir); | ||
| await fs.move(source, target, { overwrite: true }); | ||
| } | ||
|
|
||
| if (options.java) { | ||
| const reldir = options.java.package.replace(/\./g, '/'); | ||
| const source = path.resolve(path.join(workdir, 'dist/java/src/main/java', reldir)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it |
||
| const target = path.join(options.java.outdir, 'src/main' , reldir); | ||
| await fs.move(source, target, { overwrite: true }); | ||
| } | ||
| }); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.