ARTIFACTORY: How to proxy a private Google Artifact Maven Registry
This article provides a step-by-step guide on how to proxy a private Google Artifact Maven Registry using Artifactory. By configuring a remote repository in Artifactory, users can seamlessly access and manage their Maven Artifacts stored in the Artifact Registry.
Step 1Create a Maven Remote repository that points to the URL of the repository to point to the respective region's Artifact Registry endpoint.
The endpoint URLs typically follow the format "https://<region>-maven.pkg.dev/<Project-Name>/<Repository_Name>/,"
where the region corresponds to the location where the Maven registry is created. (e.g., "https://asia-south1-maven.pkg.dev/test-project/maven-repo/").
Step 2Configuring Service Account Permissions
In the GCP UI, navigate to IAM & Admin → Service Accounts. Select the relevant service account and go to the "Keys" tab. Ensure that the chosen service account has the necessary permissions.
Click on "ADD KEY," then select "Create a new key" and choose the JSON format. Save the downloaded JSON file in a convenient location for future use.
Step 3Authenticating the Maven Remote Repository
Authenticate the Maven remote repository in Artifactory using the previously downloaded JSON file. Use the following credentials:
Username: _json_key
Password: <service account key JSON> (copy the contents of the JSON file and paste it as the password)
Please note that during the Test connection for this remote URL, Artifactory throws a 404 error, which is expected behavior. However, you will still be able to resolve artifacts from this remote URL without any issues despite this error.
Step 4Resolving Maven Artifacts from Artifact Registry
Next, Add the following Remote repository to the virtual repository.
Next via Set Me UP generate a settings.xml file and save the settings.xml under .m2.
Next, add the dependencies to resolve from the registry in the POM.XML file and resolve the packages.
#mvn install [INFO] Scanning for projects... [INFO] [INFO] ------------< com.javatpoint.application2:my-application2 >------------- [INFO] Building Maven Quick Start Archetype 1.1 [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- Downloading from central: https://<Artifactory_URL>/artifactory/google-libs-release/org/apache/maven/plugins/maven-resources-plugin/3.3.1/maven-resources-plugin-3.3.1.pom Downloaded from central: https://<Artifactory_URL>/artifactory/google-libs-release/org/apache/maven/plugins/maven-resources-plugin/3.3.1/maven-resources-plugin-3.3.1.pom (8.2 kB at 5.6 kB/s) ……… ………… ………… Downloading from central: https://<Artifactory_URL>/artifactory/google-libs-release/com/javatpoint/application1/my-application1/1.0/my-application1-1.0.pom Downloaded from central: https://<Artifactory_URL>/artifactory/google-libs-release/com/javatpoint/application1/my-application1/1.0/my-application1-1.0.pom (1.8 kB at 227 B/s) Downloading from central: https://<Artifactory_URL>/artifactory/google-libs-release/com/javatpoint/application1/my-application1/1.0/my-application1-1.0.jar Downloaded from central: https://<Artifactory_URL>/artifactory/google-libs-release/com/javatpoint/application1/my-application1/1.0/my-application1-1.0.jar (1.9 kB at 219 B/s) [INFO] ……… ………… ………… INFO] Installing /Users/srigokuls/googltest/pom.xml to /Users/srigokuls/.m2/repository/com/javatpoint/application2/my-application2/1.1/my-application2-1.1.pom [INFO] Installing /Users/srigokuls/googletest/target/my-application2-1.1.jar to /Users/srigokuls/.m2/repository/com/javatpoint/application2/my-application2/1.1/my-application2-1.1.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:03 min [INFO] Finished at: 2024-06-29T16:21:42+05:30 [INFO] ------------------------------------------------------------------------