{"id":15338041,"url":"https://github.com/khmarbaise/multienv-maven-plugin","last_synced_at":"2025-04-14T23:36:02.408Z","repository":{"id":44869412,"uuid":"53270375","full_name":"khmarbaise/multienv-maven-plugin","owner":"khmarbaise","description":"multienv-maven-plugin","archived":false,"fork":false,"pushed_at":"2022-01-21T15:05:04.000Z","size":1068,"stargazers_count":9,"open_issues_count":16,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T11:42:40.658Z","etag":null,"topics":["java","maven","maven-plugin"],"latest_commit_sha":null,"homepage":"https://khmarbaise.github.io/multienv-maven-plugin/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/khmarbaise.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-06T18:48:49.000Z","updated_at":"2020-10-12T00:22:36.000Z","dependencies_parsed_at":"2022-09-15T01:21:16.719Z","dependency_job_id":null,"html_url":"https://github.com/khmarbaise/multienv-maven-plugin","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khmarbaise%2Fmultienv-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khmarbaise%2Fmultienv-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khmarbaise%2Fmultienv-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khmarbaise%2Fmultienv-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khmarbaise","download_url":"https://codeload.github.com/khmarbaise/multienv-maven-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248980627,"owners_count":21193135,"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":["java","maven","maven-plugin"],"created_at":"2024-10-01T10:24:03.054Z","updated_at":"2025-04-14T23:36:02.367Z","avatar_url":"https://github.com/khmarbaise.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Multi Environment Maven Plugin\n==============================\n\n[![Apache License, Version 2.0, January 2004][shield-license]][apache-license]\n[![Build Status][build-status]][travis-ci]\n[![Maven Central][shield-central]][maven-central]\n\nLicense\n-------\n[Apache License, Version 2.0, January 2004](http://www.apache.org/licenses/)\n\n\nOverview\n--------\n\nThere are several scenarios where you have different configurations for \ndifferent environments like dev, test, prod etc. (in real life there are\nusually more environments than three.).\n\nNow you need to produce different artifacts for example war files for those\ndifferent environments. A combination of [maven-assembly-plugin and some\ndescriptors][blog-multiple-environments-i] will solve this. Also this\ncan be [enhanced for other things as well][blog-multiple-environments-ii].\n\nThe problem becomes worse if you have more than two or three environments than the\n[configuration][iterator-plugin] with\n[maven-assembly-plugin][iterator-plugin-map] etc. became cumbersome.\nThis plugin will exactly handle such scenarios.\n\nThe scenarios are the following. Producing artifacts which include the\nconfiguration for each [environment](README.md#example-1): or artifacts which contain only the \n[configuration](README.md#example-2): for the appropriate environment.\n\nExample 1\n---------\n\nLet us assume you have several environments like `dev-01`, `dev-02`, `test-01`,\n`test-02` and finally `prod`. We will make the situation simpler for this\nexample and assume having only a single module build which produces a\nsingle `war` file as a result.\n\nThe prerequisite to use the MultiEnv Maven Plugin is to create\na directory structure similar like the following:\n\n     src\n      ├── main \n            ├── environments\n                 ├── dev-01\n                 │   └── first.properties\n                 ├── dev-02\n                 │   └── first.properties\n                 ├── test-01\n                 │   └── first.properties\n                 ├── test-02\n                 │   └── first.properties\n                 └── prod\n                     └── first.properties\n\nIn result the MultiEnv Maven Plugin will automatically create the\nappropriate war files containing the configuration file `first.properties`\n(just a single file for brevity in this example) which might contain some information like\n the database connections url etc. for the appropriate environment.\n\nYou can of course put several different files into the different environment\ndirectories. It is also possible to create a directory structure under the appropriate\nenvironment. This will also be packaged into the resulting artifact.\n\nThe environment name (directory name `dev-01`, `dev-02`, `test-01` etc.) will\nautomatically being used as classifier for the appropriate artifact. So we\nwould get the following files after running MultiEnv Maven Plugin via \n([assuming you have configured it correctly](README.md#how-to-configure)):\n\n```\nmvn clean package\n```\n\n  * artifactId-version-dev-01.war\n  * artifactId-version-dev-02.war\n  * artifactId-version-test-01.war\n  * artifactId-version-test-02.war\n  * artifactId-version-prod.war\n\n\nIf you need to add a new environment this can simply being achieved by adding a\nnew directory under `environments` which might being called `qa-01` plus the\ninformation you would like to configure and that's it. MultiEnv Maven\nPlugin will automatically identify the new environment by searching in the\nenvironment directory and producing an appropriate artifact out of it.\n\nThose above packages contain the original `war` file content as well\nas the supplemental files/directories which have been given for the\nappropriate environments.\n\nExample 2\n---------\n\nIn this example we would like to create configuration artifacts for \neach environment.\n\nThe configuration looks exactly the same in [Example 1](README.md#example-1)\nexcept for the used goal. So you need to change the \ngoal from `environment` to `configuration` in the plugin configuration.\nBy using the:\n\n```\nmvn clean package\n```\n\nyou will produce the following artifacts:\n\n  * artifactId-version-dev-01.jar\n  * artifactId-version-dev-02.jar\n  * artifactId-version-test-01.jar\n  * artifactId-version-test-02.jar\n  * artifactId-version-prod.jar\n\nAs you might already realized that those files are not `war` files. The\nfiles are jar files which contain the configuration for each environment.\n\n\nHow To Configure\n----------------\n\nTo configure MultiEnv Maven Plugin you simply add the following\nto your pom file (we assume here a war file):\n\n``` xml\n\n  \u003cgroupId\u003egroupId\u003c/groupId\u003e\n  \u003cartifactId\u003eartifactId\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.0-SNAPSHOT\u003c/version\u003e\n  \u003cpackaging\u003ewar\u003c/packaging\u003e\n  ...\n  \u003cbuild\u003e\n    \u003cplugins\u003e\n      \u003cplugin\u003e\n        \u003cgroupId\u003ecom.soebes.maven.plugins\u003c/groupId\u003e\n        \u003cartifactId\u003emultienv-maven-plugin\u003c/artifactId\u003e\n        \u003cversion\u003e0.3.1\u003c/version\u003e\n        \u003cexecutions\u003e\n          \u003cexecution\u003e\n            \u003cgoals\u003e\n              \u003cgoal\u003eenvironment\u003c/goal\u003e\n            \u003c/goals\u003e\n          \u003c/execution\u003e\n        \u003c/executions\u003e\n      \u003c/plugin\u003e\n    \u003c/plugins\u003e\n  \u003c/build\u003e\n```\n\nFiltering\n---------\n\nBased on the given directory structure files like `first.properties` etc. will be\nfiltered before they are packaged into the resulting artifacts. This means you\ncan use things like `${project.version}` in your files or other self defined\nproperties.\n\n\nDocument:\n\n * Using filename/directory filtering ?\n * Different files for different environments\n\nAdvantages\n----------\n\n * Much more convenient \n * less configuration. \n * Dynamically add new environments \n * No Profiles needed.\n\nTODO\n----\n\n * MultiEnv Maven Plugin in a different maven project within multi module\n   build? How does that work? \n * Overwriting of file which exist in the original artifact? How to handle?\n * Produce an artifact only for a single environment?\n   `mvn -Dmultienv.environment=test-01 clean package` \n   Is this a good idea?\n * Do filtering for each environment separately. So we could inject\n   the name of the environment. This can be used put the name of the\n   environment into the resulting files via filtering.\n\n[blog-multiple-environments-i]: http://blog.soebes.de/blog/2011/07/29/maven-configuration-for-multipe-environments/\n[blog-multiple-environments-ii]: http://blog.soebes.de/blog/2011/08/11/maven-configuration-for-multipe-environments-ii/\n[iterator-plugin]: http://khmarbaise.github.io/iterator-maven-plugin/\n[iterator-plugin-map]: https://github.com/khmarbaise/iterator-maven-plugin/blob/master/src/it/mavenAssemblyPluginTest/pom.xml\n[maven-central]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.soebes.maven.plugins%22%20a%3A%22multienv-maven-plugin%22\n[apache-license]: http://www.apache.org/licenses/\n[travis-ci]: https://travis-ci.org/khmarbaise/multienv-maven-plugin\n[build-status]: https://travis-ci.org/khmarbaise/multienv-maven-plugin.svg?branch=master\n[shield-central]: https://img.shields.io/maven-central/v/com.soebes.maven.plugins/multienv-maven-plugin.svg?label=Maven%20Central\n[shield-license]: https://img.shields.io/github/license/khmarbaise/iterator-maven-plugin.svg?label=License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhmarbaise%2Fmultienv-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhmarbaise%2Fmultienv-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhmarbaise%2Fmultienv-maven-plugin/lists"}