diff --git a/fragments/java-version/accelerator.axl b/fragments/java-version/accelerator.axl index 51912af45..514e8beff 100644 --- a/fragments/java-version/accelerator.axl +++ b/fragments/java-version/accelerator.axl @@ -1,8 +1,4 @@ engine { - applyTo("README.md") { - UniquePath(strategy: FavorForeign) - ReplaceText(regex: {pattern: "set BP_JVM_VERSION=.*", with: 'set BP_JVM_VERSION=' + #javaVersion}) - } applyTo("pom.xml") { ReplaceText(regex: {pattern: ".*<", with: '' + #javaVersion + '<'}) @@ -15,4 +11,9 @@ engine { applyTo("build.gradle.kts") { ReplaceText(regex: {pattern: "(?JavaVersion\.VERSION_)(\d+)", with: '${unmodified}' + #javaVersion}) } + + applyTo(".tanzu/config/*.yml") { + OpenRewriteRecipe('org.openrewrite.yaml.ChangeValue', { oldKeyPath: "$.spec.build.nonSecretEnv[?(@.name == 'BP_JVM_VERSION')].value", value: #javaVersion}) + } + } diff --git a/spring-ai-chat/.tanzu/config/spring-ai-chat.yml b/spring-ai-chat/.tanzu/config/spring-ai-chat.yml new file mode 100644 index 000000000..e2e1737af --- /dev/null +++ b/spring-ai-chat/.tanzu/config/spring-ai-chat.yml @@ -0,0 +1,15 @@ +apiVersion: apps.tanzu.vmware.com/v1 +kind: ContainerApp +metadata: + creationTimestamp: null + name: spring-ai-chat +spec: + build: + buildpacks: {} + nonSecretEnv: + - name: BP_JVM_VERSION + value: "17" + path: ../.. + ports: + - name: main + port: 8080 diff --git a/spring-ai-chat/README.md b/spring-ai-chat/README.md index 271122c3c..ad42b99ca 100644 --- a/spring-ai-chat/README.md +++ b/spring-ai-chat/README.md @@ -68,17 +68,13 @@ other. ## Configuring your app environment Change to the root directory of your generated app. -### Initialize the ContainerApp -```sh -tanzu app init -``` -### Configure the JDK version +### About the ContainerApp -You need to specify the JDK version to be used for the app: +The project contains a `ContainerApp` manifest file that can be used when building and deploying the app. To review the content of this file run: ```sh -tanzu app config build non-secret-env set BP_JVM_VERSION=17 +cat .tanzu/config/spring-ai-chat.yml ``` ### Configure HTTP Ingress Routing diff --git a/spring-ai-chat/accelerator.axl b/spring-ai-chat/accelerator.axl index bbc037b44..959bc3412 100644 --- a/spring-ai-chat/accelerator.axl +++ b/spring-ai-chat/accelerator.axl @@ -41,6 +41,12 @@ engine { ReplaceText({{text: "spring-ai-chat", with: #artifactId.toLowerCase()}}) } + // Update the artifact name and path as needed + applyTo(".tanzu/config/spring-ai-chat.yml") { + ReplaceText({{text: "spring-ai-chat", with: #artifactId.toLowerCase()}}) + RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '.yml') + } + { Include({'**'}) + InvokeFragment("build-wrapper-maven") diff --git a/spring-ai-chat/tanzu.yml b/spring-ai-chat/tanzu.yml new file mode 100644 index 000000000..ca7b3ffe2 --- /dev/null +++ b/spring-ai-chat/tanzu.yml @@ -0,0 +1,6 @@ +apiVersion: config.tanzu.vmware.com/v1 +configuration: + dev: + paths: + - .tanzu/config/ +kind: TanzuConfig diff --git a/tanzu-java-web-app/.tanzu/config/tanzu-java-web-app.yml b/tanzu-java-web-app/.tanzu/config/tanzu-java-web-app.yml new file mode 100644 index 000000000..36380a34a --- /dev/null +++ b/tanzu-java-web-app/.tanzu/config/tanzu-java-web-app.yml @@ -0,0 +1,15 @@ +apiVersion: apps.tanzu.vmware.com/v1 +kind: ContainerApp +metadata: + creationTimestamp: null + name: tanzu-java-web-app +spec: + build: + buildpacks: {} + nonSecretEnv: + - name: BP_JVM_VERSION + value: "17" + path: ../.. + ports: + - name: main + port: 8080 diff --git a/tanzu-java-web-app/README.md b/tanzu-java-web-app/README.md index cb14f9f21..4f68e73b7 100644 --- a/tanzu-java-web-app/README.md +++ b/tanzu-java-web-app/README.md @@ -75,18 +75,12 @@ tanzu build config --containerapp-registry REGISTRY Change to the root directory of your generated app. -### Initialize the ContainerApp +### About the ContainerApp -```sh -tanzu app init -``` - -### Configure the JDK version - -You need to specify the JDK version to be used for the app: +The project contains a `ContainerApp` manifest file that can be used when building and deploying the app. To review the content of this file run: ```sh -tanzu app config build non-secret-env set BP_JVM_VERSION=17 +cat .tanzu/config/tanzu-java-web-app.yml ``` ### Configure for native build with GraalVM diff --git a/tanzu-java-web-app/accelerator.axl b/tanzu-java-web-app/accelerator.axl index 81742a3ef..ddb9f3062 100644 --- a/tanzu-java-web-app/accelerator.axl +++ b/tanzu-java-web-app/accelerator.axl @@ -22,6 +22,12 @@ engine { ReplaceText({{text: "tanzu-java-web-app", with: #artifactId.toLowerCase()}}) } + // Update the artifact name and path as needed + applyTo(".tanzu/config/tanzu-java-web-app.yml") { + ReplaceText({{text: "tanzu-java-web-app", with: #artifactId.toLowerCase()}}) + RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '.yml') + } + { Include({'**'}) // Update the java version diff --git a/tanzu-java-web-app/tanzu.yml b/tanzu-java-web-app/tanzu.yml new file mode 100644 index 000000000..ca7b3ffe2 --- /dev/null +++ b/tanzu-java-web-app/tanzu.yml @@ -0,0 +1,6 @@ +apiVersion: config.tanzu.vmware.com/v1 +configuration: + dev: + paths: + - .tanzu/config/ +kind: TanzuConfig