Set up Gradle to use your internal registry
Set up Gradle so that Gradle workspaces can download plugins and dependencies from your internal registry. .Prerequisites
About this task
- You are not running any Gradle workspace.
Procedure
-
Create a Secret to store the TLS certificate:
kind: Secret apiVersion: v1 metadata: name: tls-cer annotations: controller.devfile.io/mount-path: /home/user/certs controller.devfile.io/mount-as: file labels: controller.devfile.io/mount-to-devworkspace: 'true' controller.devfile.io/watch-secret: 'true' data: tls.cer: >- <Base64_encoded_content_of_public_cert>where:
-
<Base64_encoded_content_of_public_cert> - The Base64-encoded content of your Gradle artifact repository’s public TLS certificate, with line wrapping disabled.
-
-
Create a ConfigMap for the TrustStore initialization script:
kind: ConfigMap apiVersion: v1 metadata: name: init-truststore annotations: controller.devfile.io/mount-as: subpath controller.devfile.io/mount-path: /home/user/ labels: controller.devfile.io/mount-to-devworkspace: 'true' controller.devfile.io/watch-configmap: 'true' data: init-truststore.sh: | #!/usr/bin/env bash keytool -importcert -noprompt -file /home/user/certs/tls.cer -cacerts -storepass changeit -
Create a ConfigMap for the Gradle init script:
kind: ConfigMap apiVersion: v1 metadata: name: init-gradle annotations: controller.devfile.io/mount-as: subpath controller.devfile.io/mount-path: /home/user/.gradle labels: controller.devfile.io/mount-to-devworkspace: 'true' controller.devfile.io/watch-configmap: 'true' data: init.gradle: | allprojects { repositories { mavenLocal () maven { url "https://<gradle_artifact_repository_route>/repository/maven-public/" credentials { username "admin" password "passwd" } } } }where:
-
<gradle_artifact_repository_route> - The hostname and path of your internal Gradle artifact repository.
-
-
Apply the Secret and both ConfigMaps to your project:
$ oc apply -f tls-cer.yaml -n <your_namespace> $ oc apply -f init-truststore.yaml -n <your_namespace> $ oc apply -f init-gradle.yaml -n <your_namespace> - Start a Gradle workspace.
-
Open a new terminal in the
toolscontainer. -
Run
~/init-truststore.sh.
Results
- In the workspace terminal, build a Gradle project to verify artifact resolution from the mirror:
$ gradle build