{"id":20727782,"url":"https://github.com/plippe/sbt-yax","last_synced_at":"2025-03-11T09:23:28.408Z","repository":{"id":151296915,"uuid":"111117633","full_name":"plippe/sbt-yax","owner":"plippe","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-29T21:14:17.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T23:43:58.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plippe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":"plippe"}},"created_at":"2017-11-17T15:16:19.000Z","updated_at":"2022-09-29T21:14:19.000Z","dependencies_parsed_at":"2023-04-14T15:46:52.471Z","dependency_job_id":null,"html_url":"https://github.com/plippe/sbt-yax","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plippe%2Fsbt-yax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plippe%2Fsbt-yax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plippe%2Fsbt-yax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plippe%2Fsbt-yax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plippe","download_url":"https://codeload.github.com/plippe/sbt-yax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243005221,"owners_count":20220439,"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":[],"created_at":"2024-11-17T04:34:08.990Z","updated_at":"2025-03-11T09:23:28.379Z","avatar_url":"https://github.com/plippe.png","language":"Scala","funding_links":["https://github.com/sponsors/plippe"],"categories":[],"sub_categories":[],"readme":"# sbt-yax\n\n[![Build Status](https://app.wercker.com/status/9f1f0701af2be47cfafbea03b0d1a5c0/s/master)](https://app.wercker.com/project/byKey/9f1f0701af2be47cfafbea03b0d1a5c0)\n[![Download](https://api.bintray.com/packages/plippe/sbt/sbt-yax/images/download.svg)](https://bintray.com/plippe/sbt/sbt-yax/_latestVersion)\n\n\u003e Yax has been extracted from the [doobie][doobie] project. [The code][doobie_yax] has been written by Rob Norris, not\n\u003e me.\n\u003e\n\u003e I have only converted it to an sbt plugin.\n\n\nYax is a simple templating solution that runs before compilation to avoid repetition. It is particular useful to\ngenerate multiple projects that are barely different; e.g. scala versions, library dependencies, hard coded constantes.\n\n\n### Installing sbt-yax\n\nTo add sbt-yax, just update your `project/plugins.sbt` file.\n\n```sbt\n// in project/plugins.sbt\nresolvers += Resolver.url(\"plippe-sbt\", url(\"http://dl.bintray.com/plippe/sbt\"))(Resolver.ivyStylePatterns)\naddSbtPlugin(\"com.github.plippe\" % \"sbt-yax\" % \"XXX\")\n```\n\n\n### Using sbt-yax\n\n#### Defining your yax projects\n\nHere are two identical projects. The only difference is that one outputs foo, while the other outputs bar. This problem\ncould have been solved in many simpler ways. For harder examples, look at the [other examples][examples].\n\n```sbt\n// in build.sbt\nval foo = project\n    .in(file(\"foobar\"))\n    .settings(\n        yax(\n            file(\"yax/foobar\"), // Path to yax project\n            \"foo\", // Name of block to display\n            \"otherBlock\", \"andAnother\" // More block names\n        ),\n        target := baseDirectory.value / \"target\" / \"foo\"\n    )\n\nval bar = project\n    .in(file(\"foobar\"))\n    .settings(\n        yax(file(\"yax/foobar\"), \"bar\"),\n        target := baseDirectory.value / \"target\" / \"bar\"\n    )\n```\n\n\n#### Defining your yax blocks\n\nThe avoid repetition, those two projects will share the same code base, `yax/foobar`. The flags identify blocks of code\nto include in the final project. A block opens with `#+[BLOCK_NAME]` and closes with `#-[BLOCK_NAME]`.\n\n```scala\nobject Main extends App {\n\n#+foo\n  var helloWorld = \"foo\"\n#-foo\n\n#+bar\n  val helloWorld = \"bar\"\n#-bar\n\n  println(helloWorld)\n}\n```\n\nRunning `sbt foo/run` will display `foo`, while `sbt bar/run` prints `bar`. Furthermore, the `foo` project doesn't have\nany references to `bar`, and `bar` none to `foo`. This is particularly useful when the two projects depends on\ndifferent libraries, and the blocks contain the imports.\n\n\n[doobie]: https://github.com/tpolecat/doobie\n[doobie_yax]: https://github.com/tpolecat/doobie/blob/c2bcbf52d324b79f2f07c4f9f353169141cb0f6b/project/yax.scala\n\n[examples]: https://github.com/plippe/sbt-yax/tree/master/examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplippe%2Fsbt-yax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplippe%2Fsbt-yax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplippe%2Fsbt-yax/lists"}