Skip to content

Latest commit

 

History

History
140 lines (113 loc) · 7.19 KB

ide-setup.md

File metadata and controls

140 lines (113 loc) · 7.19 KB

IDE Setup

IntelliJ Idea setup

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.

Code Development

  • 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

Running of the services

  • These are the application main classes and their corresponding service names for configuration files:

    1. ApiCatalogApplication - api-catalog-service
    2. DiscoverableClientSampleApplication - discoverable-client
    3. DiscoveryServiceApplication - discovery-service
    4. SpringEnablerSampleApplication - onboarding-enabler-spring-sample-app
    5. GatewayApplication - gateway-service
    6. MockServicesApplication - mock-services
  • There are no configuration files for:

    1. 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 value dummy

If using IDEA Ultimate Edition 2023

  • Go to 'Services', it is available via alt+8 or on the bottom line of the IDEA.

For each of the available services:

  1. Right click a service and select 'Edit Configuration' (or press Shift + F4 while the service is selected)
  2. 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
    
  3. 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.active and it's value https
  4. 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-location and its value file:./config/local/{SERVICE_NAME}.yml Replace SERVICE_NAME with the above service names.
  5. Check that you are shortening the command line, Modify options -> Java -> Shorten command line and in the new field select JAR manifest.
  6. Run the service

If using IDEA Community Edition

For each of the available services:

  1. Run -> Edit configurations...
  2. Create New (Ctrl + N or Cmd + N) -> Application
  3. Choose main class (E.g org.zowe.apiml.gateway.GatewayApplication)
  4. Add Environment variable spring.config.additional-location and it's value file:./config/local/{SERVICE_NAME}.yml Replace SERVICE_NAME with respective main class (E.g file:./config/local/gateway-service.yml)
    • For the Discovery service add Environment variable spring.profiles.active and it's value https
  5. 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

Visual Studio Code setup

You can use Visual Studio Code to develop and debug.

Follow these steps:

  1. 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 VSCode java.home setting would need to point to the Java 11 installation.
    • So long as APIML runs on Java 8, it is required that the JAVA_HOME environment 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.
  2. Run gradlew eclipse to generate the build information.

  3. Add the following definitions to the launch.json file 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"
    }
  4. Launch either of the services in debug mode (see package.json for launch scripts in debug mode). Then attach the debugger by running the appropriate launch configuration.

  5. 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"
    ]
}