With IBM Business Automation Manager Open Editions v9.1 aligning with its previous version BAMOE v8 in the downstream build model, the artifacts are no longer available in Maven Central. The artifacts are shipped as part of the product as a Container Image and Maven Repository inside the compressed file in a consumable format.

If you have a Maven Repository Manager tool like Artifactory or Nexus, you can import the compressed BAMOE Maven repository content into Maven Repository Manager. For companies without such infrastructure, it is highly recommended to use the container image and make it available within the company for all developers and the continuous integration (CI) system. For companies that already use a Maven Repository Manager tool, developers and the CI system are typically configured to connect with it. If you are using the container image, ensure that it is made available and provide the URL that developers and the CI system need to specify in their settings.xml file.

Note
When you configure the repository by modifying the Maven settings.xml file, the changes apply to all of your Maven projects.

There are two ways to do this:

  • Set up a maven repository with a container image

  • Configure your local maven repository

Configuring Maven with the container image

Before changing your Maven settings you must first deploy/run the container image somewhere. There are a few options and your choice will depend on your work environment and the tools that are available to you.

Deploying to OpenShift

Choose between using the

  • bamoe-9.1.0-maven-repository-image.tar.gz

  • quay.io/bamoe/maven-repository:9.1.0-ibm-0001

Caution

The provided container images are created for Linux execution, running on a different architecture beside Linux x86_64 architecture, there may be a warning similar to: "WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (…​) and no specific platform was requested"

Using bamoe-9.1.0-maven-repository-image.tar.gz

Enable the OpenShift registry and log into it using Docker:

oc patch configs.imageregistry.operator.openshift.io/cluster --patch '{"spec":{"defaultRoute":true}}' --type=merge
export REGISTRY=`oc get route default-route -n openshift-image-registry --template='{{ .spec.host }}'`
docker login -u `oc whoami` -p `oc whoami --show-token` ${REGISTRY}

Import the image from the .tar.gz file, re-tag it, and push it to the OpenShift registry

docker image load --input bamoe-9.1.0-maven-repository-image.tar.gz
docker tag quay.io/bamoe/maven-repository:9.1.0-ibm-0001 ${REGISTRY}/<PROJECT_NAME>/maven-repository:9.1.0-ibm-0001
docker push ${REGISTRY}/<PROJECT_NAME>/maven-repository:9.1.0-ibm-0001
# Replace <PROJECT_NAME> with your OpenShift Project (namespace)

Set an env var with the image name

export BAMOE_MAVEN_REPOSITORY_IMAGE=maven-repository:9.1.0-ibm-0001

Using quay.io/bamoe/maven-repository:9.1.0-ibm-0001

In this case, not much needs to be done, just set an env var with the image URL

export BAMOE_MAVEN_REPOSITORY_IMAGE=quay.io/bamoe/maven-repository:9.1.0-ibm-0001

Create a new Service Account and add anyuid permissions. This is important because we’ll need to run a container on port 80, which usually OpenShift blocks with the default Service Account:

oc create sa maven-repo-root-user
oc adm policy add-scc-to-user anyuid -z maven-repo-root-user
Note
If you can’t create a Service Account with elevated privileges, learn how to build your own bamoe-maven-repository image using a different port.

Create the Deployment, Service, and Route

oc new-app ${BAMOE_MAVEN_REPOSITORY_IMAGE} --name bamoe-maven-repo
oc patch deployment/bamoe-maven-repo --type=json \
  -p='[{"op":"add", "path": "/spec/template/spec/securityContext", "value": { "runAsUser": 0 } }, {"op":"add", "path": "/spec/template/spec/serviceAccountName", "value": "maven-repo-root-user" }, {"op":"add", "path": "/spec/template/spec/serviceAccount", "value": "maven-repo-root-user" }]'
oc create route edge --service=bamoe-maven-repo

Get the Maven repository URL to be used in the next steps:

oc get route bamoe-maven-repo --output jsonpath={.spec.host}

Deploying to a Kubernetes cluster

Choose between using

  • bamoe-9.1.0-maven-repository-image.tar.gz

  • the hosted quay.io/bamoe/maven-repository:9.1.0-ibm-0001 image

Using bamoe-9.1.0-maven-repository-image.tar.gz

This step varies depending on your cluster configuration, but it may involve setting up (or using an already set up) image registry, loading and re-tagging the docker image, and then pushing it to the registry with the new tag.

docker image load --input bamoe-9.1.0-maven-repository-image.tar.gz
docker tag quay.io/bamoe/maven-repository:9.1.0-ibm-0001 <REGISTRY_URL>/<NAMESPACE>/maven-repository:9.1.0-ibm-0001
docker push <REGISTRY_URL>/<NAMESPACE>/maven-repository:9.1.0-ibm-0001
Note
If you’re using a local Kubernetes cluster with Minikube or Kind you can skip the re-tagging and pushing and follow these commands: for Minikube, run minikube image load quay.io/bamoe/maven-repository:9.1.0-ibm-0001; for Kind, run kind load docker-image quay.io/bamoe/maven-repository:9.1.0-ibm-0001.

Set an env var with the image name

export BAMOE_MAVEN_REPOSITORY_IMAGE=maven-repository:9.1.0-ibm-0001
# For Kind and Minikube use the original quay.io URL for this variable

Using quay.io/bamoe/maven-repository:9.1.0-ibm-0001

In this case, not much needs to be done, just set an env var with the image URL

export BAMOE_MAVEN_REPOSITORY_IMAGE=quay.io/bamoe/maven-repository:9.1.0-ibm-0001

Create and/or use a Service Account elevated privileges:

Since our image runs on port 80, some clusters may require you to run the container as root. To do so, make sure you create and use a Service Account that can create Deployments/Pods that run as user 0 (root).

For the following steps, wherever you see <SERVICE_ACCOUNT_NAME>` replace it with the Service Account created in this step.

Create the Deployment, Service, and Ingress

kubectl create deployment bamoe-maven-repo --image=${BAMOE_MAVEN_REPOSITORY_IMAGE}
kubectl patch deployment bamoe-maven-repo --type=json \
  -p='[{"op":"add", "path": "/spec/template/spec/securityContext", "value": { "runAsUser": 0 } }, {"op":"add", "path": "/spec/template/spec/serviceAccountName", "value": "<SERVICE_ACCOUNT_NAME>" }, {"op":"add", "path": "/spec/template/spec/serviceAccount", "value": "<SERVICE_ACCOUNT_NAME>" }]'
kubectl expose deployment bamoe-maven-repo --port=80 --target-port=80
kubectl create ingress bamoe-maven-repo --rule="<EXTERNAL_BAMOE_MAVEN_REPO_URL>/*=bamoe-maven-repo:80"
# Replace <EXTERNAL_BAMOE_MAVEN_REPO_URL> with whatever URL is mapped to your cluster.
# For Kind or Minikube you could use something like bamoe-maven-repo.localhost, and then map this hostname to the cluster IP on your /etc/hosts file.

Running on Docker locally

Start of by loading the .tar.gz file or pulling the image from quay.io:

  • bamoe-9.1.0-maven-repository-image.tar.gz

    docker image load --input bamoe-9.1.0-maven-repository-image.tar.gz
  • quay.io/bamoe/maven-repository:9.1.0-ibm-0001

    docker pull quay.io/bamoe/maven-repository:9.1.0-ibm-0001

    Run the image mapping it’s port:

    docker run -d -p <PORT>:80 quay.io/bamoe/maven-repository:9.1.0-ibm-0001
    # Replace <PORT> with whatever port you want the container to be mapped to on your host.

You can verify the repository is running by accessing the repository in your browser at http://localhost/com/ibm/bamoe.

Configure Maven with the container image URL:

To configure Maven with a container image follow these steps:

  1. Download the dedicated M2 repository image container (bamoe-9.1.0-maven-repository-image.tar.gz).

  2. Open the Maven ~/.m2/settings.xml file in a text editor or integrated development environment (IDE).

    Note
    If there is no settings.xml file in the ~/.m2/ directory, copy the settings.xml file from the $MAVEN_HOME/.m2/conf/ directory into the ~/.m2/ directory.
  3. Add the following lines to the <profiles> element of the settings.xml file:

    <profile>
      <id>ibm-bamoe-enterprise-maven-repository</id>
      <repositories>
        <repository>
          <id>ibm-bamoe-enterprise-maven-repository</id>
          <url>https://container-URL-here</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>ibm-bamoe-enterprise-maven-repository</id>
          <url>https://container-URL-here/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  4. Add the following lines to the <activeProfiles> element of the settings.xml file and save the file:

<activeProfile>ibm-bamoe-enterprise-maven-repository</activeProfile>

Configuring a local Maven repository for BAMOE

If you prefer not to use containers, you can download and configure the BAMOE Maven repository from the compressed file. The BAMOE Maven repository contains the libraries that Java developers need to build BAMOE applications.

To configure the BAMOE Maven repository locally follow these steps:

  1. Download the BAMOE v9.1.0 Maven Repository (bamoe-9.1.0-maven-repository.zip).

  2. Extract the downloaded archive.

  3. Go to the ~/.m2/ directory and open the Maven settings.xml file in a text editor or IDE.

  4. Add the following lines to the <profiles> element of the Maven settings.xml file, where <MAVEN_REPOSITORY> is the path of the Maven repository that you downloaded. The format of <MAVEN_REPOSITORY> must be file://$PATH. For example, file:///home/userX/bamoe-9.1.0-maven-repository/:.

    <profile>
      <id>ibm-bamoe-enterprise-maven-repository</id>
      <repositories>
        <repository>
          <id>ibm-bamoe-enterprise-maven-repository</id>
          <url><MAVEN_REPOSITORY></url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>ibm-bamoe-enterprise-maven-repository</id>
          <url><MAVEN_REPOSITORY></url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  5. Add the following lines to the <activeProfiles> element of the Maven settings.xml file and save the file:

<activeProfile>ibm-bamoe-enterprise-maven-repository</activeProfile>

If your Maven repository contains outdated artifacts, you might encounter Maven error messages when you build or deploy the project, such as:

  • Missing artifact <PROJECT_NAME>

  • [ERROR] Failed to execute goal on project <ARTIFACT_NAME>; Could not resolve dependencies for <PROJECT_NAME>

To resolve these issues, delete the cached version of your local repository that is located in the ~/.m2/repository directory to force a download of the latest Maven artifacts.

Your Maven repository is now properly configured and ready to build BAMOE based projects using a standard Maven workflow.