{"id":18026774,"url":"https://github.com/yegor256/farea","last_synced_at":"2025-03-27T01:31:24.387Z","repository":{"id":209005689,"uuid":"722894239","full_name":"yegor256/farea","owner":"yegor256","description":"Fake Maven Reactor for unit-testing of your Maven plugins: similar Maven Invoker Plugin, but JUnit friendly","archived":false,"fork":false,"pushed_at":"2024-10-29T11:31:17.000Z","size":353,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T13:23:54.734Z","etag":null,"topics":["integration-testing","java","maven","maven-invoker","maven-invoker-plugin","maven-plugin","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yegor256.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-24T07:52:07.000Z","updated_at":"2024-10-29T11:30:56.000Z","dependencies_parsed_at":"2024-02-04T10:33:06.206Z","dependency_job_id":"2d1315a2-a179-4a72-a8ef-ab3dba7520da","html_url":"https://github.com/yegor256/farea","commit_stats":{"total_commits":128,"total_committers":4,"mean_commits":32.0,"dds":0.359375,"last_synced_commit":"df72f11d2074f835b1fdfbab045a25cc6fd8bbdb"},"previous_names":["yegor256/farea"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ffarea","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ffarea/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ffarea/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ffarea/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/farea/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245764695,"owners_count":20668462,"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":["integration-testing","java","maven","maven-invoker","maven-invoker-plugin","maven-plugin","testing"],"created_at":"2024-10-30T08:07:59.321Z","updated_at":"2025-03-27T01:31:24.381Z","avatar_url":"https://github.com/yegor256.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fake Maven Reactor, for Quick Unit Tests\n\n[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)\n[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/farea)](http://www.rultor.com/p/yegor256/farea)\n[![We recommend IntelliJ IDEA](https://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)\n\n[![mvn](https://github.com/yegor256/farea/actions/workflows/mvn.yml/badge.svg)](https://github.com/yegor256/farea/actions/workflows/mvn.yml)\n[![PDD status](http://www.0pdd.com/svg?name=yegor256/farea)](http://www.0pdd.com/p?name=yegor256/farea)\n[![Maven Central](https://img.shields.io/maven-central/v/com.yegor256/farea.svg)](https://maven-badges.herokuapp.com/maven-central/com.yegor256/farea)\n[![Javadoc](http://www.javadoc.io/badge/com.yegor256/farea.svg)](http://www.javadoc.io/doc/com.yegor256/farea)\n[![codecov](https://codecov.io/gh/yegor256/farea/branch/master/graph/badge.svg)](https://codecov.io/gh/yegor256/farea)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/farea)](https://hitsofcode.com/view/github/yegor256/farea)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/farea/blob/master/LICENSE.txt)\n\nIt's a fake Maven Reactor, helping you to integration-test\nyour custom Maven plugins.\nThere is a traditional way to do this:\n[Maven Invoker Plugin][invoker].\nIt works perfectly, but it has two pretty annoying\ndrawbacks: 1) It doesn't run from IDE (at least from IntelliJ IDEA),\nand 2) It always starts the entire build from scratch,\nwhich makes 3) it pretty slow.\n\nFarea suggests an alternative way, which is way less flexible, but much\nfaster and JUnit-friendly.\n\nFirst, you add this to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.yegor256\u003c/groupId\u003e\n  \u003cartifactId\u003efarea\u003c/artifactId\u003e\n  \u003cversion\u003e0.15.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThen, you use it like this, in your JUnit5 test\n(obviously, you need to have `mvn` installed\nand available on `$PATH`):\n\n```java\nimport com.yegor256.farea.Farea;\nimport com.yegor256.farea.RequisiteMatcher;\nimport org.hamcrest.MatcherAssert;\nimport org.hamcrest.Matchers;\nimport org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.io.TempDir;\n\nclass JavaCompilationTest {\n  @Test\n  void worksAsExpected(@Mktmp Path dir) {\n    new Farea(dir).together(f -\u003e {\n      f.files()\n        .file(\"src/test/java/Hello.java\")\n        .write(\"class Hello {}\".getBytes());\n      f.dependencies().append(\"org.cactoos\", \"cactoos\", \"0.55.0\");\n      f.exec(\"compile\");\n      MatcherAssert.assertThat(\n        \"Compiles without any issues\",\n        f.files().log(),\n        RequisiteMatcher.SUCCESS\n      );\n    });\n  }\n}\n```\n\nThis code will create a new `pom.xml` file in the temporary directory,\ncreate a temporary `Hello.java` file, write simple content into it,\nadd a new `\u003cdependency\u003e` to the `pom.xml`, and then run `mvn test` in this\ntemporary directory. The output of the build will be saved to `log.txt`,\nwhich is available through the call to `.log()` method.\n\nYou can also test the plugin that you are developing, inside the same reactor:\n\n```java\nclass MyPluginTest {\n  @Test\n  void worksAsExpected(@Mktmp Path dir) {\n    new Farea(dir).together(f -\u003e {\n      f.build()\n        .plugins()\n        .appendItself()\n        .execution()\n        .phase(\"test\")\n        .goals(\"my-custom-goal\")\n        .configuration()\n        .set(\"message\", \"Hello, world!\");\n      f.exec(\"test\");\n      assert f.files().log().contains(\"SUCCESS\");\n    });\n  }\n}\n```\n\nHere, a `.jar` with the entire classpath will be packaged and saved\ninto the `~/.m2/repository/` directory. This is almost exactly what\nthe [`install`][install-mojo] goal of the\n[invoker plugin][invoker] would do if you use it for\nintegration testing.\n\nIt is recommended to add this to your `pom.xml`, in order\nto enable interactive test runs right from the IDE:\n\n```xml\n\u003cproject\u003e\n  \u003cbuild\u003e\n    \u003cplugins\u003e\n      [...]\n      \u003cplugin\u003e\n        \u003cartifactId\u003emaven-resources-plugin\u003c/artifactId\u003e\n        \u003cexecutions\u003e\n          \u003cexecution\u003e\n            \u003cid\u003ecopy-descriptor\u003c/id\u003e\n            \u003cphase\u003eprocess-classes\u003c/phase\u003e\n            \u003cgoals\u003e\n              \u003cgoal\u003ecopy-resources\u003c/goal\u003e\n            \u003c/goals\u003e\n            \u003cconfiguration\u003e\n              \u003coutputDirectory\u003e${project.build.directory}\u003c/outputDirectory\u003e\n              \u003cresources\u003e\n                \u003cresource\u003e\n                  \u003cdirectory\u003e${project.build.outputDirectory}/META-INF/maven\u003c/directory\u003e\n                  \u003cincludes\u003e\n                    \u003cinclude\u003eplugin.xml\u003c/include\u003e\n                  \u003c/includes\u003e\n                \u003c/resource\u003e\n              \u003c/resources\u003e\n            \u003c/configuration\u003e\n          \u003c/execution\u003e\n        \u003c/executions\u003e\n      \u003c/plugin\u003e\n    \u003c/plugins\u003e\n  \u003c/build\u003e\n\u003c/project\u003e\n```\n\nThis will make sure the `META-INF/maven/plugin.xml` is not destroyed\nin the `target/classes` by the IDE before the next test run.\n\nSee how\n[antlr2ebnf-maven-plugin](https://github.com/yegor256/antlr2ebnf-maven-plugin)\nis using Farea.\n\n## How to Contribute\n\nFork repository, make changes, send us a\n[pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nWe will review your changes and apply them to the `master` branch shortly,\nprovided they don't violate our quality standards. To avoid frustration,\nbefore sending us your pull request please run full Maven build:\n\n```bash\nmvn clean install -Pqulice\n```\n\nYou will need Maven 3.3+ and Java 11+.\n\n[invoker]: https://maven.apache.org/plugins/maven-invoker-plugin/index.html\n[install-mojo]: https://maven.apache.org/plugins/maven-invoker-plugin/install-mojo.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Ffarea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Ffarea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Ffarea/lists"}