Featured image: IntelliJ and CodeReady Workspaces

Red Hat CodeReady Workspaces (CRW) provides a default browser-based IDE to be used with developer workspaces. However, the architecture is flexible for using other IDEs such as Jupyter Notebooks and Eclipse Dirigible. In this article, you will learn how to create a custom workspace using the community edition of IntelliJ IDEA.

Note: You can also apply the instructions in this article to create a free, self-service Eclipse Che workspace hosted at che.openshift.io.

Creating a custom workspace in CodeReady Workspaces

We will start with the procedure for creating a custom workspace in a connected CodeReady Workspaces environment. See the next section for instructions to set up a custom workspace in an air-gapped environment.

Step 1: Add a custom IntelliJ IDEA workspace

Our first step is to install IntelliJ IDEA from a devfile:

  1. Open CodeReady Workspaces and select Workspaces from the top-left corner of the dashboard.
  2. Click Add Workspace.
  3. Select the Custom Workspace tab if it is not already selected.
  4. Enter the URL of the CRW 2.5 IntelliJ devfile:
    https://raw.githubusercontent.com/redhat-developer/codeready-workspaces/crw-2.5-rhel-8/dependencies/che-editor-intellij-community/devfiles/workspace.yaml.
  5. Click Load devfile.

Figure 1 shows the dialog to add a workspace and load the CRW 2.5 IntelliJ devfile.

Screenshot of Create a Custom Workspace after loading a Devfile
Figure 1: Add a workspace and load the IntelliJ devfile.

Step 2: Create and open the workspace

Scroll down and click Create & Open. After the workspace loads, you will be prompted to accept the license terms for IntelliJ's community edition. After accepting the terms, you will see the Welcome to IntelliJ IDEA window shown in Figure 2.

Welcome screen for IntelliJ
Figure 2 - Welcome to IntelliJ IDEA
Figure 2 - Welcome to IntelliJ IDEA

From here, click Get from Version Control and enter a CodeReady Workspaces project URL. The URL for our example is https://github.com/redhat-developer/codeready-workspaces. You can use the noVNC clipboard to paste the URL from your computer into the IntelliJ dialog, as shown in Figure 3.

Shows the noVNC clipboard which allows you to copy and paste content such as a git repository URL
Figure 3 - Using the noVNC clipboard
Figure 3: Using the noVNC clipboard to copy and paste the CodeReady Workspaces project URL.

Next, click Clone and wait for the project to load. Once it has loaded, you can open a project file and start coding in IntelliJ IDEA.

Additional tips

If you accidentally minimize a window and can’t get it back, see this tip for using the Fluxbox content menu to enable the toolbar. Once the toolbar is enabled, you will be able to find the window again.

If the noVNC interface uses a different language from your primary setting, you likely need to configure your browser’s language settings.

Creating a custom workspace in an air-gapped environment

Creating a custom workspace in an air-gapped environment requires a different approach and a few more steps than the connected environment.

Step 1: Build a custom plug-in registry image

To start, make sure that you've mirrored the image quay.io/crw/plugin-intellij-rhel8:2.5 to your internal registry. Next, you will build a custom plug-in registry image that includes IntelliJ:

  1. Clone the Git repository that has the CRW 2.5 plug-in definitions:
    git clone -b crw-2.5-rhel-8 https://github.com/redhat-developer/codeready-workspaces.git
    cd codeready-workspaces/dependencies/che-plugin-registry
    
  2. Create a new folder that contains the IntelliJ editor definition:
    mkdir -p v3/plugins/idea/intellij-community/2020.2.2/
    
  3. Create the meta.yaml file that contains the IntelliJ editor definition:
    echo 'apiVersion: v2
    publisher: idea
    name: intellij-community
    version: 2020.2.2
    type: Che Editor
    displayName:  IntelliJ IDEA Community Edition
    title:  IntelliJ IDEA Community Edition (in browser using noVNC) as editor for Eclipse Che
    description:  IntelliJ IDEA Community Edition running on the Web with noVNC
    icon: https://resources.jetbrains.com/storage/products/intellij-idea/img/meta/intellij-idea_logo_300x300.png
    category: Editor
    repository: https://github.com/che-incubator/jetbrains-editor-images
    firstPublicationDate: "2020-09-25"
    spec:
      endpoints:
      - name: "intellij"
        public: true
        targetPort: 8080
        attributes:
          protocol: http
          type: ide
          discoverable: false
          path: /vnc.html?resize=remote&autoconnect=true&reconnect=true
    containers:
    - name: ideaic-novnc
      image: "quay.io/crw/plugin-intellij-rhel8:2.5"
      mountSources: true
      volumes:
      - mountPath: "/JetBrains/IdeaIC"
        name: idea-configuration
      ports:
      - exposedPort: 8080
      memoryLimit: "2048M"' > v3/plugins/idea/intellij-community/2020.2.2/meta.yaml
  4. Specify that the latest version is 2020.2.2:
    echo "2020.2.2" > v3/plugins/idea/intellij-community/latest.txt
    
  5. Patch the Dockerfile:
    echo '--- a/dependencies/che-plugin-registry/build/dockerfiles/Dockerfile
    +++ b/dependencies/che-plugin-registry/build/dockerfiles/Dockerfile
    @@ -12,7 +12,7 @@
     
    # Builder: check meta.yamls and create index.json
    FROM docker.io/alpine:3.11.5 AS builder
    -RUN apk add --no-cache py-pip jq bash wget skopeo && pip install yq jsonschema
    +RUN apk add --no-cache py3-pip jq bash wget skopeo && pip3 install yq jsonschema
     
    ARG LATEST_ONLY=false
    ARG USE_DIGESTS=false' | patch build/dockerfiles/Dockerfile
    
  6. Build and publish the new plug-in registry image that includes the IntelliJ editor:
    REGISTRY_URL=quay.io
    REGISTRY_ORG=crw
    REGISTRY_IMAGE_TAG=crw-2.5-rhel-8-intellij
    ./build.sh --organization ${REGISTRY_ORG} \
    --registry ${REGISTRY_URL} \
    --tag ${REGISTRY_IMAGE_TAG}
    docker push ${REGISTRY_URL}/${REGISTRY_ORG}/che-plugin-registry:${REGISTRY_IMAGE_TAG}
    
  7. Update the CRW configuration to use the new image for the plug-in registry:
    CRW_NAMESPACE=workspaces
    oc patch checluster codeready-workspaces -n ${CRW_NAMESPACE} \
    --type=merge -p \
    '{"spec":{"server": {"pluginRegistryImage": "'${REGISTRY_URL}'/'${REGISTRY_ORG}'/che-plugin-registry:'${REGISTRY_IMAGE_TAG}'"}}}'
    

Once the CheCluster custom resource (CR) is patched, the plug-in registry pod will be updated with the new image.

Step 2: Create the IntelliJ workspace

Next, you'll create the custom workspace in CodeReady Workspaces:

  1. Open CodeReady Workspaces and select Get Started from the top-left corner of the CRW dashboard.
  2. Select the Custom Workspace tab if it is not already selected.
  3. Copy and paste the following into the devfile text area:
    apiVersion: 1.0.0
    metadata:
    generateName: che-ideaic
    components:
    - type: cheEditor
      id: idea/intellij-community/2020.2.2
    
  4. Click Load devfile.
  5. Scroll down and click Create & Open.

Conclusion

This article showed you how to create a custom workspace with IntelliJ IDEA in CodeReady Workspaces 2.5. We started with the installation and setup for a connected environment, then presented an air-gapped installation. We hope the instructions are helpful. Please let us know in the comments if you have questions or feedback.

Check out the CodeReady Workspaces product page on Red Hat Developer for the latest news and tutorials.

Acknowledgment

Special thanks to Nick Boldt for his help with this article.

Last updated: November 8, 2023