@qshift/quarkus-plugins

May 3, 2024 ยท View on GitHub

This project contains different Backstage plugins to work with Quarkus which is a Kubernetes-native Java framework tailored for GraalVM and HotSpot, crafted from best-of-breed Java libraries and standards.

Prerequisites

Getting started

To play with one of our plugins, create first a Backstage application locally using this command:

npx @backstage/create-app@latest

Next, verify if the newly application created is working fine: yarn dev

If this is the case, you can start to play with one or all our plugins :-)

Quarkus Console

Before to use the quarkus console, it is needed to install and configure the kubernetes plugin as documented.

Import first the following package within an existing backstage application:

yarn add --cwd packages/app "@qshift/plugin-quarkus-console"

Next, customize the packages/app/src/components/catalog/EntityPage.tsx to include a new <EntityLayout.Route...>:

import {
    QuarkusPage,
} from "@qshift/plugin-quarkus-console";
...
const serviceEntityPage = (
  <EntityLayout>
  ...
    <EntityLayout.Route path="/quarkus" title="Quarkus">
      <QuarkusPage />
    </EntityLayout.Route>

Start backstage, register a quarkus component including the following annotations

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: my-quarkus-app
  description: A cool quarkus app
  annotations:
    app.kubernetes.io/name: quarkus
    app.quarkus.io/quarkus-version: "3.9"

and open the Quarkus view using the software catalog.

Scaffold template fields

This plugin proposes different UI fields to be used part of a template scaffolded by backstage:

NameDescription
QuarkusExtensionListFilter, select your Quarkus extensions using the Quarkus Extension List field.
QuarkusQuickstartPickerSelect using the Quarkus QuickStart Picker one of the quickstarts available: https://github.com/quarkusio/quarkus-quickstarts
QuarkusVersionListList the recommended and available versions of Quarkus

NOTE: Such frontend feature(s) should be used with the quarkus scaffolder backend plugin !

To use them, import the needed package under the following path within an existing backstage application:

yarn add --cwd packages/app "@qshift/plugin-quarkus"

Next, customize the packages/app/src/App.tsx file according to the field that you plan to use and described hereafter

Local development

When you develop a new <ScaffolderFieldExtensions/>, then we recommend to launch the plugin locally using the createDevApp of the ./dev/index.tsx file for testing/debugging purposes.

To play with it, open a terminal and run the command: yarn start within the ./plugins/quarkus folder

NOTE: Don't forget to open a second terminal and to launch the backend or backend-next there, using yarn start and to specify the locations of the templates to play with !

If your IDE supports to debug an application that is running on the localhost in the development mode like IntelliJ, then use the commands "Command + Shift" and click on the url: http://localhost:3000, next add a breakpoint within your tsx file

local-debug.png

Quarkus extensions field

This field allows a user to pick up Quarkus extension(s) from the code generator server.

Edit the packages/app/src/App.tsx file to add the tag of the <QuarkusExtensionListField /> within the tag <Route path="/create" element={<ScaffolderPage />}> as described hereafter.

...
import { ScaffolderFieldExtensions } from '@backstage/plugin-scaffolder-react';
import { QuarkusExtensionListField } from '@qshift/plugin-quarkus';
...
    <Route path="/create" element={<ScaffolderPage />}>
      <ScaffolderFieldExtensions>
        <QuarkusExtensionListField />
      </ScaffolderFieldExtensions>
...

Update your template file to use extension field:

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: quarkus-application
  title: Create a Quarkus Application
  description: Create a Quarkus application using code generator "code.quarkus.io"
  tags:
    - quarkus
    - java
spec:
  owner: guests
  type: service

  parameters:
  ...
  - title: Customize the Quarkus application features
    properties:
      extensions:
        title: Quarkus Extensions
        type: array
        description: The list of the quarkus extensions
        ui:field: QuarkusExtensionList
  steps:
  ...

When done, you will be able to select your extension(s) when you scaffold a new project.

It is also possible to filter the extensions (aka restrict the list of the extensions to be used):

    ui:field: QuarkusExtensionList
    ui:options:
      filter:
        extensions:
          - io.quarkus:quarkus-resteasy-reactive-jackson
          - io.quarkus:quarkus-smallrye-openapi
          - io.quarkus:quarkus-smallrye-graphql
          - io.quarkus:quarkus-hibernate-orm-rest-data-panache

If you would like to use a different code generator server, set the following property

    ui:field: QuarkusExtensionList
    ui:options:
        codeQuarkusUrl: https://staging.code.quarkus.io

Quarkus Extension List - default (field): extensions-1.png

Quarkus Extension List - Select (field): extensions-2.png

Quarkus Extension List - Added (field): extensions-3.png

Quarkus Quickstart picker field

This field allows a user to pick up a Quarkus Quickstart project.

Edit the packages/app/src/App.tsx file to add the tag of the <QuarkusQuickstartPickerField /> within the <Route path="/create" element={<ScaffolderPage />}> as described hereafter.

...
import { ScaffolderFieldExtensions } from '@backstage/plugin-scaffolder-react';
import { QuarkusQuickstartPickerField } from '@qshift/plugin-quarkus';
...
    <Route path="/create" element={<ScaffolderPage />}>
      <ScaffolderFieldExtensions>
        <QuarkusQuickstartPickerField />
      </ScaffolderFieldExtensions>
...

Update your template file to use extension field:

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: quarkus-quickstart
  title: Create a Quarkus Application from a Quickstart
  description: Create a Quarkus Application from one of the Quickstarts you can find on "https://github.com/quarkusio/quarkus-quickstarts"
  tags:
    - quarkus
    - java
spec:
  owner: guests
  type: service

  parameters:
  ...
  - title: Select the Quarkus Quickstart
    properties:
      quickstartName:
        title: Quickstart Name
        type: string
        description: The name of the quickstart to clone
        default: 'hibernate-orm-panache'
        ui:field: QuarkusQuickstartPicker
  steps:
  ...

When done, you will be able to create a new Quarkus project from the quickstart selected.

Quarkus Quickstart Picker - default (field): quickstart-1.png

Quarkus Quickstart Picker - select (field): quickstart-2.png

Quarkus Version list field

This field allows a user to select a Quarkus version from the list of the recommended and available version.

Edit the packages/app/src/App.tsx file to add the tag of the <QuarkusQuickstartPickerField /> within the <Route path="/create" element={<ScaffolderPage />}> as described hereafter.

...
import { ScaffolderFieldExtensions } from '@backstage/plugin-scaffolder-react';
import { QuarkusVersionListField } from '@qshift/plugin-quarkus';
...
    <Route path="/create" element={<ScaffolderPage />}>
      <ScaffolderFieldExtensions>
        <QuarkusQuickstartPickerField />
      </ScaffolderFieldExtensions>
...

Update your template file to use extension field:

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: quarkus-application
  title: Create a Quarkus Application
  description: Create a Quarkus application using code generator "code.quarkus.io"
  tags:
    - quarkus
    - java
spec:
  owner: guests
  type: service

  parameters:
  ...
  - title: Customize the Quarkus application features
    properties:
      quarkusVersion:
      title: Quarkus version
      type: array
      description: The list of the quarkus supported/recommended
      ui:field: QuarkusVersionList
      
  steps:
  ...

When done, you will be able to select the quarkus version to be used to scaffold your quarkus project

Quarkus Version list - Select (field): version-list.png

Quarkus Version list - Recommended (field): version-recommended.png

Quarkus actions

This plugin proposes 2 actions able to:

ActionDescription
quarkus:app:createCreate a Quarkus using the website code.quarkus.io able to generate a zip file of a Quarkus project and extensions selected (using extension list field)
quarkus:quickstart:cloneClone a Quarkus "Quickstart" repository.

To use this plugin, import the following packages under the following path:

yarn add --cwd packages/backend "@qshift/plugin-quarkus-backend"
yarn add --cwd packages/backend "@backstage/integration"

quickstart:clone

To use the Quarkus action able to clone a quarkus quickstart from this repository, then edit the file packages/backend/src/plugins/scaffolder.ts to register the action: cloneQuarkusQuickstart.

Here is a snippet example of code changed

import { ScmIntegrations } from '@backstage/integration';
import {createBuiltinActions, createRouter} from '@backstage/plugin-scaffolder-backend';
import { cloneQuarkusQuickstart } from '@internal/plugin-quarkus-backend';
...
  const integrations = ScmIntegrations.fromConfig(env.config);

  const builtInActions = createBuiltinActions({
    integrations,
    catalogClient,
    config: env.config,
    reader: env.reader,
  });

  const actions = [...builtInActions, cloneQuarkusQuickstart()];

  return await createRouter({
    actions,

The following table details the fields that you can use to use this action:

InputDescriptionTypeRequired
quickstartNameThe name of the quickstart project to be usedstringYes
groupIdMaven GroupIDNo
artifactIdMaven ArtifactIDNo
targetPathTarget Path to access the code within the workspaceNo
additionalPropertiesQuarkus propertiesNo
databaseQuarkus backend database (PostgreSQL, etc)No
infoEndpointQuarkus API endpointNo
healthEndpointKubernetes Health ednpointNo
metricsEndpointEnpoint exposing the Quarkus metricsNo

Example of action:

  steps:
    - id: template
      name: Generating the Source Code Component
      action: quarkus:quickstart:clone
      input:
        values:
          groupId: ${{ parameters.groupId }}
          artifactId: ${{ parameters.artifactId }}
          version: ${{ parameters.version }}
          quickstartName: ${{ parameters.quickstartName }}
          additionalProperties: ${{ parameters.additionalProperties }}

app:create

To use the Quarkus action able to create a quarkus application using code.quarkus.io, then edit the file packages/backend/src/plugins/scaffolder.ts to register the action: createQuarkusApp.

Here is a snippet example of code changed

import { ScmIntegrations } from '@backstage/integration';
import {createBuiltinActions, createRouter} from '@backstage/plugin-scaffolder-backend';
import { createQuarkusApp } from '@internal/plugin-quarkus-backend';
...
  const integrations = ScmIntegrations.fromConfig(env.config);

  const builtInActions = createBuiltinActions({
    integrations,
    catalogClient,
    config: env.config,
    reader: env.reader,
  });

  const actions = [...builtInActions, createQuarkusApp()];

  return await createRouter({
    actions,

The following table details the fields that you can use to use this action:

InputDescriptionTypeRequired
quarkusVersionQuarkus versionstringNo
groupIdMaven GroupIDstringNo
artifactIdMaven ArtifactIDstringNo
versionMaven VersionstringNo
buildToolTool to be used to build: 'MAVEN', 'GRADLE', 'GRADLE_KOTLIN_DSL'stringNo
extensionsList of the Quarkus extensionsarrayNo
javaVersionJDK versionstringNo
starterCodeGenerate for the project some code to start ?booleanNo
targetPathTarget Path to access the code within the workspacestringNo
additionalPropertiesQuarkus propertiesstringNo
databaseQuarkus backend database (PostgreSQL, etc)stringNo
infoEndpointHas a Quarkus API endpoint ?booleanNo
healthEndpointHas a Kubernetes Health endpoint ?booleanNo
metricsEndpointHas a Quarkus metrics endpoint ?booleanNo

Example of action:

  steps:
    - id: template
      name: Generating the Source Code Component
      action: quarkus:app:create
      input:
        values:
          quarkusVersion: ${{ parameters.quarkusVersion[0] }}
          groupId: ${{ parameters.groupId }}
          artifactId: ${{ parameters.artifactId }}
          version: ${{ parameters.version }}
          buildTool: ${{ parameters.buildTool }}
          javaVersion: ${{ parameters.javaVersion }}
          extensions: ${{ parameters.extensions }}
          database: ${{ parameters.database }}
          infoEndpoint: ${{ parameters.infoEndpoint }}
          healthEndpoint: ${{ parameters.healthEndpoint }}
          metricsEndpoint: ${{ parameters.metricsEndpoint }}
          additionalProperties: ${{ parameters.additionalProperties }}
          starterCode: true