Guidelines relevant for development of the API Mediation Layer in the IntelliJ IDEA.
Be aware that Idea contains
a bug since 2023.1.4.
This bug break reading Gradle model, and it is not possible to load the project correctly. To avoid this issue it is
possible to disable parallel processing by setting org.gradle.parallel to false in the
gradle.properties file.
- Enable Annotations processing if you haven't done so already (Just go to settings and search for 'annotation')
- Install Lombok plugin. Go to the plugins in the setting and look for the lombok plugin.
- Make sure that the Project SDK is set to JDK 17 (IBM Semeru Runtime) and the Language level is also set to 17 (or SDK default)
- Gradle JVM should be set to the Project SDK as well. To set it go to the Settings->Build,Execution,Deployment->Build Tools->Gradle
-
These are the application main classes and their corresponding service names for configuration files:
- ApiCatalogApplication - api-catalog-service
- DiscoverableClientSampleApplication - discoverable-client
- DiscoveryServiceApplication - discovery-service
- SpringEnablerSampleApplication - onboarding-enabler-spring-sample-app
- GatewayApplication - gateway-service
- MockServicesApplication - mock-services
-
There are no configuration files for:
- CachingService
-
If you plan on using the Dummy Authentication Provider open the ./config/local/gateway-service.yml file and update
apiml.security.auth.provider:to have valuedummy
- Go to 'Services', it is available via alt+8 or on the bottom line of the IDEA.
For each of the available services:
- Right click a service and select 'Edit Configuration' (or press Shift + F4 while the service is selected)
- To resolve issues with reflection in Java 9 or later, add following JVM parameters (Alt + E or click on Modify options > VM Options)
--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/javax.net.ssl=ALL-UNNAMED --add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED - Check that there are no set Environment variables (if you do not see the field you can press Alt + E or click on Modify options and select the Environment variables option from the list)
- For the Discovery service add Environment variable
spring.profiles.activeand it's valuehttps
- For the Discovery service add Environment variable
- Then in the 'Override configuration properties' section (Alt + P or select it from the Modify options list again) add a new parameter
spring.config.additional-locationand its valuefile:./config/local/{SERVICE_NAME}.ymlReplace SERVICE_NAME with the above service names. - Check that you are shortening the command line, Modify options -> Java -> Shorten command line and in the new field select JAR manifest.
- Run the service
For each of the available services:
- Run -> Edit configurations...
- Create New (Ctrl + N or Cmd + N) -> Application
- Choose main class (E.g
org.zowe.apiml.gateway.GatewayApplication) - Add Environment variable
spring.config.additional-locationand it's valuefile:./config/local/{SERVICE_NAME}.ymlReplace SERVICE_NAME with respective main class (E.gfile:./config/local/gateway-service.yml)- For the Discovery service add Environment variable
spring.profiles.activeand it's valuehttps
- For the Discovery service add Environment variable
- Run the service Run -> Run... (Alt + Shift + F10 or Ctrl + Option + R)
Repeat the above for the following application main classes and their service names as written above:
- gateway-service
- discovery-service
- mock-services
- api-catalog-services
- discoverable-client
You can use Visual Studio Code to develop and debug.
Follow these steps:
-
Install the Java Extension Pack, Spring Boot Extension Pack and Lombok Annotations Support for VS Code extensions.
The VSCode Java Extension requires Java 11, which would need to be installed alongside with Java 8 (so long as APIML runs on Java 8). The VSCodejava.homesetting would need to point to the Java 11 installation.So long as APIML runs on Java 8, it is required that theJAVA_HOMEenvironment variable points to Java 8 by default. This way, with the above-mentioned VSCode setting, the java extension will work fine with Java 11 while the debugger and the test runner will use Java 8.
-
Run
gradlew eclipseto generate the build information. -
Add the following definitions to the
launch.jsonfile in the workspace:{ "type": "java", "name": "Debug (Attach)-ApiCatalogApplication<api-catalog-services>", "request": "attach", "hostName": "localhost", "port": 5014, "projectName": "api-catalog-services" }, { "type": "java", "name": "Debug (Attach)-GatewayApplication<gateway-service>", "request": "attach", "hostName": "localhost", "port": 5010, "projectName": "gateway-service" } -
Launch either of the services in debug mode (see
package.jsonfor launch scripts in debug mode). Then attach the debugger by running the appropriate launch configuration. -
To debug unit tests, use the shortcuts that are created by the Java Test Runner extension.
Example to launch Gateway application in launch.json:
{
"type": "java",
"name": "Launch GatewayApplication",
"request": "launch",
"mainClass": "org.zowe.apiml.gateway.GatewayApplication",
"projectName": "gateway-service",
"vmArgs": [
"-Dspring.config.additional-location=file:../config/local/gateway-service.yml",
"-Dspring.profiles.active=https"
],
"args": [
"--apiml.security.ssl.verifySslCertificatesOfServices=true",
"--server.ssl.keyStore=../keystore/localhost/localhost.keystore.p12",
"--server.ssl.trustStore=../keystore/localhost/localhost.truststore.p12",
"--server.internal.ssl.keyStore=../keystore/localhost/localhost-multi.keystore.p12",
"--apiml.security.auth.provider=dummy"
]
}