diff --git a/API.md b/API.md index e49519c5c33..66065dbb684 100644 --- a/API.md +++ b/API.md @@ -48,6 +48,9 @@ Name|Description [Version](#projen-version)|*No description* [XmlFile](#projen-xmlfile)|Represents an XML file. [YamlFile](#projen-yamlfile)|Represents a YAML file. +[awscdk.AwsCdkJavaApp](#projen-awscdk-awscdkjavaapp)|AWS CDK app in Java. +[awscdk.CdkConfig](#projen-awscdk-cdkconfig)|Represents cdk.json file. +[awscdk.CdkTasks](#projen-awscdk-cdktasks)|Adds standard AWS CDK tasks to your project. [deps.Dependencies](#projen-deps-dependencies)|The `Dependencies` component is responsible to track the list of dependencies a project has, and then used by project types as the model for rendering project-specific dependency manifests such as the dependencies section `package.json` files. [git.GitAttributesFile](#projen-git-gitattributesfile)|Assign attributes to file names in a git repository. [github.AutoApprove](#projen-github-autoapprove)|Auto approve pull requests that meet a criteria. @@ -168,6 +171,9 @@ Name|Description [VersionOptions](#projen-versionoptions)|Options for `Version`. [XmlFileOptions](#projen-xmlfileoptions)|Options for `XmlFile`. [YamlFileOptions](#projen-yamlfileoptions)|Options for `JsonFile`. +[awscdk.AwsCdkJavaAppOptions](#projen-awscdk-awscdkjavaappoptions)|*No description* +[awscdk.CdkConfigCommonOptions](#projen-awscdk-cdkconfigcommonoptions)|Common options for `cdk.json`. +[awscdk.CdkConfigOptions](#projen-awscdk-cdkconfigoptions)|Options for `CdkJson`. [deps.Dependency](#projen-deps-dependency)|Represents a project dependency. [deps.DependencyCoordinates](#projen-deps-dependencycoordinates)|Coordinates of the dependency (name and version). [deps.DepsManifest](#projen-deps-depsmanifest)|*No description* @@ -186,6 +192,7 @@ Name|Description [github.StaleBehavior](#projen-github-stalebehavior)|Stale behavior. [github.StaleOptions](#projen-github-staleoptions)|Options for `Stale`. [github.TaskWorkflowOptions](#projen-github-taskworkflowoptions)|*No description* +[java.JavaProjectCommonOptions](#projen-java-javaprojectcommonoptions)|Options for `JavaProject`. [java.JavaProjectOptions](#projen-java-javaprojectoptions)|Options for `JavaProject`. [java.JunitOptions](#projen-java-junitoptions)|Options for `Junit`. [java.MavenCompileOptions](#projen-java-mavencompileoptions)|Options for `MavenCompile`. @@ -271,7 +278,6 @@ Name|Description Name|Description ----|----------- [AutoRelease](#projen-autorelease)|Automatic bump modes. -[CdkApprovalLevel](#projen-cdkapprovallevel)|*No description* [DockerComposeProtocol](#projen-dockercomposeprotocol)|Network protocol for port mapping. [GitpodOnOpen](#projen-gitpodonopen)|What to do when a service on a port is detected. [GitpodOpenIn](#projen-gitpodopenin)|Configure where in the IDE the terminal should be opened. @@ -285,6 +291,7 @@ Name|Description [Stability](#projen-stability)|*No description* [TypeScriptJsxMode](#projen-typescriptjsxmode)|Determines how JSX should get transformed into valid JavaScript. [TypeScriptModuleResolution](#projen-typescriptmoduleresolution)|Determines how modules get resolved. +[awscdk.ApprovalLevel](#projen-awscdk-approvallevel)|Which approval is required when deploying CDK apps. [deps.DependencyType](#projen-deps-dependencytype)|Type of dependency. [github.DependabotRegistryType](#projen-github-dependabotregistrytype)|Each configuration type requires you to provide particular settings. [github.DependabotScheduleInterval](#projen-github-dependabotscheduleinterval)|How often to check for new versions and raise pull requests for version updates. @@ -699,12 +706,14 @@ new AwsCdkTypeScriptApp(options: AwsCdkTypeScriptAppOptions) * **tsconfigDev** ([TypescriptConfigOptions](#projen-typescriptconfigoptions)) Custom tsconfig options for the development tsconfig.json file (used for testing). __*Default*__: use the production tsconfig options * **tsconfigDevFile** (string) The name of the development tsconfig.json file. __*Default*__: "tsconfig.dev.json" * **typescriptVersion** (string) TypeScript version to use. __*Default*__: "latest" + * **cdkout** (string) cdk.out directory. __*Default*__: "cdk.out" + * **context** (Map) Additional context to include in `cdk.json`. __*Default*__: no additional context + * **featureFlags** (boolean) Include all feature flags in cdk.json. __*Default*__: true + * **requireApproval** ([awscdk.ApprovalLevel](#projen-awscdk-approvallevel)) To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them. __*Default*__: ApprovalLevel.BROADENING * **cdkVersion** (string) AWS CDK version to use. * **appEntrypoint** (string) The CDK app's entrypoint (relative to the source directory, which is "src" by default). __*Default*__: "main.ts" * **cdkDependencies** (Array) Which AWS CDK modules (those that start with "@aws-cdk/") this app uses. __*Optional*__ * **cdkVersionPinning** (boolean) Use pinned version instead of caret version for CDK. __*Default*__: false - * **context** (Map) Additional context to include in `cdk.json`. __*Optional*__ - * **requireApproval** ([CdkApprovalLevel](#projen-cdkapprovallevel)) To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them. __*Default*__: CdkApprovalLevel.BROADENING @@ -714,7 +723,8 @@ new AwsCdkTypeScriptApp(options: AwsCdkTypeScriptAppOptions) Name | Type | Description -----|------|------------- **appEntrypoint**🔹 | string | The CDK app entrypoint. -**cdkConfig**🔹 | any | Contents of `cdk.json`. +**cdkConfig**🔹 | [awscdk.CdkConfig](#projen-awscdk-cdkconfig) | cdk.json configuration. +**cdkTasks**🔹 | [awscdk.CdkTasks](#projen-awscdk-cdktasks) | Common CDK tasks. **cdkVersion**🔹 | string | The CDK version this app is using. ### Methods @@ -5114,6 +5124,170 @@ __Returns__: +## class AwsCdkJavaApp 🔹 + +AWS CDK app in Java. + +__Submodule__: awscdk + +__Extends__: [java.JavaProject](#projen-java-javaproject) + +### Initializer + + + + +```ts +new awscdk.AwsCdkJavaApp(options: AwsCdkJavaAppOptions) +``` + +* **options** ([awscdk.AwsCdkJavaAppOptions](#projen-awscdk-awscdkjavaappoptions)) *No description* + * **name** (string) This is the name of your project. + * **logging** ([LoggerOptions](#projen-loggeroptions)) Configure logging options such as verbosity. __*Default*__: {} + * **outdir** (string) The root directory of the project. __*Default*__: "." + * **parent** ([Project](#projen-project)) The parent project, if this project is part of a bigger project. __*Optional*__ + * **projenrcJson** (boolean) Generate (once) .projenrc.json (in JSON). Set to `false` in order to disable .projenrc.json generation. __*Default*__: false + * **projenrcJsonOptions** ([json.ProjenrcOptions](#projen-json-projenrcoptions)) Options for .projenrc.json. __*Default*__: default options + * **autoApproveOptions** ([github.AutoApproveOptions](#projen-github-autoapproveoptions)) Enable and configure the 'auto approve' workflow. __*Default*__: auto approve is disabled + * **autoMergeOptions** ([github.AutoMergeOptions](#projen-github-automergeoptions)) Configure options for automatic merging on GitHub. __*Default*__: see defaults in `AutoMergeOptions` + * **clobber** (boolean) Add a `clobber` task which resets the repo to origin. __*Default*__: true + * **devContainer** (boolean) Add a VSCode development environment (used for GitHub Codespaces). __*Default*__: false + * **github** (boolean) Enable GitHub integration. __*Default*__: true + * **githubOptions** ([github.GitHubOptions](#projen-github-githuboptions)) Options for GitHub integration. __*Default*__: see GitHubOptions + * **gitpod** (boolean) Add a Gitpod development environment. __*Default*__: false + * **mergify** (boolean) Whether mergify should be enabled on this repository or not. __*Default*__: true + * **projectType** ([ProjectType](#projen-projecttype)) Which type of project this is (library/app). __*Default*__: ProjectType.UNKNOWN + * **readme** ([SampleReadmeProps](#projen-samplereadmeprops)) The README setup. __*Default*__: { filename: 'README.md', contents: '# replace this' } + * **stale** (boolean) Auto-close of stale issues and pull request. __*Default*__: true + * **staleOptions** ([github.StaleOptions](#projen-github-staleoptions)) Auto-close stale issues and pull requests. __*Default*__: see defaults in `StaleOptions` + * **vscode** (boolean) Enable VSCode integration. __*Default*__: true + * **artifactId** (string) The artifactId is generally the name that the project is known by. + * **groupId** (string) This is generally unique amongst an organization or a project. + * **version** (string) This is the last piece of the naming puzzle. + * **description** (string) Description of a project is always good. __*Default*__: undefined + * **packaging** (string) Project packaging format. __*Default*__: "jar" + * **url** (string) The URL, like the name, is not required. __*Default*__: undefined + * **compileOptions** ([java.MavenCompileOptions](#projen-java-mavencompileoptions)) Compile options. __*Default*__: defaults + * **deps** (Array) List of runtime dependencies for this project. __*Default*__: [] + * **distdir** (string) Final artifact output directory. __*Default*__: "dist/java" + * **junit** (boolean) Include junit tests. __*Default*__: true + * **junitOptions** ([java.JunitOptions](#projen-java-junitoptions)) junit options. __*Default*__: defaults + * **packagingOptions** ([java.MavenPackagingOptions](#projen-java-mavenpackagingoptions)) Packaging options. __*Default*__: defaults + * **projenrcJava** (boolean) Use projenrc in java. __*Default*__: true + * **projenrcJavaOptions** ([java.ProjenrcOptions](#projen-java-projenrcoptions)) Options related to projenrc in java. __*Default*__: default options + * **testDeps** (Array) List of test dependencies for this project. __*Default*__: [] + * **sample** (boolean) Include sample code and test if the relevant directories don't exist. __*Optional*__ + * **sampleJavaPackage** (string) The java package to use for the code sample. __*Default*__: "org.acme" + * **cdkout** (string) cdk.out directory. __*Default*__: "cdk.out" + * **context** (Map) Additional context to include in `cdk.json`. __*Default*__: no additional context + * **featureFlags** (boolean) Include all feature flags in cdk.json. __*Default*__: true + * **requireApproval** ([awscdk.ApprovalLevel](#projen-awscdk-approvallevel)) To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them. __*Default*__: ApprovalLevel.BROADENING + * **cdkVersion** (string) AWS CDK version to use (you can use semantic versioning). + * **mainClass** (string) The name of the Java class with the static `main()` method. + * **cdkDependencies** (Array) Which AWS CDK modules this app uses. __*Optional*__ + + + +### Properties + + +Name | Type | Description +-----|------|------------- +**cdkConfig**🔹 | [awscdk.CdkConfig](#projen-awscdk-cdkconfig) | The `cdk.json` file. +**cdkTasks**🔹 | [awscdk.CdkTasks](#projen-awscdk-cdktasks) | CDK tasks. +**cdkVersion**🔹 | string | The CDK version this app is using. +**mainClass**🔹 | string | The full name of the main class of the java app (package.Class). +**mainClassName**🔹 | string | The name of the Java class with the static `main()` method. +**mainPackage**🔹 | string | The name of the Java package that includes the main class. + +### Methods + + +#### addCdkDependency(...modules)🔹 + +Adds an AWS CDK module dependencies. + +```ts +addCdkDependency(...modules: string[]): void +``` + +* **modules** (string) The list of modules to depend on (e.g. "core", "aws-lambda", etc). + + + + + + +## class CdkConfig 🔹 + +Represents cdk.json file. + +__Submodule__: awscdk + +__Extends__: [Component](#projen-component) + +### Initializer + + + + +```ts +new awscdk.CdkConfig(project: Project, options: CdkConfigOptions) +``` + +* **project** ([Project](#projen-project)) *No description* +* **options** ([awscdk.CdkConfigOptions](#projen-awscdk-cdkconfigoptions)) *No description* + * **cdkout** (string) cdk.out directory. __*Default*__: "cdk.out" + * **context** (Map) Additional context to include in `cdk.json`. __*Default*__: no additional context + * **featureFlags** (boolean) Include all feature flags in cdk.json. __*Default*__: true + * **requireApproval** ([awscdk.ApprovalLevel](#projen-awscdk-approvallevel)) To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them. __*Default*__: ApprovalLevel.BROADENING + * **app** (string) The command line to execute in order to synthesize the CDK application (language specific). + + + +### Properties + + +Name | Type | Description +-----|------|------------- +**cdkout**🔹 | string | Name of the cdk.out directory. +**json**🔹 | [JsonFile](#projen-jsonfile) | Represents the JSON file. + + + +## class CdkTasks 🔹 + +Adds standard AWS CDK tasks to your project. + +__Submodule__: awscdk + +__Extends__: [Component](#projen-component) + +### Initializer + + + + +```ts +new awscdk.CdkTasks(project: Project) +``` + +* **project** ([Project](#projen-project)) *No description* + + + +### Properties + + +Name | Type | Description +-----|------|------------- +**deploy**🔹 | [tasks.Task](#projen-tasks-task) | Deploys your app. +**destroy**🔹 | [tasks.Task](#projen-tasks-task) | Destroys all the stacks. +**diff**🔹 | [tasks.Task](#projen-tasks-task) | Diff against production. +**synth**🔹 | [tasks.Task](#projen-tasks-task) | Synthesizes your app. + + + ## class Dependencies 🔹 The `Dependencies` component is responsible to track the list of dependencies a project has, and then used by project types as the model for rendering project-specific dependency manifests such as the dependencies section `package.json` files. @@ -5780,9 +5954,9 @@ new java.JavaProject(options: JavaProjectOptions) * **packagingOptions** ([java.MavenPackagingOptions](#projen-java-mavenpackagingoptions)) Packaging options. __*Default*__: defaults * **projenrcJava** (boolean) Use projenrc in java. __*Default*__: true * **projenrcJavaOptions** ([java.ProjenrcOptions](#projen-java-projenrcoptions)) Options related to projenrc in java. __*Default*__: default options + * **testDeps** (Array) List of test dependencies for this project. __*Default*__: [] * **sample** (boolean) Include sample code and test if the relevant directories don't exist. __*Optional*__ * **sampleJavaPackage** (string) The java package to use for the code sample. __*Default*__: "org.acme" - * **testDeps** (Array) List of test dependencies for this project. __*Default*__: [] @@ -5791,6 +5965,7 @@ new java.JavaProject(options: JavaProjectOptions) Name | Type | Description -----|------|------------- +**buildTask**🔹 | [tasks.Task](#projen-tasks-task) | The primary build task. **compile**🔹 | [java.MavenCompile](#projen-java-mavencompile) | Compile component. **distdir**🔹 | string | Maven artifact output directory. **packaging**🔹 | [java.MavenPackaging](#projen-java-mavenpackaging) | Packaging component. @@ -8694,11 +8869,12 @@ Name | Type | Description **bundledDeps**?🔹 | Array | List of dependencies to bundle into this module.
__*Optional*__ **cdkDependencies**?🔹 | Array | Which AWS CDK modules (those that start with "@aws-cdk/") this app uses.
__*Optional*__ **cdkVersionPinning**?🔹 | boolean | Use pinned version instead of caret version for CDK.
__*Default*__: false +**cdkout**?🔹 | string | cdk.out directory.
__*Default*__: "cdk.out" **clobber**?🔹 | boolean | Add a `clobber` task which resets the repo to origin.
__*Default*__: true **codeCov**?🔹 | boolean | Define a GitHub workflow step for sending code coverage metrics to https://codecov.io/ Uses codecov/codecov-action@v1 A secret is required for private repos. Configured with @codeCovTokenSecret.
__*Default*__: false **codeCovTokenSecret**?🔹 | string | Define the secret name for a specified https://codecov.io/ token A secret is required to send coverage for private repositories.
__*Default*__: if this option is not specified, only public repositories are supported **compileBeforeTest**?🔹 | boolean | Compile the code before running tests.
__*Default*__: if `testdir` is under `src/**`, the default is `true`, otherwise the default is `false`. -**context**?🔹 | Map | Additional context to include in `cdk.json`.
__*Optional*__ +**context**?🔹 | Map | Additional context to include in `cdk.json`.
__*Default*__: no additional context **copyrightOwner**?🔹 | string | License copyright owner.
__*Default*__: defaults to the value of authorName or "" if `authorName` is undefined. **copyrightPeriod**?🔹 | string | The copyright years to put in the LICENSE file.
__*Default*__: current year **dependabot**?🔹 | boolean | Use dependabot to handle dependency upgrades.
__*Default*__: false @@ -8716,6 +8892,7 @@ Name | Type | Description **entrypointTypes**?🔹 | string | The .d.ts file that includes the type declarations for this module.
__*Default*__: .d.ts file derived from the project's entrypoint (usually lib/index.d.ts) **eslint**?🔹 | boolean | Setup eslint.
__*Default*__: true **eslintOptions**?🔹 | [EslintOptions](#projen-eslintoptions) | Eslint options.
__*Default*__: opinionated default options +**featureFlags**?🔹 | boolean | Include all feature flags in cdk.json.
__*Default*__: true **github**?🔹 | boolean | Enable GitHub integration.
__*Default*__: true **githubOptions**?🔹 | [github.GitHubOptions](#projen-github-githuboptions) | Options for GitHub integration.
__*Default*__: see GitHubOptions **gitignore**?🔹 | Array | Additional entries to .gitignore.
__*Optional*__ @@ -8782,7 +8959,7 @@ Name | Type | Description **releaseWorkflowSetupSteps**?🔹 | Array<[github.workflows.JobStep](#projen-github-workflows-jobstep)> | A set of workflow steps to execute in order to setup the workflow container.
__*Optional*__ **repository**?🔹 | string | The repository is the location where the actual code for your package lives.
__*Optional*__ **repositoryDirectory**?🔹 | string | If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives.
__*Optional*__ -**requireApproval**?🔹 | [CdkApprovalLevel](#projen-cdkapprovallevel) | To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them.
__*Default*__: CdkApprovalLevel.BROADENING +**requireApproval**?🔹 | [awscdk.ApprovalLevel](#projen-awscdk-approvallevel) | To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them.
__*Default*__: ApprovalLevel.BROADENING **sampleCode**?🔹 | boolean | Generate one-time sample in `src/` and `test/` if there are no files there.
__*Default*__: true **scripts**?🔹 | Map | npm scripts to include.
__*Default*__: {} **srcdir**?🔹 | string | Typescript sources directory.
__*Default*__: "src" @@ -11250,6 +11427,94 @@ Name | Type | Description +## struct AwsCdkJavaAppOptions 🔹 + + + + + + +Name | Type | Description +-----|------|------------- +**artifactId**🔹 | string | The artifactId is generally the name that the project is known by. +**cdkVersion**🔹 | string | AWS CDK version to use (you can use semantic versioning). +**groupId**🔹 | string | This is generally unique amongst an organization or a project. +**mainClass**🔹 | string | The name of the Java class with the static `main()` method. +**name**🔹 | string | This is the name of your project. +**version**🔹 | string | This is the last piece of the naming puzzle. +**autoApproveOptions**?🔹 | [github.AutoApproveOptions](#projen-github-autoapproveoptions) | Enable and configure the 'auto approve' workflow.
__*Default*__: auto approve is disabled +**autoMergeOptions**?🔹 | [github.AutoMergeOptions](#projen-github-automergeoptions) | Configure options for automatic merging on GitHub.
__*Default*__: see defaults in `AutoMergeOptions` +**cdkDependencies**?🔹 | Array | Which AWS CDK modules this app uses.
__*Optional*__ +**cdkout**?🔹 | string | cdk.out directory.
__*Default*__: "cdk.out" +**clobber**?🔹 | boolean | Add a `clobber` task which resets the repo to origin.
__*Default*__: true +**compileOptions**?🔹 | [java.MavenCompileOptions](#projen-java-mavencompileoptions) | Compile options.
__*Default*__: defaults +**context**?🔹 | Map | Additional context to include in `cdk.json`.
__*Default*__: no additional context +**deps**?🔹 | Array | List of runtime dependencies for this project.
__*Default*__: [] +**description**?🔹 | string | Description of a project is always good.
__*Default*__: undefined +**devContainer**?🔹 | boolean | Add a VSCode development environment (used for GitHub Codespaces).
__*Default*__: false +**distdir**?🔹 | string | Final artifact output directory.
__*Default*__: "dist/java" +**featureFlags**?🔹 | boolean | Include all feature flags in cdk.json.
__*Default*__: true +**github**?🔹 | boolean | Enable GitHub integration.
__*Default*__: true +**githubOptions**?🔹 | [github.GitHubOptions](#projen-github-githuboptions) | Options for GitHub integration.
__*Default*__: see GitHubOptions +**gitpod**?🔹 | boolean | Add a Gitpod development environment.
__*Default*__: false +**junit**?🔹 | boolean | Include junit tests.
__*Default*__: true +**junitOptions**?🔹 | [java.JunitOptions](#projen-java-junitoptions) | junit options.
__*Default*__: defaults +**logging**?🔹 | [LoggerOptions](#projen-loggeroptions) | Configure logging options such as verbosity.
__*Default*__: {} +**mergify**?⚠️ | boolean | Whether mergify should be enabled on this repository or not.
__*Default*__: true +**outdir**?🔹 | string | The root directory of the project.
__*Default*__: "." +**packaging**?🔹 | string | Project packaging format.
__*Default*__: "jar" +**packagingOptions**?🔹 | [java.MavenPackagingOptions](#projen-java-mavenpackagingoptions) | Packaging options.
__*Default*__: defaults +**parent**?🔹 | [Project](#projen-project) | The parent project, if this project is part of a bigger project.
__*Optional*__ +**projectType**?⚠️ | [ProjectType](#projen-projecttype) | Which type of project this is (library/app).
__*Default*__: ProjectType.UNKNOWN +**projenrcJava**?🔹 | boolean | Use projenrc in java.
__*Default*__: true +**projenrcJavaOptions**?🔹 | [java.ProjenrcOptions](#projen-java-projenrcoptions) | Options related to projenrc in java.
__*Default*__: default options +**projenrcJson**?🔹 | boolean | Generate (once) .projenrc.json (in JSON). Set to `false` in order to disable .projenrc.json generation.
__*Default*__: false +**projenrcJsonOptions**?🔹 | [json.ProjenrcOptions](#projen-json-projenrcoptions) | Options for .projenrc.json.
__*Default*__: default options +**readme**?🔹 | [SampleReadmeProps](#projen-samplereadmeprops) | The README setup.
__*Default*__: { filename: 'README.md', contents: '# replace this' } +**requireApproval**?🔹 | [awscdk.ApprovalLevel](#projen-awscdk-approvallevel) | To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them.
__*Default*__: ApprovalLevel.BROADENING +**sample**?🔹 | boolean | Include sample code and test if the relevant directories don't exist.
__*Optional*__ +**sampleJavaPackage**?🔹 | string | The java package to use for the code sample.
__*Default*__: "org.acme" +**stale**?🔹 | boolean | Auto-close of stale issues and pull request.
__*Default*__: true +**staleOptions**?🔹 | [github.StaleOptions](#projen-github-staleoptions) | Auto-close stale issues and pull requests.
__*Default*__: see defaults in `StaleOptions` +**testDeps**?🔹 | Array | List of test dependencies for this project.
__*Default*__: [] +**url**?🔹 | string | The URL, like the name, is not required.
__*Default*__: undefined +**vscode**?🔹 | boolean | Enable VSCode integration.
__*Default*__: true + + + +## struct CdkConfigCommonOptions 🔹 + + +Common options for `cdk.json`. + + + +Name | Type | Description +-----|------|------------- +**cdkout**?🔹 | string | cdk.out directory.
__*Default*__: "cdk.out" +**context**?🔹 | Map | Additional context to include in `cdk.json`.
__*Default*__: no additional context +**featureFlags**?🔹 | boolean | Include all feature flags in cdk.json.
__*Default*__: true +**requireApproval**?🔹 | [awscdk.ApprovalLevel](#projen-awscdk-approvallevel) | To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them.
__*Default*__: ApprovalLevel.BROADENING + + + +## struct CdkConfigOptions 🔹 + + +Options for `CdkJson`. + + + +Name | Type | Description +-----|------|------------- +**app**🔹 | string | The command line to execute in order to synthesize the CDK application (language specific). +**cdkout**?🔹 | string | cdk.out directory.
__*Default*__: "cdk.out" +**context**?🔹 | Map | Additional context to include in `cdk.json`.
__*Default*__: no additional context +**featureFlags**?🔹 | boolean | Include all feature flags in cdk.json.
__*Default*__: true +**requireApproval**?🔹 | [awscdk.ApprovalLevel](#projen-awscdk-approvallevel) | To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them.
__*Default*__: ApprovalLevel.BROADENING + + + ## struct Dependency 🔹 __Obtainable from__: [Dependencies](#projen-deps-dependencies).[addDependency](#projen-deps-dependencies#projen-deps-dependencies-adddependency)(), [Dependencies](#projen-deps-dependencies).[getDependency](#projen-deps-dependencies#projen-deps-dependencies-getdependency)(), [JavaProject](#projen-java-javaproject).[addPlugin](#projen-java-javaproject#projen-java-javaproject-addplugin)(), [Pom](#projen-java-pom).[addPlugin](#projen-java-pom#projen-java-pom-addplugin)() @@ -11537,6 +11802,52 @@ Name | Type | Description +## struct JavaProjectCommonOptions 🔹 + + +Options for `JavaProject`. + + + +Name | Type | Description +-----|------|------------- +**artifactId**🔹 | string | The artifactId is generally the name that the project is known by. +**groupId**🔹 | string | This is generally unique amongst an organization or a project. +**name**🔹 | string | This is the name of your project. +**version**🔹 | string | This is the last piece of the naming puzzle. +**autoApproveOptions**?🔹 | [github.AutoApproveOptions](#projen-github-autoapproveoptions) | Enable and configure the 'auto approve' workflow.
__*Default*__: auto approve is disabled +**autoMergeOptions**?🔹 | [github.AutoMergeOptions](#projen-github-automergeoptions) | Configure options for automatic merging on GitHub.
__*Default*__: see defaults in `AutoMergeOptions` +**clobber**?🔹 | boolean | Add a `clobber` task which resets the repo to origin.
__*Default*__: true +**compileOptions**?🔹 | [java.MavenCompileOptions](#projen-java-mavencompileoptions) | Compile options.
__*Default*__: defaults +**deps**?🔹 | Array | List of runtime dependencies for this project.
__*Default*__: [] +**description**?🔹 | string | Description of a project is always good.
__*Default*__: undefined +**devContainer**?🔹 | boolean | Add a VSCode development environment (used for GitHub Codespaces).
__*Default*__: false +**distdir**?🔹 | string | Final artifact output directory.
__*Default*__: "dist/java" +**github**?🔹 | boolean | Enable GitHub integration.
__*Default*__: true +**githubOptions**?🔹 | [github.GitHubOptions](#projen-github-githuboptions) | Options for GitHub integration.
__*Default*__: see GitHubOptions +**gitpod**?🔹 | boolean | Add a Gitpod development environment.
__*Default*__: false +**junit**?🔹 | boolean | Include junit tests.
__*Default*__: true +**junitOptions**?🔹 | [java.JunitOptions](#projen-java-junitoptions) | junit options.
__*Default*__: defaults +**logging**?🔹 | [LoggerOptions](#projen-loggeroptions) | Configure logging options such as verbosity.
__*Default*__: {} +**mergify**?⚠️ | boolean | Whether mergify should be enabled on this repository or not.
__*Default*__: true +**outdir**?🔹 | string | The root directory of the project.
__*Default*__: "." +**packaging**?🔹 | string | Project packaging format.
__*Default*__: "jar" +**packagingOptions**?🔹 | [java.MavenPackagingOptions](#projen-java-mavenpackagingoptions) | Packaging options.
__*Default*__: defaults +**parent**?🔹 | [Project](#projen-project) | The parent project, if this project is part of a bigger project.
__*Optional*__ +**projectType**?⚠️ | [ProjectType](#projen-projecttype) | Which type of project this is (library/app).
__*Default*__: ProjectType.UNKNOWN +**projenrcJava**?🔹 | boolean | Use projenrc in java.
__*Default*__: true +**projenrcJavaOptions**?🔹 | [java.ProjenrcOptions](#projen-java-projenrcoptions) | Options related to projenrc in java.
__*Default*__: default options +**projenrcJson**?🔹 | boolean | Generate (once) .projenrc.json (in JSON). Set to `false` in order to disable .projenrc.json generation.
__*Default*__: false +**projenrcJsonOptions**?🔹 | [json.ProjenrcOptions](#projen-json-projenrcoptions) | Options for .projenrc.json.
__*Default*__: default options +**readme**?🔹 | [SampleReadmeProps](#projen-samplereadmeprops) | The README setup.
__*Default*__: { filename: 'README.md', contents: '# replace this' } +**stale**?🔹 | boolean | Auto-close of stale issues and pull request.
__*Default*__: true +**staleOptions**?🔹 | [github.StaleOptions](#projen-github-staleoptions) | Auto-close stale issues and pull requests.
__*Default*__: see defaults in `StaleOptions` +**testDeps**?🔹 | Array | List of test dependencies for this project.
__*Default*__: [] +**url**?🔹 | string | The URL, like the name, is not required.
__*Default*__: undefined +**vscode**?🔹 | boolean | Enable VSCode integration.
__*Default*__: true + + + ## struct JavaProjectOptions 🔹 @@ -13182,17 +13493,6 @@ Name | Description **DAILY** 🔹|Automatically bump & release a new version on a daily basis. -## enum CdkApprovalLevel 🔹 - - - -Name | Description ------|----- -**NEVER** 🔹|Approval is never required. -**ANY_CHANGE** 🔹|Requires approval on any IAM or security-group-related change. -**BROADENING** 🔹|Requires approval when IAM statements or traffic rules are added; - - ## enum DockerComposeProtocol 🔹 Network protocol for port mapping. @@ -13344,6 +13644,17 @@ Name | Description **NODE** 🔹|Resolution strategy which attempts to mimic the Node.js module resolution strategy at runtime. +## enum ApprovalLevel 🔹 + +Which approval is required when deploying CDK apps. + +Name | Description +-----|----- +**NEVER** 🔹|Approval is never required. +**ANY_CHANGE** 🔹|Requires approval on any IAM or security-group-related change. +**BROADENING** 🔹|Requires approval when IAM statements or traffic rules are added; + + ## enum DependencyType 🔹 Type of dependency. diff --git a/README.md b/README.md index b86f4b32848..def153f75fa 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Currently supported project types (use `npx projen new` without a type for a list): +* [awscdk-app-java](https://github.com/projen/projen/blob/main/API.md#projen-awscdk-awscdkjavaapp) - AWS CDK app in Java. * [awscdk-app-ts](https://github.com/projen/projen/blob/main/API.md#projen-awscdktypescriptapp) - AWS CDK app in TypeScript. * [awscdk-construct](https://github.com/projen/projen/blob/main/API.md#projen-awscdkconstructlibrary) - AWS CDK construct library project. * [cdk8s-app-ts](https://github.com/projen/projen/blob/main/API.md#projen-cdk8stypescriptapp) - CDK8s app in TypeScript. diff --git a/src/awscdk-app-ts.ts b/src/awscdk-app-ts.ts index b3ad7276006..0b8bb0bab84 100644 --- a/src/awscdk-app-ts.ts +++ b/src/awscdk-app-ts.ts @@ -1,25 +1,12 @@ import * as path from 'path'; import * as fs from 'fs-extra'; import * as semver from 'semver'; +import { CdkConfig, CdkConfigCommonOptions } from './awscdk/cdk-config'; +import { CdkTasks } from './awscdk/cdk-tasks'; import { Component } from './component'; -import { JsonFile } from './json'; import { TypeScriptAppProject, TypeScriptProjectOptions } from './typescript'; -export enum CdkApprovalLevel { - /** - * Approval is never required - */ - NEVER = 'never', - /** - * Requires approval on any IAM or security-group-related change - */ - ANY_CHANGE = 'any-change', - /** - * Requires approval when IAM statements or traffic rules are added; removals don't require approval - */ - BROADENING = 'broadening', -} -export interface AwsCdkTypeScriptAppOptions extends TypeScriptProjectOptions { +export interface AwsCdkTypeScriptAppOptions extends TypeScriptProjectOptions, CdkConfigCommonOptions { /** * AWS CDK version to use. * @@ -44,11 +31,6 @@ export interface AwsCdkTypeScriptAppOptions extends TypeScriptProjectOptions { */ readonly cdkDependencies?: string[]; - /** - * Additional context to include in `cdk.json`. - */ - readonly context?: { [key: string]: string }; - /** * The CDK app's entrypoint (relative to the source directory, which is * "src" by default). @@ -56,15 +38,6 @@ export interface AwsCdkTypeScriptAppOptions extends TypeScriptProjectOptions { * @default "main.ts" */ readonly appEntrypoint?: string; - - /** - * To protect you against unintended changes that affect your security posture, - * the AWS CDK Toolkit prompts you to approve security-related changes before deploying them. - * - * @default CdkApprovalLevel.BROADENING - */ - readonly requireApproval?: CdkApprovalLevel; - } /** @@ -79,14 +52,19 @@ export class AwsCdkTypeScriptApp extends TypeScriptAppProject { public readonly cdkVersion: string; /** - * Contents of `cdk.json`. + * The CDK app entrypoint */ - public readonly cdkConfig: any; + public readonly appEntrypoint: string; /** - * The CDK app entrypoint + * Common CDK tasks. */ - public readonly appEntrypoint: string; + public readonly cdkTasks: CdkTasks; + + /** + * cdk.json configuration. + */ + public readonly cdkConfig: CdkConfig; constructor(options: AwsCdkTypeScriptAppOptions) { super({ @@ -126,25 +104,7 @@ export class AwsCdkTypeScriptApp extends TypeScriptAppProject { this.addCdkDependency(...options.cdkDependencies ?? []); - const synth = this.addTask('synth', { - description: 'Synthesizes your cdk app into cdk.out (part of "yarn build")', - exec: 'cdk synth', - }); - - this.addTask('deploy', { - description: 'Deploys your CDK app to the AWS cloud', - exec: 'cdk deploy', - }); - - this.addTask('destroy', { - description: 'Destroys your cdk app in the AWS cloud', - exec: 'cdk destroy', - }); - - this.addTask('diff', { - description: 'Diffs the currently deployed app against your code', - exec: 'cdk diff', - }); + this.cdkTasks = new CdkTasks(this); // no compile step because we do all of it in typescript directly this.compileTask.reset(); @@ -152,37 +112,24 @@ export class AwsCdkTypeScriptApp extends TypeScriptAppProject { this.removeScript('watch'); // because we use ts-node // add synth to the build - this.buildTask.spawn(synth); + this.buildTask.spawn(this.cdkTasks.synth); - this.cdkConfig = { - app: `npx ts-node --prefer-ts-exts ${path.posix.join(this.srcdir, this.appEntrypoint)}`, - }; - if (options.context) { - this.cdkConfig.context = { ...options.context }; - } - - if (options.requireApproval) { - this.cdkConfig.requireApproval = options.requireApproval; - } + this.cdkConfig = new CdkConfig(this, { + app: `npx ts-node --prefer-ts-exts ${path.posix.join(this.srcdir, this.appEntrypoint)}`, + ...options, + }); - this.gitignore.exclude('cdk.out/'); - this.gitignore.exclude('.cdk.staging/'); this.gitignore.exclude('.parcel-cache/'); - this.npmignore?.exclude('cdk.out/'); + this.npmignore?.exclude(`${this.cdkConfig.cdkout}/`); this.npmignore?.exclude('.cdk.staging/'); if (this.tsconfig) { - this.tsconfig.exclude.push('cdk.out'); + this.tsconfig.exclude.push(this.cdkConfig.cdkout); } this.addDevDeps('ts-node@^9'); - - new JsonFile(this, 'cdk.json', { - obj: this.cdkConfig, - }); - if (options.sampleCode ?? true) { new SampleCode(this, cdkMajorVersion); } diff --git a/src/awscdk/cdk-config.ts b/src/awscdk/cdk-config.ts new file mode 100644 index 00000000000..4abbed3a151 --- /dev/null +++ b/src/awscdk/cdk-config.ts @@ -0,0 +1,111 @@ +import { Component } from '../component'; +import { JsonFile } from '../json'; +import { Project } from '../project'; +import { FEATURE_FLAGS } from './internal'; + +/** + * Common options for `cdk.json`. + */ +export interface CdkConfigCommonOptions { + /** + * Additional context to include in `cdk.json`. + * + * @default - no additional context + */ + readonly context?: { [key: string]: string }; + + /** + * Include all feature flags in cdk.json + * + * @default true + */ + readonly featureFlags?: boolean; + + /** + * To protect you against unintended changes that affect your security posture, + * the AWS CDK Toolkit prompts you to approve security-related changes before deploying them. + * + * @default ApprovalLevel.BROADENING + */ + readonly requireApproval?: ApprovalLevel; + + /** + * cdk.out directory. + * + * @default "cdk.out" + */ + readonly cdkout?: string; +} + +/** + * Options for `CdkJson`. + */ +export interface CdkConfigOptions extends CdkConfigCommonOptions { + /** + * The command line to execute in order to synthesize the CDK application + * (language specific). + */ + readonly app: string; +} + +/** + * Represents cdk.json file. + */ +export class CdkConfig extends Component { + + /** + * Represents the JSON file. + */ + public readonly json: JsonFile; + + /** + * Name of the cdk.out directory. + */ + public readonly cdkout: string; + + constructor(project: Project, options: CdkConfigOptions) { + super(project); + + this.cdkout = options.cdkout ?? 'cdk.out'; + + const context: Record = { ...options.context }; + const fflags = options.featureFlags ?? true; + if (fflags) { + for (const flag of FEATURE_FLAGS) { + context[flag] = true; + } + } + + this.json = new JsonFile(project, 'cdk.json', { + omitEmpty: true, + obj: { + app: options.app, + context: context, + requireApproval: options.requireApproval, + output: this.cdkout, + }, + }); + + project.gitignore.exclude(`/${this.cdkout}/`); + project.gitignore.exclude('.cdk.staging/'); + } +} + +/** + * Which approval is required when deploying CDK apps. + */ +export enum ApprovalLevel { + /** + * Approval is never required + */ + NEVER = 'never', + /** + * Requires approval on any IAM or security-group-related change + */ + ANY_CHANGE = 'any-change', + /** + * Requires approval when IAM statements or traffic rules are added; removals don't require approval + */ + BROADENING = 'broadening', +} + diff --git a/src/awscdk/cdk-tasks.ts b/src/awscdk/cdk-tasks.ts new file mode 100644 index 00000000000..ba31bcdf326 --- /dev/null +++ b/src/awscdk/cdk-tasks.ts @@ -0,0 +1,52 @@ +import { Component } from '../component'; +import { Project } from '../project'; +import { Task } from '../tasks'; + +/** + * Adds standard AWS CDK tasks to your project. + */ +export class CdkTasks extends Component { + /** + * Synthesizes your app. + */ + public readonly synth: Task; + + /** + * Deploys your app. + */ + public readonly deploy: Task; + + /** + * Destroys all the stacks. + */ + public readonly destroy: Task; + + /** + * Diff against production. + */ + public readonly diff: Task; + + constructor(project: Project) { + super(project); + + this.synth = project.addTask('synth', { + description: 'Synthesizes your cdk app into cdk.out (part of "yarn build")', + exec: 'cdk synth', + }); + + this.deploy = project.addTask('deploy', { + description: 'Deploys your CDK app to the AWS cloud', + exec: 'cdk deploy', + }); + + this.destroy = project.addTask('destroy', { + description: 'Destroys your cdk app in the AWS cloud', + exec: 'cdk destroy', + }); + + this.diff = project.addTask('diff', { + description: 'Diffs the currently deployed app against your code', + exec: 'cdk diff', + }); + } +} \ No newline at end of file diff --git a/src/awscdk/index.ts b/src/awscdk/index.ts new file mode 100644 index 00000000000..4391341cfe9 --- /dev/null +++ b/src/awscdk/index.ts @@ -0,0 +1,3 @@ +export * from './java-app'; +export * from './cdk-config'; +export * from './cdk-tasks'; \ No newline at end of file diff --git a/src/awscdk/internal.ts b/src/awscdk/internal.ts new file mode 100644 index 00000000000..9e48e64ae34 --- /dev/null +++ b/src/awscdk/internal.ts @@ -0,0 +1,18 @@ +/** + * Feature flags as of v1.130.0 + */ +export const FEATURE_FLAGS = [ + 'aws-cdk:enableDiffNoFail', + '@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId', + '@aws-cdk/core:enableStackNameDuplicates', + '@aws-cdk/core:stackRelativeExports', + '@aws-cdk/aws-ecr-assets:dockerIgnoreSupport', + '@aws-cdk/aws-secretsmanager:parseOwnedSecretName', + '@aws-cdk/aws-kms:defaultKeyPolicies', + '@aws-cdk/aws-s3:grantWriteWithoutAcl', + '@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount', + '@aws-cdk/aws-rds:lowercaseDbIdentifier', + '@aws-cdk/aws-efs:defaultEncryptionAtRest', + '@aws-cdk/aws-lambda:recognizeVersionProps', + '@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021', +]; \ No newline at end of file diff --git a/src/awscdk/java-app.ts b/src/awscdk/java-app.ts new file mode 100644 index 00000000000..15fda1da072 --- /dev/null +++ b/src/awscdk/java-app.ts @@ -0,0 +1,142 @@ +import { join } from 'path'; +import * as semver from 'semver'; +import { SampleDir } from '..'; +import { JavaProject, JavaProjectOptions } from '../java'; +import { CdkConfig, CdkConfigCommonOptions } from './cdk-config'; +import { CdkTasks } from './cdk-tasks'; + +export interface AwsCdkJavaAppOptions extends JavaProjectOptions, CdkConfigCommonOptions { + /** + * AWS CDK version to use (you can use semantic versioning). + * + * @default "^1.130.0" + */ + readonly cdkVersion: string; + + /** + * Which AWS CDK modules this app uses. The `core` module is included by + * default and you can add additional modules here by stating only the package + * name (e.g. `aws-lambda`). + * + * @featured + */ + readonly cdkDependencies?: string[]; + + /** + * The name of the Java class with the static `main()` method. This method + * should call `app.synth()` on the CDK app. + * + * @default "org.acme.App" + */ + readonly mainClass: string; +} + +/** + * AWS CDK app in Java. + * + * @pjid awscdk-app-java + */ +export class AwsCdkJavaApp extends JavaProject { + /** + * The CDK version this app is using. + */ + public readonly cdkVersion: string; + + /** + * The `cdk.json` file. + */ + public readonly cdkConfig: CdkConfig; + + /** + * The full name of the main class of the java app (package.Class). + */ + public readonly mainClass: string; + + /** + * CDK tasks. + */ + public readonly cdkTasks: CdkTasks; + + /** + * The name of the Java package that includes the main class. + */ + public readonly mainPackage: string; + + /** + * The name of the Java class with the static `main()` method. + */ + public readonly mainClassName: string; + + constructor(options: AwsCdkJavaAppOptions) { + const mainClassComponents = options.mainClass.split('.'); + const mainPackage = mainClassComponents.slice(0, -1); + const mainClassName = mainClassComponents[mainClassComponents.length - 1]; + + super({ + ...options, + sample: false, + sampleJavaPackage: mainPackage.join('.'), + }); + + this.mainClass = options.mainClass; + this.mainPackage = mainPackage.join('.'); + this.mainClassName = mainClassName; + this.cdkVersion = options.cdkVersion; + + if (!this.cdkVersion) { + throw new Error('Required field cdkVersion is not specified.'); + } + + const cdkMajorVersion = semver.minVersion(this.cdkVersion)?.major ?? 1; + if (cdkMajorVersion >= 2) { + throw new Error('CDKv2 is still not supported'); + } + + this.addCdkDependency('core'); + this.addCdkDependency(...options.cdkDependencies ?? []); + + this.cdkTasks = new CdkTasks(this); + this.buildTask.spawn(this.cdkTasks.synth); + + this.cdkConfig = new CdkConfig(this, { + app: `mvn exec:java --quiet -Dexec.mainClass=${this.mainClass}`, + ...options, + }); + + this.addSample(); + } + + /** + * Adds an AWS CDK module dependencies + * + * @param modules The list of modules to depend on (e.g. "core", "aws-lambda", etc) + */ + public addCdkDependency(...modules: string[]) { + for (const m of modules) { + this.addDependency(`software.amazon.awscdk/${m}@${this.cdkVersion}`); + } + } + + private addSample() { + const pkg = this.mainPackage.split('.'); + const javaFile = `${this.mainClassName}.java`; + new SampleDir(this, join('src', 'main', 'java', ...pkg), { + files: { + [javaFile]: [ + `package ${pkg.join('.')};`, + '', + 'import software.amazon.awscdk.core.App;', + 'import software.amazon.awscdk.core.Stack;', + '', + `public class ${this.mainClassName} {`, + ' public static void main(final String[] args) {', + ' App app = new App();', + ' new Stack(app, "MyStack");', + ' app.synth();', + ' }', + '}', + ].join('\n'), + }, + }); + } +} diff --git a/src/index.ts b/src/index.ts index 746101464fe..85e7cf0144e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -49,4 +49,5 @@ export * as python from './python'; export * as typescript from './typescript/index'; // <-- we also have typescript.ts export * as javascript from './javascript'; export * as release from './release'; -export * as git from './git'; \ No newline at end of file +export * as git from './git'; +export * as awscdk from './awscdk'; \ No newline at end of file diff --git a/src/java/java-project.ts b/src/java/java-project.ts index 1cecb94ee2f..1b66c9018f8 100644 --- a/src/java/java-project.ts +++ b/src/java/java-project.ts @@ -1,4 +1,5 @@ import { GitHubProject, GitHubProjectOptions } from '../project'; +import { Task } from '../tasks'; import { Junit, JunitOptions } from './junit'; import { MavenCompile, MavenCompileOptions } from './maven-compile'; import { MavenPackaging, MavenPackagingOptions } from './maven-packaging'; @@ -9,7 +10,7 @@ import { Projenrc as ProjenrcJava, ProjenrcOptions } from './projenrc'; /** * Options for `JavaProject`. */ -export interface JavaProjectOptions extends GitHubProjectOptions, PomOptions { +export interface JavaProjectCommonOptions extends GitHubProjectOptions, PomOptions { /** * Final artifact output directory. * @@ -69,17 +70,6 @@ export interface JavaProjectOptions extends GitHubProjectOptions, PomOptions { */ readonly compileOptions?: MavenCompileOptions; - /** - * Include sample code and test if the relevant directories don't exist. - */ - readonly sample?: boolean; - - /** - * The java package to use for the code sample. - * @default "org.acme" - */ - readonly sampleJavaPackage?: string; - /** * Use projenrc in java. * @@ -97,6 +87,22 @@ export interface JavaProjectOptions extends GitHubProjectOptions, PomOptions { readonly projenrcJavaOptions?: ProjenrcOptions; } +/** + * Options for `JavaProject`. + */ +export interface JavaProjectOptions extends JavaProjectCommonOptions { + /** + * Include sample code and test if the relevant directories don't exist. + */ + readonly sample?: boolean; + + /** + * The java package to use for the code sample. + * @default "org.acme" + */ + readonly sampleJavaPackage?: string; +} + /** * Java project. * @@ -133,6 +139,11 @@ export class JavaProject extends GitHubProject { */ public readonly distdir: string; + /** + * The primary build task. + */ + public readonly buildTask: Task; + constructor(options: JavaProjectOptions) { super(options); @@ -178,6 +189,7 @@ export class JavaProject extends GitHubProject { const buildTask = this.addTask('build', { description: 'Full CI build' }); buildTask.spawn(this.packaging.task); + this.buildTask = buildTask; for (const dep of options.deps ?? []) { this.addDependency(dep); diff --git a/test/__snapshots__/inventory.test.ts.snap b/test/__snapshots__/inventory.test.ts.snap index 5858be4bd83..dff0be200d9 100644 --- a/test/__snapshots__/inventory.test.ts.snap +++ b/test/__snapshots__/inventory.test.ts.snap @@ -2,6 +2,786 @@ exports[`inventory 1`] = ` Array [ + Object { + "docs": "AWS CDK app in Java.", + "docsurl": "https://github.com/projen/projen/blob/main/API.md#projen-awscdk-awscdkjavaapp", + "fqn": "projen.awscdk.AwsCdkJavaApp", + "moduleName": "projen", + "options": Array [ + Object { + "default": "\\"my-app\\"", + "docs": "The artifactId is generally the name that the project is known by.", + "featured": true, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "artifactId", + "parent": "PomOptions", + "path": Array [ + "artifactId", + ], + "simpleType": "string", + "switch": "artifact-id", + }, + Object { + "default": "- auto approve is disabled", + "docs": "Enable and configure the 'auto approve' workflow.", + "featured": false, + "fqn": "projen.github.AutoApproveOptions", + "fullType": Object { + "fqn": "projen.github.AutoApproveOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "autoApproveOptions", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "autoApproveOptions", + ], + "simpleType": "AutoApproveOptions", + "switch": "auto-approve-options", + }, + Object { + "default": "- see defaults in \`AutoMergeOptions\`", + "docs": "Configure options for automatic merging on GitHub.", + "featured": false, + "fqn": "projen.github.AutoMergeOptions", + "fullType": Object { + "fqn": "projen.github.AutoMergeOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "autoMergeOptions", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "autoMergeOptions", + ], + "simpleType": "AutoMergeOptions", + "switch": "auto-merge-options", + }, + Object { + "docs": "Which AWS CDK modules this app uses.", + "featured": true, + "fullType": Object { + "collection": Object { + "elementtype": Object { + "primitive": "string", + }, + "kind": "array", + }, + }, + "jsonLike": true, + "name": "cdkDependencies", + "optional": true, + "parent": "AwsCdkJavaAppOptions", + "path": Array [ + "cdkDependencies", + ], + "simpleType": "unknown", + "switch": "cdk-dependencies", + }, + Object { + "default": "\\"cdk.out\\"", + "docs": "cdk.out directory.", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "cdkout", + "optional": true, + "parent": "CdkConfigCommonOptions", + "path": Array [ + "cdkout", + ], + "simpleType": "string", + "switch": "cdkout", + }, + Object { + "default": "\\"^1.130.0\\"", + "docs": "AWS CDK version to use (you can use semantic versioning).", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "cdkVersion", + "parent": "AwsCdkJavaAppOptions", + "path": Array [ + "cdkVersion", + ], + "simpleType": "string", + "switch": "cdk-version", + }, + Object { + "default": "true", + "docs": "Add a \`clobber\` task which resets the repo to origin.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "clobber", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "clobber", + ], + "simpleType": "boolean", + "switch": "clobber", + }, + Object { + "default": "- defaults", + "docs": "Compile options.", + "featured": false, + "fqn": "projen.java.MavenCompileOptions", + "fullType": Object { + "fqn": "projen.java.MavenCompileOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "compileOptions", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "compileOptions", + ], + "simpleType": "MavenCompileOptions", + "switch": "compile-options", + }, + Object { + "default": "- no additional context", + "docs": "Additional context to include in \`cdk.json\`.", + "featured": false, + "fullType": Object { + "collection": Object { + "elementtype": Object { + "primitive": "string", + }, + "kind": "map", + }, + }, + "jsonLike": true, + "name": "context", + "optional": true, + "parent": "CdkConfigCommonOptions", + "path": Array [ + "context", + ], + "simpleType": "unknown", + "switch": "context", + }, + Object { + "default": "[]", + "docs": "List of runtime dependencies for this project.", + "featured": true, + "fullType": Object { + "collection": Object { + "elementtype": Object { + "primitive": "string", + }, + "kind": "array", + }, + }, + "jsonLike": true, + "name": "deps", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "deps", + ], + "simpleType": "unknown", + "switch": "deps", + }, + Object { + "docs": "Description of a project is always good.", + "featured": true, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "description", + "optional": true, + "parent": "PomOptions", + "path": Array [ + "description", + ], + "simpleType": "string", + "switch": "description", + }, + Object { + "default": "false", + "docs": "Add a VSCode development environment (used for GitHub Codespaces).", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "devContainer", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "devContainer", + ], + "simpleType": "boolean", + "switch": "dev-container", + }, + Object { + "default": "\\"dist/java\\"", + "docs": "Final artifact output directory.", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "distdir", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "distdir", + ], + "simpleType": "string", + "switch": "distdir", + }, + Object { + "default": "true", + "docs": "Include all feature flags in cdk.json.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "featureFlags", + "optional": true, + "parent": "CdkConfigCommonOptions", + "path": Array [ + "featureFlags", + ], + "simpleType": "boolean", + "switch": "feature-flags", + }, + Object { + "default": "true", + "docs": "Enable GitHub integration.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "github", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "github", + ], + "simpleType": "boolean", + "switch": "github", + }, + Object { + "default": "- see GitHubOptions", + "docs": "Options for GitHub integration.", + "featured": false, + "fqn": "projen.github.GitHubOptions", + "fullType": Object { + "fqn": "projen.github.GitHubOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "githubOptions", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "githubOptions", + ], + "simpleType": "GitHubOptions", + "switch": "github-options", + }, + Object { + "default": "false", + "docs": "Add a Gitpod development environment.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "gitpod", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "gitpod", + ], + "simpleType": "boolean", + "switch": "gitpod", + }, + Object { + "default": "\\"org.acme\\"", + "docs": "This is generally unique amongst an organization or a project.", + "featured": true, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "groupId", + "parent": "PomOptions", + "path": Array [ + "groupId", + ], + "simpleType": "string", + "switch": "group-id", + }, + Object { + "default": "true", + "docs": "Include junit tests.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "junit", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "junit", + ], + "simpleType": "boolean", + "switch": "junit", + }, + Object { + "default": "- defaults", + "docs": "junit options.", + "featured": false, + "fqn": "projen.java.JunitOptions", + "fullType": Object { + "fqn": "projen.java.JunitOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "junitOptions", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "junitOptions", + ], + "simpleType": "JunitOptions", + "switch": "junit-options", + }, + Object { + "default": "{}", + "docs": "Configure logging options such as verbosity.", + "featured": false, + "fqn": "projen.LoggerOptions", + "fullType": Object { + "fqn": "projen.LoggerOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "logging", + "optional": true, + "parent": "ProjectOptions", + "path": Array [ + "logging", + ], + "simpleType": "LoggerOptions", + "switch": "logging", + }, + Object { + "default": "\\"org.acme.App\\"", + "docs": "The name of the Java class with the static \`main()\` method.", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "mainClass", + "parent": "AwsCdkJavaAppOptions", + "path": Array [ + "mainClass", + ], + "simpleType": "string", + "switch": "main-class", + }, + Object { + "default": "true", + "deprecated": true, + "docs": "Whether mergify should be enabled on this repository or not.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "mergify", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "mergify", + ], + "simpleType": "boolean", + "switch": "mergify", + }, + Object { + "default": "$BASEDIR", + "docs": "This is the name of your project.", + "featured": true, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "name", + "parent": "ProjectOptions", + "path": Array [ + "name", + ], + "simpleType": "string", + "switch": "name", + }, + Object { + "default": "\\".\\"", + "docs": "The root directory of the project.", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "outdir", + "optional": true, + "parent": "ProjectOptions", + "path": Array [ + "outdir", + ], + "simpleType": "string", + "switch": "outdir", + }, + Object { + "default": "\\"jar\\"", + "docs": "Project packaging format.", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "packaging", + "optional": true, + "parent": "PomOptions", + "path": Array [ + "packaging", + ], + "simpleType": "string", + "switch": "packaging", + }, + Object { + "default": "- defaults", + "docs": "Packaging options.", + "featured": false, + "fqn": "projen.java.MavenPackagingOptions", + "fullType": Object { + "fqn": "projen.java.MavenPackagingOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "packagingOptions", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "packagingOptions", + ], + "simpleType": "MavenPackagingOptions", + "switch": "packaging-options", + }, + Object { + "docs": "The parent project, if this project is part of a bigger project.", + "featured": false, + "fqn": "projen.Project", + "fullType": Object { + "fqn": "projen.Project", + }, + "jsonLike": false, + "kind": "class", + "name": "parent", + "optional": true, + "parent": "ProjectOptions", + "path": Array [ + "parent", + ], + "simpleType": "Project", + "switch": "parent", + }, + Object { + "default": "ProjectType.UNKNOWN", + "deprecated": true, + "docs": "Which type of project this is (library/app).", + "featured": false, + "fqn": "projen.ProjectType", + "fullType": Object { + "fqn": "projen.ProjectType", + }, + "jsonLike": true, + "kind": "enum", + "name": "projectType", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "projectType", + ], + "simpleType": "ProjectType", + "switch": "project-type", + }, + Object { + "default": "true", + "docs": "Use projenrc in java.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "projenrcJava", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "projenrcJava", + ], + "simpleType": "boolean", + "switch": "projenrc-java", + }, + Object { + "default": "- default options", + "docs": "Options related to projenrc in java.", + "featured": false, + "fqn": "projen.java.ProjenrcOptions", + "fullType": Object { + "fqn": "projen.java.ProjenrcOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "projenrcJavaOptions", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "projenrcJavaOptions", + ], + "simpleType": "ProjenrcOptions", + "switch": "projenrc-java-options", + }, + Object { + "default": "false", + "docs": "Generate (once) .projenrc.json (in JSON). Set to \`false\` in order to disable .projenrc.json generation.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "projenrcJson", + "optional": true, + "parent": "ProjectOptions", + "path": Array [ + "projenrcJson", + ], + "simpleType": "boolean", + "switch": "projenrc-json", + }, + Object { + "default": "- default options", + "docs": "Options for .projenrc.json.", + "featured": false, + "fqn": "projen.json.ProjenrcOptions", + "fullType": Object { + "fqn": "projen.json.ProjenrcOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "projenrcJsonOptions", + "optional": true, + "parent": "ProjectOptions", + "path": Array [ + "projenrcJsonOptions", + ], + "simpleType": "ProjenrcOptions", + "switch": "projenrc-json-options", + }, + Object { + "default": "- { filename: 'README.md', contents: '# replace this' }", + "docs": "The README setup.", + "featured": false, + "fqn": "projen.SampleReadmeProps", + "fullType": Object { + "fqn": "projen.SampleReadmeProps", + }, + "jsonLike": true, + "kind": "interface", + "name": "readme", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "readme", + ], + "simpleType": "SampleReadmeProps", + "switch": "readme", + }, + Object { + "default": "ApprovalLevel.BROADENING", + "docs": "To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them.", + "featured": false, + "fqn": "projen.awscdk.ApprovalLevel", + "fullType": Object { + "fqn": "projen.awscdk.ApprovalLevel", + }, + "jsonLike": true, + "kind": "enum", + "name": "requireApproval", + "optional": true, + "parent": "CdkConfigCommonOptions", + "path": Array [ + "requireApproval", + ], + "simpleType": "ApprovalLevel", + "switch": "require-approval", + }, + Object { + "docs": "Include sample code and test if the relevant directories don't exist.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "sample", + "optional": true, + "parent": "JavaProjectOptions", + "path": Array [ + "sample", + ], + "simpleType": "boolean", + "switch": "sample", + }, + Object { + "default": "\\"org.acme\\"", + "docs": "The java package to use for the code sample.", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "sampleJavaPackage", + "optional": true, + "parent": "JavaProjectOptions", + "path": Array [ + "sampleJavaPackage", + ], + "simpleType": "string", + "switch": "sample-java-package", + }, + Object { + "default": "true", + "docs": "Auto-close of stale issues and pull request.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "stale", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "stale", + ], + "simpleType": "boolean", + "switch": "stale", + }, + Object { + "default": "- see defaults in \`StaleOptions\`", + "docs": "Auto-close stale issues and pull requests.", + "featured": false, + "fqn": "projen.github.StaleOptions", + "fullType": Object { + "fqn": "projen.github.StaleOptions", + }, + "jsonLike": true, + "kind": "interface", + "name": "staleOptions", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "staleOptions", + ], + "simpleType": "StaleOptions", + "switch": "stale-options", + }, + Object { + "default": "[]", + "docs": "List of test dependencies for this project.", + "featured": true, + "fullType": Object { + "collection": Object { + "elementtype": Object { + "primitive": "string", + }, + "kind": "array", + }, + }, + "jsonLike": true, + "name": "testDeps", + "optional": true, + "parent": "JavaProjectCommonOptions", + "path": Array [ + "testDeps", + ], + "simpleType": "unknown", + "switch": "test-deps", + }, + Object { + "docs": "The URL, like the name, is not required.", + "featured": true, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "url", + "optional": true, + "parent": "PomOptions", + "path": Array [ + "url", + ], + "simpleType": "string", + "switch": "url", + }, + Object { + "default": "\\"0.1.0\\"", + "docs": "This is the last piece of the naming puzzle.", + "featured": true, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "version", + "parent": "PomOptions", + "path": Array [ + "version", + ], + "simpleType": "string", + "switch": "version", + }, + Object { + "default": "true", + "docs": "Enable VSCode integration.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "vscode", + "optional": true, + "parent": "GitHubProjectOptions", + "path": Array [ + "vscode", + ], + "simpleType": "boolean", + "switch": "vscode", + }, + ], + "pjid": "awscdk-app-java", + "typename": "awscdk.AwsCdkJavaApp", + }, Object { "docs": "AWS CDK app in TypeScript.", "docsurl": "https://github.com/projen/projen/blob/main/API.md#projen-awscdktypescriptapp", @@ -309,6 +1089,23 @@ Array [ "simpleType": "unknown", "switch": "cdk-dependencies", }, + Object { + "default": "\\"cdk.out\\"", + "docs": "cdk.out directory.", + "featured": false, + "fullType": Object { + "primitive": "string", + }, + "jsonLike": true, + "name": "cdkout", + "optional": true, + "parent": "CdkConfigCommonOptions", + "path": Array [ + "cdkout", + ], + "simpleType": "string", + "switch": "cdkout", + }, Object { "default": "\\"1.95.2\\"", "docs": "AWS CDK version to use.", @@ -411,6 +1208,7 @@ Array [ "switch": "compile-before-test", }, Object { + "default": "- no additional context", "docs": "Additional context to include in \`cdk.json\`.", "featured": false, "fullType": Object { @@ -424,7 +1222,7 @@ Array [ "jsonLike": true, "name": "context", "optional": true, - "parent": "AwsCdkTypeScriptAppOptions", + "parent": "CdkConfigCommonOptions", "path": Array [ "context", ], @@ -751,6 +1549,23 @@ Array [ "simpleType": "EslintOptions", "switch": "eslint-options", }, + Object { + "default": "true", + "docs": "Include all feature flags in cdk.json.", + "featured": false, + "fullType": Object { + "primitive": "boolean", + }, + "jsonLike": true, + "name": "featureFlags", + "optional": true, + "parent": "CdkConfigCommonOptions", + "path": Array [ + "featureFlags", + ], + "simpleType": "boolean", + "switch": "feature-flags", + }, Object { "default": "true", "docs": "Enable GitHub integration.", @@ -1963,22 +2778,22 @@ Array [ "switch": "repository-directory", }, Object { - "default": "CdkApprovalLevel.BROADENING", + "default": "ApprovalLevel.BROADENING", "docs": "To protect you against unintended changes that affect your security posture, the AWS CDK Toolkit prompts you to approve security-related changes before deploying them.", "featured": false, - "fqn": "projen.CdkApprovalLevel", + "fqn": "projen.awscdk.ApprovalLevel", "fullType": Object { - "fqn": "projen.CdkApprovalLevel", + "fqn": "projen.awscdk.ApprovalLevel", }, "jsonLike": true, "kind": "enum", "name": "requireApproval", "optional": true, - "parent": "AwsCdkTypeScriptAppOptions", + "parent": "CdkConfigCommonOptions", "path": Array [ "requireApproval", ], - "simpleType": "CdkApprovalLevel", + "simpleType": "ApprovalLevel", "switch": "require-approval", }, Object { @@ -12154,7 +12969,7 @@ added, set to the exact version configrued here.", "kind": "interface", "name": "compileOptions", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "compileOptions", ], @@ -12176,7 +12991,7 @@ added, set to the exact version configrued here.", "jsonLike": true, "name": "deps", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "deps", ], @@ -12226,7 +13041,7 @@ added, set to the exact version configrued here.", "jsonLike": true, "name": "distdir", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "distdir", ], @@ -12312,7 +13127,7 @@ added, set to the exact version configrued here.", "jsonLike": true, "name": "junit", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "junit", ], @@ -12331,7 +13146,7 @@ added, set to the exact version configrued here.", "kind": "interface", "name": "junitOptions", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "junitOptions", ], @@ -12437,7 +13252,7 @@ added, set to the exact version configrued here.", "kind": "interface", "name": "packagingOptions", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "packagingOptions", ], @@ -12492,7 +13307,7 @@ added, set to the exact version configrued here.", "jsonLike": true, "name": "projenrcJava", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "projenrcJava", ], @@ -12511,7 +13326,7 @@ added, set to the exact version configrued here.", "kind": "interface", "name": "projenrcJavaOptions", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "projenrcJavaOptions", ], @@ -12657,7 +13472,7 @@ added, set to the exact version configrued here.", "jsonLike": true, "name": "testDeps", "optional": true, - "parent": "JavaProjectOptions", + "parent": "JavaProjectCommonOptions", "path": Array [ "testDeps", ], diff --git a/test/__snapshots__/new.test.ts.snap b/test/__snapshots__/new.test.ts.snap index 96f8d25dbba..bb7f94d5298 100644 --- a/test/__snapshots__/new.test.ts.snap +++ b/test/__snapshots__/new.test.ts.snap @@ -1559,6 +1559,27 @@ const project = new AwsCdkAppSyncApp({ project.synth();" `; +exports[`projen new awscdk-app-java 1`] = ` +Object { + "src/test/java/projenrc.java": "import io.github.cdklabs.projen.awscdk.AwsCdkJavaApp; +import io.github.cdklabs.projen.awscdk.AwsCdkJavaAppOptions; + +public class projenrc { + public static void main(String[] args) { + AwsCdkJavaApp project = new AwsCdkJavaApp(AwsCdkJavaAppOptions.builder() + .artifactId(\\"my-app\\") + .cdkVersion(\\"^1.130.0\\") + .groupId(\\"org.acme\\") + .mainClass(\\"org.acme.App\\") + .name(\\"my-project\\") + .version(\\"0.1.0\\") + .build()); + project.synth(); + } +}", +} +`; + exports[`projen new awscdk-app-ts 1`] = ` Object { ".projenrc.js": "const { AwsCdkTypeScriptApp } = require(\\"projen\\"); diff --git a/test/awscdk/__snapshots__/java-app.test.ts.snap b/test/awscdk/__snapshots__/java-app.test.ts.snap new file mode 100644 index 00000000000..e6b4a45512f --- /dev/null +++ b/test/awscdk/__snapshots__/java-app.test.ts.snap @@ -0,0 +1,165 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`happy flow 1`] = ` +Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "app": "mvn exec:java --quiet -Dexec.mainClass=org.bacme.BoomApp", + "context": Object { + "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, + "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, + "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true, + "@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true, + "@aws-cdk/aws-efs:defaultEncryptionAtRest": true, + "@aws-cdk/aws-kms:defaultKeyPolicies": true, + "@aws-cdk/aws-lambda:recognizeVersionProps": true, + "@aws-cdk/aws-rds:lowercaseDbIdentifier": true, + "@aws-cdk/aws-s3:grantWriteWithoutAcl": true, + "@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true, + "@aws-cdk/core:enableStackNameDuplicates": true, + "@aws-cdk/core:stackRelativeExports": true, + "aws-cdk:enableDiffNoFail": true, + }, + "output": "cdk.out", +} +`; + +exports[`happy flow 2`] = ` +" + + 4.0.0 + org.acme + my-app + 0.1.0 + jar + my-app + + UTF-8 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + + 3.6 + + + + + + enforce-maven + + enforce + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + true + + true + true + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + false + protected + false + + -J-XX:+TieredCompilation + -J-XX:TieredStopAtLevel=1 + + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + + + + + software.amazon.awscdk + core + [1.130.0,2.0.0) + + + io.github.cdklabs + projen + 0.0.0 + test + + + org.junit.jupiter + junit-jupiter-api + 5.7.0 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.7.0 + test + + + +" +`; + +exports[`happy flow 3`] = ` +"package org.bacme; + +import org.junit.jupiter.api.Test; + +public class MyTest { + @Test + public void testHello() { + System.out.println(\\"Hello, world!\\"); + } +}" +`; diff --git a/test/awscdk/java-app.test.ts b/test/awscdk/java-app.test.ts new file mode 100644 index 00000000000..f3fe779a147 --- /dev/null +++ b/test/awscdk/java-app.test.ts @@ -0,0 +1,91 @@ +import * as xml from 'xmlbuilder2'; +import { awscdk } from '../../src'; +import { Testing } from '../../src/testing'; + +test('happy flow', () => { + const p = new awscdk.AwsCdkJavaApp({ + artifactId: 'my-app', + groupId: 'org.acme', + cdkVersion: '^1.130.0', + mainClass: 'org.bacme.BoomApp', + name: 'my-app', + version: '0.1.0', + }); + + const snapshot = Testing.synth(p); + expect(Object.keys(snapshot)).toStrictEqual([ + '.gitattributes', + '.github/workflows/stale.yml', + '.gitignore', + '.projen/deps.json', + '.projen/tasks.json', + 'cdk.json', + 'pom.xml', + 'README.md', + 'src/main/java/org/bacme/BoomApp.java', + 'src/test/java/org/bacme/MyTest.java', + ]); + expect(snapshot['cdk.json']).toMatchSnapshot(); + expect(snapshot['pom.xml']).toMatchSnapshot(); + expect(snapshot['src/test/java/org/bacme/MyTest.java']).toMatchSnapshot(); + expect(snapshot['cdk.json'].app).toStrictEqual('mvn exec:java --quiet -Dexec.mainClass=org.bacme.BoomApp'); +}); + +test('mainClass', () => { + const p = new awscdk.AwsCdkJavaApp({ + artifactId: 'my-app', + groupId: 'org.acme', + cdkVersion: '^1.130.0', + mainClass: 'org.acme.jojo.MyApp', + name: 'my-app', + version: '0.1.0', + }); + + const snapshot = Testing.synth(p); + expect(snapshot['cdk.json'].app).toStrictEqual('mvn exec:java --quiet -Dexec.mainClass=org.acme.jojo.MyApp'); +}); + +test('deps', () => { + const p = new awscdk.AwsCdkJavaApp({ + artifactId: 'my-app', + groupId: 'org.acme', + cdkVersion: '^1.120.0', + mainClass: 'org.acme.jojo.MyApp', + name: 'my-app', + version: '0.1.0', + cdkDependencies: [ + 'aws-lambda', + 'aws-sns', + ], + }); + + p.addCdkDependency('aws-sqs'); + + const snapshot = Testing.synth(p); + const pom = JSON.parse(xml.convert(snapshot['pom.xml'], { + format: 'json', + })); + + expect(pom.project.dependencies.dependency.filter((d: any) => d.groupId === 'software.amazon.awscdk')).toStrictEqual([ + { + artifactId: 'aws-lambda', + groupId: 'software.amazon.awscdk', + version: '[1.120.0,2.0.0)', + }, + { + artifactId: 'aws-sns', + groupId: 'software.amazon.awscdk', + version: '[1.120.0,2.0.0)', + }, + { + artifactId: 'aws-sqs', + groupId: 'software.amazon.awscdk', + version: '[1.120.0,2.0.0)', + }, + { + artifactId: 'core', + groupId: 'software.amazon.awscdk', + version: '[1.120.0,2.0.0)', + }, + ]); +}); \ No newline at end of file