Skip to content

Commit ef8caf9

Browse files
authored
Merge pull request #20128 from christiansavchev/master
Automatic commit: Move 'create-hello-world-mta' from QA to Production
2 parents 9324344 + a36aa32 commit ef8caf9

File tree

1 file changed

+185
-0
lines changed

1 file changed

+185
-0
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
parser: v2
3+
auto_validation: true
4+
time: 20
5+
tags: [ tutorial>beginner, programming-tool>java]
6+
primary_tag: software-product>sap-business-technology-platform
7+
---
8+
9+
# Create a Hello World Multitarget Application
10+
<!-- description --> This tutorial will help you create a module that describes a Java application, a resource that describes your database binding and additional metadata required for the deployment.
11+
12+
## Prerequisites
13+
- You have created a Java application `.war file.`
14+
- You have an SAP BTP database configured in your subaccount and valid credentials.
15+
16+
## You will learn
17+
- How to create a module that describes a Java application
18+
- How to create a resource that describes your database binding
19+
- How to create additional metadata required for the deployment
20+
21+
22+
---
23+
24+
### Modeling the MTA deployment descriptor
25+
26+
27+
You define the entities that have to be deployed, namely modules and resources related to other modules, in the MTA deployment descriptor. This is a YAML file that defines the contract between you as a deployable artifact provider and the SAP BTP as a deployer tool. Initially, you have to describe the metadata required for the deployment.
28+
29+
1. Create an empty text file and name it `mtad.yaml.`
30+
2. Using a text editor, enter the following data in the file:
31+
32+
>Strictly adhere to the correct indentations when working with YAML files, and do not use the tabulator character.
33+
34+
``` YAML
35+
_schema-version: '3.1'
36+
37+
parameters:
38+
hcp-deployer-version: '1.1.0'
39+
40+
ID: com.example.demo.basic
41+
version: 0.1.0
42+
```
43+
44+
The example above instructs the SAP BTP to:
45+
46+
* Validate the Multitarget Application against the MTA specification version `3.1`
47+
* Use deploy features specific to the SAP BTP marked as version `1.0`
48+
* Deploy the Multitarget Application as a Solution with ID `com.example.demo.basic`
49+
* Consider the Multitarget Application version as a version `0.1.0`
50+
51+
52+
3. Create the module that describes the Java application. In the mtad.yaml, add the following data:
53+
54+
``` YAML
55+
modules:
56+
-name: example-java-app
57+
type: com.sap.java
58+
requires:
59+
- name: db-binding
60+
parameters:
61+
name: example
62+
jvm-arguments: -server
63+
java-version: JRE 7
64+
runtime: neo-java-web
65+
runtime-version: 1
66+
```
67+
68+
The example above instructs the SAP BTP to:
69+
70+
* Deploy a Java application with a specific runtime, Java version, and runtime arguments
71+
* Require a MTA resource called db-bindings, where you describe your binding data
72+
73+
4. Describe the database binding ID and the database credentials the Java application has to use by adding the following to the `mtad.yaml`:
74+
75+
```YAML
76+
resources:
77+
- name: db-binding
78+
type: com.sap.hcp.persistence
79+
parameters:
80+
id:
81+
```
82+
83+
The example above instructs the SAP BTP to create a database binding during the deployment process.
84+
85+
At this point of the procedure, no database ID or credentials for your database binding have been added. The reason for this is that all the content of the `mtad.yaml` so far is a target-platform independent, meaning that the same `mtad.yaml` could be deployed to multiple SAP BTP subaccounts.
86+
87+
The information about your database ID and credentials are, however, subaccount-specific. To keep the `mtad.yaml` target platform independent, you have to create an MTA extension descriptor. This file is used in addition to your primary descriptor file, and contains data that is account-specific.
88+
89+
>Security-sensitive data, for example database credentials, should be always deployed using an MTA extension descriptor, so that this data is encrypted.
90+
91+
92+
93+
### Create the MTA extension descriptor
94+
95+
96+
1. Create an empty text file and name it `dev.mtaext.`
97+
98+
2. Using a text editor, enter the following data in the file:
99+
100+
```YAML
101+
_schema-version: '3.1'
102+
ID: com.example.demo.basic.config
103+
extends: com.example.demo.basic
104+
parameters:
105+
title: Basic Solution
106+
description: This is a sample of a basic Solution.
107+
resources:
108+
- name: db-binding
109+
parameters:
110+
id: dbalias
111+
user-id: myuser
112+
password : mypassword
113+
```
114+
115+
The example above instructs the SAP BTP to:
116+
117+
- Extend the `com.example.demo.basic` MTA deployment descriptor with the `com.example.demo.basic.config` MTA extension descriptor
118+
- Define the title and description for the target solution that will be visible in the SAP BTP
119+
- Extend the db-binding resource and define within the following parameters:
120+
- Alias of the database
121+
- User for the database schema that you own
122+
- Password for the database schema that you own
123+
124+
125+
At this point of the procedure, the MTA deployment descriptor, MTA extension descriptor, and the Java application `.war` files are compiled. You can now package your Multitarget Application archive and deploy it to the SAP BTP.
126+
127+
The MTA archive contains all entities that have to be deployed. It also contains a manifest file, which links the modules and resources described into the MTA deployment descriptor file using their location in the archive. Using this data, the SAP BTP deploys the Multitarget Application archive as a solution.
128+
129+
130+
131+
132+
### Packaging your Multitarget Application
133+
134+
135+
1. Create an empty text file and name it `MANIFEST.MF`. Explicitly use upper-case letters.
136+
137+
2. Using a text editor, enter the following data in the file:
138+
139+
```
140+
Manifest-Version: 1.0
141+
Created-By: example.com
142+
143+
Name: example.war
144+
Content-Type: application/zip
145+
MTA-Module: example-java-app
146+
```
147+
148+
The example above instructs the SAP BTP to link the module example-java-app to the archive example.war.
149+
150+
>**CAUTION**
151+
>
152+
>Make sure that the `MANIFEST.MF` is compliant to the JAR file specification.
153+
154+
155+
### Create your Multitarget Application archive
156+
157+
158+
MTA archives are compliant to the JAR file specification. This allows you to use commonly available tools for creating, modifying, and signing such archives. For the sake of the tutorial, we assume that you have a root directory named ***/*** where you place all the parts of the Multitarget Application before creating the archive.
159+
160+
1. Create a folder called `META-INF` in the root directory.
161+
2. Place the `mtad.yaml` and the `MANIFEST.MF` files inside the `META-INF` directory.
162+
3. Place the `example.war` archive inside the root directory.
163+
164+
>The MTA extension descriptor file is deployed separately from the MTA archive.
165+
166+
The root directory should now be structured as follows:
167+
168+
```
169+
/example.war
170+
/META-INF
171+
/META-INF/mtad.yaml
172+
/META-INF/MANIFEST.MF
173+
```
174+
175+
4. Archive the content of the root directory in an `.mtar` format using an archiving tool capable of producing a JAR archive.
176+
177+
After you have created your Multitarget Application archive, you are ready to deploy it into the SAP BTP as a solution. To deploy the archive, proceed as described in [Deploy a Standard Solution](https://help.sap.com/docs/BTP/ea72206b834e4ace9cd834feed6c0e09/fea07defe09f44c09e03269705550335.html).
178+
179+
180+
181+
182+
183+
184+
185+
---

0 commit comments

Comments
 (0)