{"id":20020668,"url":"https://github.com/netcentric/maven-ext-repos-from-env","last_synced_at":"2026-06-09T11:31:21.689Z","repository":{"id":48639575,"uuid":"282913556","full_name":"Netcentric/maven-ext-repos-from-env","owner":"Netcentric","description":"Allows to auto-configure maven repositories from system environment","archived":false,"fork":false,"pushed_at":"2024-04-26T11:39:58.000Z","size":107,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2025-01-12T16:12:41.037Z","etag":null,"topics":["adobe-experience-manager","aem","cloud-manager"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Netcentric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-27T13:56:13.000Z","updated_at":"2024-12-09T19:55:00.000Z","dependencies_parsed_at":"2024-04-26T12:50:36.884Z","dependency_job_id":null,"html_url":"https://github.com/Netcentric/maven-ext-repos-from-env","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fmaven-ext-repos-from-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fmaven-ext-repos-from-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fmaven-ext-repos-from-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fmaven-ext-repos-from-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Netcentric","download_url":"https://codeload.github.com/Netcentric/maven-ext-repos-from-env/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241454527,"owners_count":19965405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adobe-experience-manager","aem","cloud-manager"],"created_at":"2024-11-13T08:33:35.829Z","updated_at":"2026-06-09T11:31:21.677Z","avatar_url":"https://github.com/Netcentric.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://maven-badges.herokuapp.com/maven-central/biz.netcentric.maven.extension/maven-ext-repos-from-env/badge.svg)](https://maven-badges.herokuapp.com/maven-central/biz.netcentric.maven.extension/maven-ext-repos-from-env)\n[![Java CI/CD](https://github.com/Netcentric/maven-ext-repos-from-env/workflows/Java%20CI/CD/badge.svg)](https://github.com/Netcentric/maven-ext-repos-from-env/actions/workflows/maven.yml)\n[![License](https://img.shields.io/badge/License-EPL%202.0-red.svg)](https://www.eclipse.org/legal/epl-v20.html)\n\n# Maven Extension: Repos from System Env\n\nThis Maven extension allows to add additional remote repositories to the Maven execution by solely using OS level environment variables or Java system properties (without touching `settings.xml` nor `pom.xml`). Furthermore it allows to place certain artifacts directly under `.mvn/repository` (see details [below](#using-file-repositories)). This is achieved by modifying the in-memory [Maven settings](https://maven.apache.org/settings.html) before using them.\n\nWhile most of the time setting the remote repositories in the `settings.xml` (and potentially also in `pom.xml`) is the recommended approach, for cases where the `settings.xml` is not under the development team's control it can be useful to configure this extension. \n\nIn case the relevant environment variables are not set this extension has no effect (apart from the implicit file repo `.mvn/repository` if it exists). This allows to \n\n* Minimise the changes in the regular project setup (only the extension has to be added, all mirrors, repositories from `settings.xml` may remain active for local developers or CI servers)\n* Add additional repositories with the help of environment variables or system properties. \n\nThis is helpful for constrained build environments (without full control over the `settings.xml` file) and also to enforce a common repository across all developers without additional manual set up. As this extension always adds a **new** repository it is mostly useful for cases where no POM repositories are being used. *Just adding credentials for an existing (POM or settings.xml) repository is not supported yet ([issue 28](https://github.com/Netcentric/maven-ext-repos-from-env/issues/28))*.\n\n## Simple Usage\n\n### Step 1: Configure the extension for your repository\n\nIn directory `.mvn`, create (or adjust) the file `extensions.xml`:\n\n```\n\u003cextensions xmlns=\"http://maven.apache.org/EXTENSIONS/1.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n  xsi:schemaLocation=\"http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd\"\u003e\n    \u003cextension\u003e\n        \u003cgroupId\u003ebiz.netcentric.maven.extension\u003c/groupId\u003e\n        \u003cartifactId\u003emaven-ext-repos-from-env\u003c/artifactId\u003e\n        \u003cversion\u003e1.2.0\u003c/version\u003e\n    \u003c/extension\u003e\n\u003c/extensions\u003e\n\n```\nSee [Maven documentation](https://maven.apache.org/configure.html#mvn-extensions-xml-file) for reference on how extensions can be activated.\n\nThe artifact is available at [Maven Central](https://search.maven.org/search?q=g:biz.netcentric.maven.extension%20AND%20a:maven-ext-repos-from-env).\n\n### Step 2: Setup the environment variables or system properties for your build\n\nIn all the following examples environment variables are used, but this extension can also be configured with Java system properties having the same name as the environment variables. In case both a variable and property are given with the same name the system property takes precedence.\n\n#### Remote https repo using credentials\n\nThe following environment variables can be set to have the Maven extension above automatically add both the repository (could be otherwise in `pom.xml` or in `settings.xml`) and the authentication for the server (would have to be configured in `settings.xml` without this extension):\n\n```\nexport MVN_SETTINGS_REPO_URL=https://repo.myorg.com/path/to/repo\nexport MVN_SETTINGS_REPO_USERNAME=username\nexport MVN_SETTINGS_REPO_PASSWORD=password\n```\n\nThis leads to using authentication via basic auth to the given repository.\n\nIt is also possible to use [Preemptive Authentication](https://maven.apache.org/guides/mini/guide-resolver-transport.html#Low-level_Resolver_configuration):\n\n```\nexport MVN_SETTINGS_REPO_USE_PREEMPTIVE_AUTH=true\n```\n\nIMPORTANT: Preemptive Authentication will only be used for the repository it is configured for (it's not set globally, the credentials will not be sent to any other repository configured nor to Maven Central)\n\n#### Remote https repo without authentication\n\nFor the case no authentication is necessary, setting only one environment variable is sufficient:\n\n```\nexport MVN_SETTINGS_REPO_URL=https://repo.myorg.com/path/to/repo_no_auth\n```\n\nFor this case, no corresponding `server` entry is generated for this repository.\n\n#### Using multiple repositories\n\nIt is also possible to use multiple repositories by placing an infix between the environment prefix `MVN_SETTINGS_REPO` and the configuration specific suffix:\n\n```\n# REPO_NAME1\nexport MVN_SETTINGS_REPO_NAME1_URL=https://repo.myorg.com/path/to/repo\nexport MVN_SETTINGS_REPO_NAME1_USERNAME=username1\nexport MVN_SETTINGS_REPO_NAME1_PASSWORD=password1\n# REPO_NAME2\nexport MVN_SETTINGS_REPO_NAME2_URL=https://repo.myorg.com/path/to/repo\nexport MVN_SETTINGS_REPO_NAME2_USERNAME=username2\nexport MVN_SETTINGS_REPO_NAME2_PASSWORD=password2\n```\n\nIn this example two repositories and two server entries for are created. The order can be important for performance reasons, the repositories are added in alphabetical order of their names. \n\n#### Using file repositories\n\nAs generally true for Maven repositories, it is also possible to use file urls. To reference a file repository within the build repository itself, use the property `maven.multiModuleProjectDirectory` in the value of `MVN_SETTINGS_REPO_URL`, e.g. `MVN_SETTINGS_REPO_URL=file://${maven.multiModuleProjectDirectory}/vendor1/repository`. If the directory `.mvn/repository` exists, it is automatically added as file repository.\n\nThis approach can be useful for parent poms or importing dependencies (scope `import`).\n\n#### Using the verbose logging mode\n\nWith the environment variable `MVN_SETTINGS_REPO_LOG_VERBOSE`, some more logging can be activated:\n\n```\nexport MVN_SETTINGS_REPO_LOG_VERBOSE=true\n```\n\n#### Bypassing mirrors\n\nIn case the `settings.xml` defines one or multiple mirrors, those are automatically disabled for the newly added repositories by adding their ids to the `mirrorOf` value with a leading `!` as documented in [Advanced Mirror Specification](https://maven.apache.org/guides/mini/guide-mirror-settings.html#advanced-mirror-specification). To disable this mirror bypass set the environment variable `MVN_DISABLE_BYPASS_MIRRORS` to `true`.\n\n#### Repository order\n\nBy default, the repositories as configured in env are queried **after** the default repositories in `settings.xml`. For the case that the system env repo is also a proxy repository for Maven Central (i.e. containing all required artifacts), it can be forced to be used first (before the repositories from settings.xml).\n\n```\nexport MVN_SETTINGS_ENV_REPOS_FIRST=true\n```\n\nSetting this flag is only relevant for performance reasons, the overall build will work with or without this flag.\nFor the general order of repositories (both from settings and POM) refer to \u003chttps://maven.apache.org/guides/mini/guide-multiple-repositories.html#repository-order\u003e.\n\n#### Distribute configuration with code\n\nIn case environment variables are too much effort to set one can also leverage the [`.mvn/jvm.config` file](https://maven.apache.org/configure.html#mvn-jvm-config-file) to set the configuration via [Java system properties](https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html).\n\nAn example file might look like this\n\n```\n-DMVN_SETTINGS_REPO_NAME1_URL=https://repo.myorg.com/path/to/repo -DMVN_SETTINGS_REPO_NAME1_USERNAME=username1 -DMVN_SETTINGS_REPO_NAME1_PASSWORD=password1\n```\n\nSuch a configuration can be distributed through the SCM along with the code (in case the values are not supposed to be treated as secrets).\n\n## Usage with Adobe Experience Manager Cloud Manager\n\n### Step 1: Configure the extension for your repository\n\nReference the Maven extension in the `.mvn/extensions.xml` file as described above.\n\n### Step 2: Setup the environment for your build using Adobe IO\n\n*Prerequisites:*\n\n* Add the `Cloud Manager API` to your Adobe IO project at [https://console.adobe.io/](https://console.adobe.io/)\n  * Add a Service Account (JWT based) by either uploading a public key (from a manually generated private/public key pair) or letting the wizard generate both private and public key for you. In both cases make sure to store the private key in a safe place.\n  * Setting environment variables requires [permissions of role `Deployment Manager`](https://www.adobe.io/apis/experiencecloud/cloud-manager/docs.html#!AdobeDocs/cloudmanager-api-docs/master/permissions.md) so make sure that the service account has at least that permission\n* Install [aio-cli](https://github.com/adobe/aio-cli/blob/master/README.md#usage)\n* Setup Adobe IO CLI in general [Getting Started](https://www.adobe.io/apis/experienceplatform/project-firefly/docs.html#!AdobeDocs/project-firefly/master/getting_started/setup.md)\n* Install [aio-cli-plugin-cloudmanager](https://github.com/adobe/aio-cli-plugin-cloudmanager#installation)\n* Setup [Adobe IO authentication with Cloud Manager](https://github.com/adobe/aio-cli-plugin-cloudmanager#authentication)\n\nOnce everything is set up, the environment variables of the Cloud Manager build can be set as follows:\n\n```\naio cloudmanager:set-pipeline-variables \\\n   \u003cPIPELINE_ID\u003e \\\n   --programId=\u003cPROGRAM_ID\u003e \\\n   --variable \\\n     MVN_SETTINGS_REPO_URL \u003cREPO_URL\u003e \\\n     MVN_SETTINGS_REPO_USERNAME \u003cREPO_USER\u003e \\\n   --secret \\\n     MVN_SETTINGS_REPO_PASSWORD \u003cREPO_PASSWORD\u003e  \n```\n\nThe parameters `\u003cPIPELINE_ID\u003e` and `\u003cPROGRAM_ID\u003e` can be derived from URLs when browsing the Cloud Manager. The call needs to be made for each pipeline as set up in cloud manager (all non-prod and the prod pipeline).\n\nSee also official [Adobe documentation](https://docs.adobe.com/content/help/en/experience-manager-cloud-service/onboarding/getting-access/creating-aem-application-project.html#pipeline-variables) and [reference on GitHub](https://github.com/adobe/aio-cli-plugin-cloudmanager#aio-cloudmanagerset-pipeline-variables-pipelineid)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcentric%2Fmaven-ext-repos-from-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetcentric%2Fmaven-ext-repos-from-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcentric%2Fmaven-ext-repos-from-env/lists"}