// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`PDK Pipeline Java Unit Tests Defaults 1`] = ` { ".gitattributes": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". /.gitattributes linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.gitignore linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated /.projen/tasks.json linguist-generated /cdk.json linguist-generated /pom.xml linguist-generated", ".github/workflows/pull-request-lint.yml": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". name: pull-request-lint on: pull_request_target: types: - labeled - opened - synchronize - reopened - ready_for_review - edited jobs: validate: name: Validate PR title runs-on: ubuntu-latest permissions: pull-requests: write steps: - uses: amannn/action-semantic-pull-request@v5.0.2 env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} with: types: |- feat fix chore requireScope: false ", ".gitignore": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". node_modules/ !/.gitattributes !/.projen/tasks.json !/.projen/deps.json !/.projen/files.json !/.github/workflows/pull-request-lint.yml !/pom.xml .classpath .project .settings target dist/java !/cdk.json /cdk.out/ .cdk.staging/ ", ".projen/deps.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "dependencies": [ { "metadata": { "configuration": { "source": "1.8", "target": "1.8", }, }, "name": "org.apache.maven.plugins/maven-compiler-plugin", "type": "build", "version": "3.8.1", }, { "metadata": { "configuration": { "rules": [ { "requireMavenVersion": [ { "version": "3.6", }, ], }, ], }, "executions": [ { "goals": [ "enforce", ], "id": "enforce-maven", }, ], }, "name": "org.apache.maven.plugins/maven-enforcer-plugin", "type": "build", "version": "3.0.0-M3", }, { "metadata": { "configuration": { "archive": { "index": true, "manifest": { "addDefaultImplementationEntries": true, "addDefaultSpecificationEntries": true, }, }, }, }, "name": "org.apache.maven.plugins/maven-jar-plugin", "type": "build", "version": "3.2.0", }, { "metadata": { "configuration": { "additionalJOptions": { "additionalJOption": [ "-J-XX:+TieredCompilation", "-J-XX:TieredStopAtLevel=1", ], }, "detectJavaApiLink": false, "failOnError": false, "show": "protected", }, "executions": [ { "goals": [ "jar", ], "id": "attach-javadocs", }, ], }, "name": "org.apache.maven.plugins/maven-javadoc-plugin", "type": "build", "version": "3.2.0", }, { "metadata": { "executions": [ { "goals": [ "jar", ], "id": "attach-sources", }, ], }, "name": "org.apache.maven.plugins/maven-source-plugin", "type": "build", "version": "3.2.1", }, { "name": "org.codehaus.mojo/exec-maven-plugin", "type": "build", "version": "3.0.0", }, { "name": "io.github.cdklabs/cdknag", "type": "runtime", "version": "^2", }, { "name": "software.amazon.awscdk/aws-cdk-lib", "type": "runtime", "version": "^2.0.0", }, { "name": "software.aws.awsprototypingsdk/pdk-nag", "type": "runtime", "version": "^0", }, { "name": "software.aws.awsprototypingsdk/pipeline", "type": "runtime", "version": "^0", }, { "name": "software.constructs/constructs", "type": "runtime", "version": "^10.0.5", }, { "name": "io.github.cdklabs/projen", "type": "test", "version": "99.99.99", }, { "name": "org.junit.jupiter/junit-jupiter-api", "type": "test", "version": "5.7.0", }, { "name": "org.junit.jupiter/junit-jupiter-engine", "type": "test", "version": "5.7.0", }, ], }, ".projen/files.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "files": [ ".gitattributes", ".github/workflows/pull-request-lint.yml", ".gitignore", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", "cdk.json", "pom.xml", ], }, ".projen/tasks.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "tasks": { "build": { "description": "Full release build", "name": "build", "steps": [ { "spawn": "default", }, { "spawn": "pre-compile", }, { "spawn": "compile", }, { "spawn": "post-compile", }, { "spawn": "test", }, { "spawn": "package", }, ], }, "clobber": { "condition": "git diff --exit-code > /dev/null", "description": "hard resets to HEAD of origin and cleans the local repo", "env": { "BRANCH": "$(git branch --show-current)", }, "name": "clobber", "steps": [ { "exec": "git checkout -b scratch", "name": "save current HEAD in "scratch" branch", }, { "exec": "git checkout $BRANCH", }, { "exec": "git fetch origin", "name": "fetch latest changes from origin", }, { "exec": "git reset --hard origin/$BRANCH", "name": "hard reset to origin commit", }, { "exec": "git clean -fdx", "name": "clean all untracked files", }, { "say": "ready to rock! (unpushed commits are under the "scratch" branch)", }, ], }, "compile": { "description": "Only compile", "name": "compile", "steps": [ { "exec": "mvn compiler:compile", }, ], }, "default": { "description": "Synthesize project files", "name": "default", "steps": [ { "exec": "mvn compiler:testCompile --quiet", }, { "exec": "mvn exec:java --quiet -Dexec.mainClass=projenrc -Dexec.classpathScope="test"", }, ], }, "deploy": { "description": "Deploys your CDK app to the AWS cloud", "name": "deploy", "steps": [ { "exec": "cdk deploy", "receiveArgs": true, }, ], }, "destroy": { "description": "Destroys your cdk app in the AWS cloud", "name": "destroy", "steps": [ { "exec": "cdk destroy", "receiveArgs": true, }, ], }, "diff": { "description": "Diffs the currently deployed app against your code", "name": "diff", "steps": [ { "exec": "cdk diff", }, ], }, "eject": { "description": "Remove projen from the project", "env": { "PROJEN_EJECTING": "true", }, "name": "eject", "steps": [ { "spawn": "default", }, ], }, "package": { "description": "Creates the distribution package", "env": { "MAVEN_OPTS": "-XX:+TieredCompilation -XX:TieredStopAtLevel=1", }, "name": "package", "steps": [ { "exec": "mkdir -p dist/java", }, { "exec": "mvn deploy -D=altDeploymentRepository=local::default::file:///$PWD/dist/java", }, ], }, "post-compile": { "description": "Runs after successful compilation", "name": "post-compile", "steps": [ { "spawn": "synth", }, ], }, "pre-compile": { "description": "Prepare the project for compilation", "name": "pre-compile", }, "synth": { "description": "Synthesizes your cdk app into cdk.out", "name": "synth", "steps": [ { "exec": "cdk synth", }, ], }, "synth:silent": { "description": "Synthesizes your cdk app into cdk.out and suppresses the template in stdout (part of "yarn build")", "name": "synth:silent", "steps": [ { "exec": "cdk synth -q", }, ], }, "test": { "description": "Run tests", "name": "test", "steps": [ { "exec": "mvn test", }, ], }, "watch": { "description": "Watches changes in your source code and rebuilds and deploys to the current account", "name": "watch", "steps": [ { "exec": "cdk deploy --hotswap", }, { "exec": "cdk watch", }, ], }, }, }, "README.md": "# replace this", "cdk.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "app": "mvn exec:java --quiet -Dexec.mainClass=software.aws.Pipeline", "output": "cdk.out", }, "pom.xml": " 4.0.0 test test 0.0.0 jar Defaults 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 io.github.cdklabs cdknag [2.0.0,3.0.0) software.amazon.awscdk aws-cdk-lib [2.0.0,3.0.0) software.aws.awsprototypingsdk pdk-nag (,1.0.0) software.aws.awsprototypingsdk pipeline (,1.0.0) software.constructs constructs [10.0.5,11.0.0) io.github.cdklabs projen 99.99.99 test org.junit.jupiter junit-jupiter-api 5.7.0 test org.junit.jupiter junit-jupiter-engine 5.7.0 test ", "src/main/java/software/aws/ApplicationStack.java": "package software.aws; import org.jetbrains.annotations.Nullable; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.constructs.Construct; public class ApplicationStack extends Stack { public ApplicationStack(Construct construct, String id, @Nullable StackProps props) { super(construct, id, props); // TODO: Add Resources } }", "src/main/java/software/aws/ApplicationStage.java": "package software.aws; import org.jetbrains.annotations.Nullable; import software.amazon.awscdk.Stage; import software.amazon.awscdk.StageProps; import software.constructs.Construct; public class ApplicationStage extends Stage { protected ApplicationStage(Construct scope, String id, @Nullable StageProps props) { super(scope, id, props); new ApplicationStack(this, "MyAplication", null); } }", "src/main/java/software/aws/Pipeline.java": "package software.aws; import software.aws.awsprototypingsdk.pdknag.PDKNagApp; import software.aws.awsprototypingsdk.pdknag.PDKNag; import software.aws.awsprototypingsdk.pipeline.PDKPipeline; import software.aws.awsprototypingsdk.pipeline.IsDefaultBranchProps; import software.amazon.awscdk.Environment; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.StageProps; public class Pipeline { public static void main(String[] args) { PDKNagApp app = PDKNag.app(); String branchPrefix = PDKPipeline.getBranchPrefix(IsDefaultBranchProps.builder() .node(app.getNode()) .build()); PipelineStack pipelineStack = new PipelineStack(app, branchPrefix + "PipelineStack", StackProps.builder() .env(Environment.builder() .account(System.getenv("CDK_DEFAULT_ACCOUNT")) .region(System.getenv("CDK_DEFAULT_REGION")) .build()) .build()); ApplicationStage devStage = new ApplicationStage(app, branchPrefix + "Dev", StageProps.builder() .env(Environment.builder() .account(System.getenv("CDK_DEFAULT_ACCOUNT")) .region(System.getenv("CDK_DEFAULT_REGION")) .build()) .build()); pipelineStack.getPipeline().addStage(devStage); // Add additional stages here i.e. Prod // if (PDKPipeline.isDefaultBranch(IsDefaultBranchProps.builder() // .node(app.getNode()) // .build())) ... pipelineStack.getPipeline().buildPipeline(); // Needed for CDK Nag app.synth(); } }", "src/main/java/software/aws/PipelineStack.java": "package software.aws; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import org.jetbrains.annotations.Nullable; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.pipelines.FileSet; import software.amazon.awscdk.pipelines.IFileSetProducer; import software.amazon.jsii.JsiiObjectMapper; import software.aws.awsprototypingsdk.pipeline.PDKPipeline; import software.aws.awsprototypingsdk.pipeline.PDKPipelineProps; import software.aws.awsprototypingsdk.pipeline.SonarCodeScannerConfig; import software.constructs.Construct; import java.util.List; import java.util.function.Function; public class PipelineStack extends Stack { private PDKPipeline pipeline; public PipelineStack(Construct scope, String id, @Nullable StackProps props) { super(scope, id, props); SonarCodeScannerConfig sonarConfig = null; Object sonarCtx = this.getNode().tryGetContext("sonarqubeScannerConfig"); String repositoryName = (String) this.getNode().tryGetContext("repositoryName"); String defaultBranchName = (String) this.getNode().tryGetContext("defaultBranchName"); if (sonarCtx != null) { JsonNode ctxJson = JsiiObjectMapper.valueToTree(sonarCtx).get("$jsii.map"); sonarConfig = SonarCodeScannerConfig.builder() .cfnNagIgnorePath(getNode(ctxJson, "cfnNagIgnorePath", JsonNode::asText)) .sonarqubeAuthorizedGroup(getNode(ctxJson, "sonarqubeAuthorizedGroup", JsonNode::asText)) .sonarqubeEndpoint(getNode(ctxJson, "sonarqubeEndpoint", JsonNode::asText)) .sonarqubeProjectName(getNode(ctxJson, "sonarqubeProjectName", JsonNode::asText)) .sonarqubeSpecificProfileOrGateName(getNode(ctxJson, "sonarqubeSpecificProfileOrGateName", JsonNode::asText)) .sonarqubeDefaultProfileOrGateName(getNode(ctxJson, "sonarqubeDefaultProfileOrGateName", JsonNode::asText)) .preArchiveCommands(getNode(ctxJson, "preArchiveCommands", (node) -> JsiiObjectMapper.INSTANCE.convertValue(node, new TypeReference>() {}))) .sonarqubeTags(getNode(ctxJson, "sonarqubeTags", (node) -> JsiiObjectMapper.INSTANCE.convertValue(node, new TypeReference>() {}))) .build(); } this.pipeline = new PDKPipeline(this, "ApplicationPipeline", PDKPipelineProps.builder() .primarySynthDirectory("packages/infra/cdk.out") .repositoryName(repositoryName != null ? repositoryName : "monorepo") .defaultBranchName(defaultBranchName != null ? defaultBranchName : PDKPipeline.DEFAULT_BRANCH_NAME) .publishAssetsInParallel(false) .crossAccountKeys(true) .sonarCodeScannerConfig(sonarConfig) .synth(new IFileSetProducer() { @Override public @Nullable FileSet getPrimaryOutput() { return null; } }) .build()); } private static T getNode(JsonNode parent, String fieldName, Function supplier) { JsonNode node = parent.get(fieldName); return node != null ? supplier.apply(node) : null; } public PDKPipeline getPipeline() { return this.pipeline; } }", "src/test/java/software/aws/PipelineTest.java": "package software.aws; import org.junit.jupiter.api.Test; public class PipelineTest { @Test public void testPipeline() { System.out.println("Implement me!"); } }", } `; exports[`PDK Pipeline Java Unit Tests With Context 1`] = ` { ".gitattributes": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". /.gitattributes linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.gitignore linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated /.projen/tasks.json linguist-generated /cdk.json linguist-generated /pom.xml linguist-generated", ".github/workflows/pull-request-lint.yml": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". name: pull-request-lint on: pull_request_target: types: - labeled - opened - synchronize - reopened - ready_for_review - edited jobs: validate: name: Validate PR title runs-on: ubuntu-latest permissions: pull-requests: write steps: - uses: amannn/action-semantic-pull-request@v5.0.2 env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} with: types: |- feat fix chore requireScope: false ", ".gitignore": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". node_modules/ !/.gitattributes !/.projen/tasks.json !/.projen/deps.json !/.projen/files.json !/.github/workflows/pull-request-lint.yml !/pom.xml .classpath .project .settings target dist/java !/cdk.json /cdk.out/ .cdk.staging/ ", ".projen/deps.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "dependencies": [ { "metadata": { "configuration": { "source": "1.8", "target": "1.8", }, }, "name": "org.apache.maven.plugins/maven-compiler-plugin", "type": "build", "version": "3.8.1", }, { "metadata": { "configuration": { "rules": [ { "requireMavenVersion": [ { "version": "3.6", }, ], }, ], }, "executions": [ { "goals": [ "enforce", ], "id": "enforce-maven", }, ], }, "name": "org.apache.maven.plugins/maven-enforcer-plugin", "type": "build", "version": "3.0.0-M3", }, { "metadata": { "configuration": { "archive": { "index": true, "manifest": { "addDefaultImplementationEntries": true, "addDefaultSpecificationEntries": true, }, }, }, }, "name": "org.apache.maven.plugins/maven-jar-plugin", "type": "build", "version": "3.2.0", }, { "metadata": { "configuration": { "additionalJOptions": { "additionalJOption": [ "-J-XX:+TieredCompilation", "-J-XX:TieredStopAtLevel=1", ], }, "detectJavaApiLink": false, "failOnError": false, "show": "protected", }, "executions": [ { "goals": [ "jar", ], "id": "attach-javadocs", }, ], }, "name": "org.apache.maven.plugins/maven-javadoc-plugin", "type": "build", "version": "3.2.0", }, { "metadata": { "executions": [ { "goals": [ "jar", ], "id": "attach-sources", }, ], }, "name": "org.apache.maven.plugins/maven-source-plugin", "type": "build", "version": "3.2.1", }, { "name": "org.codehaus.mojo/exec-maven-plugin", "type": "build", "version": "3.0.0", }, { "name": "io.github.cdklabs/cdknag", "type": "runtime", "version": "^2", }, { "name": "software.amazon.awscdk/aws-cdk-lib", "type": "runtime", "version": "^2.0.0", }, { "name": "software.aws.awsprototypingsdk/pdk-nag", "type": "runtime", "version": "^0", }, { "name": "software.aws.awsprototypingsdk/pipeline", "type": "runtime", "version": "^0", }, { "name": "software.constructs/constructs", "type": "runtime", "version": "^10.0.5", }, { "name": "io.github.cdklabs/projen", "type": "test", "version": "99.99.99", }, { "name": "org.junit.jupiter/junit-jupiter-api", "type": "test", "version": "5.7.0", }, { "name": "org.junit.jupiter/junit-jupiter-engine", "type": "test", "version": "5.7.0", }, ], }, ".projen/files.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "files": [ ".gitattributes", ".github/workflows/pull-request-lint.yml", ".gitignore", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", "cdk.json", "pom.xml", ], }, ".projen/tasks.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "tasks": { "build": { "description": "Full release build", "name": "build", "steps": [ { "spawn": "default", }, { "spawn": "pre-compile", }, { "spawn": "compile", }, { "spawn": "post-compile", }, { "spawn": "test", }, { "spawn": "package", }, ], }, "clobber": { "condition": "git diff --exit-code > /dev/null", "description": "hard resets to HEAD of origin and cleans the local repo", "env": { "BRANCH": "$(git branch --show-current)", }, "name": "clobber", "steps": [ { "exec": "git checkout -b scratch", "name": "save current HEAD in "scratch" branch", }, { "exec": "git checkout $BRANCH", }, { "exec": "git fetch origin", "name": "fetch latest changes from origin", }, { "exec": "git reset --hard origin/$BRANCH", "name": "hard reset to origin commit", }, { "exec": "git clean -fdx", "name": "clean all untracked files", }, { "say": "ready to rock! (unpushed commits are under the "scratch" branch)", }, ], }, "compile": { "description": "Only compile", "name": "compile", "steps": [ { "exec": "mvn compiler:compile", }, ], }, "default": { "description": "Synthesize project files", "name": "default", "steps": [ { "exec": "mvn compiler:testCompile --quiet", }, { "exec": "mvn exec:java --quiet -Dexec.mainClass=projenrc -Dexec.classpathScope="test"", }, ], }, "deploy": { "description": "Deploys your CDK app to the AWS cloud", "name": "deploy", "steps": [ { "exec": "cdk deploy", "receiveArgs": true, }, ], }, "destroy": { "description": "Destroys your cdk app in the AWS cloud", "name": "destroy", "steps": [ { "exec": "cdk destroy", "receiveArgs": true, }, ], }, "diff": { "description": "Diffs the currently deployed app against your code", "name": "diff", "steps": [ { "exec": "cdk diff", }, ], }, "eject": { "description": "Remove projen from the project", "env": { "PROJEN_EJECTING": "true", }, "name": "eject", "steps": [ { "spawn": "default", }, ], }, "package": { "description": "Creates the distribution package", "env": { "MAVEN_OPTS": "-XX:+TieredCompilation -XX:TieredStopAtLevel=1", }, "name": "package", "steps": [ { "exec": "mkdir -p dist/java", }, { "exec": "mvn deploy -D=altDeploymentRepository=local::default::file:///$PWD/dist/java", }, ], }, "post-compile": { "description": "Runs after successful compilation", "name": "post-compile", "steps": [ { "spawn": "synth", }, ], }, "pre-compile": { "description": "Prepare the project for compilation", "name": "pre-compile", }, "synth": { "description": "Synthesizes your cdk app into cdk.out", "name": "synth", "steps": [ { "exec": "cdk synth", }, ], }, "synth:silent": { "description": "Synthesizes your cdk app into cdk.out and suppresses the template in stdout (part of "yarn build")", "name": "synth:silent", "steps": [ { "exec": "cdk synth -q", }, ], }, "test": { "description": "Run tests", "name": "test", "steps": [ { "exec": "mvn test", }, ], }, "watch": { "description": "Watches changes in your source code and rebuilds and deploys to the current account", "name": "watch", "steps": [ { "exec": "cdk deploy --hotswap", }, { "exec": "cdk watch", }, ], }, }, }, "README.md": "# replace this", "cdk.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "app": "mvn exec:java --quiet -Dexec.mainClass=software.aws.Pipeline", "context": { "sonarqubeScannerConfig": { "preArchiveCommands": [ "echo here", ], "sonarqubeAuthorizedGroup": "group", "sonarqubeDefaultProfileOrGateName": "default", "sonarqubeEndpoint": "https://my.endpoint", "sonarqubeProjectName": "WithContext", "sonarqubeSpecificProfileOrGateName": "specific", "sonarqubeTags": [ "sample", ], }, }, "output": "cdk.out", }, "pom.xml": " 4.0.0 test test 0.0.0 jar WithContext 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 io.github.cdklabs cdknag [2.0.0,3.0.0) software.amazon.awscdk aws-cdk-lib [2.0.0,3.0.0) software.aws.awsprototypingsdk pdk-nag (,1.0.0) software.aws.awsprototypingsdk pipeline (,1.0.0) software.constructs constructs [10.0.5,11.0.0) io.github.cdklabs projen 99.99.99 test org.junit.jupiter junit-jupiter-api 5.7.0 test org.junit.jupiter junit-jupiter-engine 5.7.0 test ", "src/main/java/software/aws/ApplicationStack.java": "package software.aws; import org.jetbrains.annotations.Nullable; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.constructs.Construct; public class ApplicationStack extends Stack { public ApplicationStack(Construct construct, String id, @Nullable StackProps props) { super(construct, id, props); // TODO: Add Resources } }", "src/main/java/software/aws/ApplicationStage.java": "package software.aws; import org.jetbrains.annotations.Nullable; import software.amazon.awscdk.Stage; import software.amazon.awscdk.StageProps; import software.constructs.Construct; public class ApplicationStage extends Stage { protected ApplicationStage(Construct scope, String id, @Nullable StageProps props) { super(scope, id, props); new ApplicationStack(this, "MyAplication", null); } }", "src/main/java/software/aws/Pipeline.java": "package software.aws; import software.aws.awsprototypingsdk.pdknag.PDKNagApp; import software.aws.awsprototypingsdk.pdknag.PDKNag; import software.aws.awsprototypingsdk.pipeline.PDKPipeline; import software.aws.awsprototypingsdk.pipeline.IsDefaultBranchProps; import software.amazon.awscdk.Environment; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.StageProps; public class Pipeline { public static void main(String[] args) { PDKNagApp app = PDKNag.app(); String branchPrefix = PDKPipeline.getBranchPrefix(IsDefaultBranchProps.builder() .node(app.getNode()) .build()); PipelineStack pipelineStack = new PipelineStack(app, branchPrefix + "PipelineStack", StackProps.builder() .env(Environment.builder() .account(System.getenv("CDK_DEFAULT_ACCOUNT")) .region(System.getenv("CDK_DEFAULT_REGION")) .build()) .build()); ApplicationStage devStage = new ApplicationStage(app, branchPrefix + "Dev", StageProps.builder() .env(Environment.builder() .account(System.getenv("CDK_DEFAULT_ACCOUNT")) .region(System.getenv("CDK_DEFAULT_REGION")) .build()) .build()); pipelineStack.getPipeline().addStage(devStage); // Add additional stages here i.e. Prod // if (PDKPipeline.isDefaultBranch(IsDefaultBranchProps.builder() // .node(app.getNode()) // .build())) ... pipelineStack.getPipeline().buildPipeline(); // Needed for CDK Nag app.synth(); } }", "src/main/java/software/aws/PipelineStack.java": "package software.aws; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import org.jetbrains.annotations.Nullable; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.pipelines.FileSet; import software.amazon.awscdk.pipelines.IFileSetProducer; import software.amazon.jsii.JsiiObjectMapper; import software.aws.awsprototypingsdk.pipeline.PDKPipeline; import software.aws.awsprototypingsdk.pipeline.PDKPipelineProps; import software.aws.awsprototypingsdk.pipeline.SonarCodeScannerConfig; import software.constructs.Construct; import java.util.List; import java.util.function.Function; public class PipelineStack extends Stack { private PDKPipeline pipeline; public PipelineStack(Construct scope, String id, @Nullable StackProps props) { super(scope, id, props); SonarCodeScannerConfig sonarConfig = null; Object sonarCtx = this.getNode().tryGetContext("sonarqubeScannerConfig"); String repositoryName = (String) this.getNode().tryGetContext("repositoryName"); String defaultBranchName = (String) this.getNode().tryGetContext("defaultBranchName"); if (sonarCtx != null) { JsonNode ctxJson = JsiiObjectMapper.valueToTree(sonarCtx).get("$jsii.map"); sonarConfig = SonarCodeScannerConfig.builder() .cfnNagIgnorePath(getNode(ctxJson, "cfnNagIgnorePath", JsonNode::asText)) .sonarqubeAuthorizedGroup(getNode(ctxJson, "sonarqubeAuthorizedGroup", JsonNode::asText)) .sonarqubeEndpoint(getNode(ctxJson, "sonarqubeEndpoint", JsonNode::asText)) .sonarqubeProjectName(getNode(ctxJson, "sonarqubeProjectName", JsonNode::asText)) .sonarqubeSpecificProfileOrGateName(getNode(ctxJson, "sonarqubeSpecificProfileOrGateName", JsonNode::asText)) .sonarqubeDefaultProfileOrGateName(getNode(ctxJson, "sonarqubeDefaultProfileOrGateName", JsonNode::asText)) .preArchiveCommands(getNode(ctxJson, "preArchiveCommands", (node) -> JsiiObjectMapper.INSTANCE.convertValue(node, new TypeReference>() {}))) .sonarqubeTags(getNode(ctxJson, "sonarqubeTags", (node) -> JsiiObjectMapper.INSTANCE.convertValue(node, new TypeReference>() {}))) .build(); } this.pipeline = new PDKPipeline(this, "ApplicationPipeline", PDKPipelineProps.builder() .primarySynthDirectory("packages/infra/cdk.out") .repositoryName(repositoryName != null ? repositoryName : "monorepo") .defaultBranchName(defaultBranchName != null ? defaultBranchName : PDKPipeline.DEFAULT_BRANCH_NAME) .publishAssetsInParallel(false) .crossAccountKeys(true) .sonarCodeScannerConfig(sonarConfig) .synth(new IFileSetProducer() { @Override public @Nullable FileSet getPrimaryOutput() { return null; } }) .build()); } private static T getNode(JsonNode parent, String fieldName, Function supplier) { JsonNode node = parent.get(fieldName); return node != null ? supplier.apply(node) : null; } public PDKPipeline getPipeline() { return this.pipeline; } }", "src/test/java/software/aws/PipelineTest.java": "package software.aws; import org.junit.jupiter.api.Test; public class PipelineTest { @Test public void testPipeline() { System.out.println("Implement me!"); } }", } `; exports[`PDK Pipeline Java Unit Tests projenrc synth correctly 1`] = ` "import software.aws.awsprototypingsdk.pipeline.PDKPipelineJavaProject; import software.aws.awsprototypingsdk.pipeline.PDKPipelineJavaProjectOptions; public class projenrc { public static void main(String[] args) { PDKPipelineJavaProject project = new PDKPipelineJavaProject(PDKPipelineJavaProjectOptions.builder() .artifactId("test") .cdkVersion("2.0.0") .groupId("test") .mainClass("software.aws.Pipeline") .version("0.0.0") .name("ProjenRc") .build()); project.synth(); } }" `;