{"id":27915040,"url":"https://github.com/kyoripowered/blossom","last_synced_at":"2025-05-06T15:33:43.619Z","repository":{"id":37435709,"uuid":"41350676","full_name":"KyoriPowered/blossom","owner":"KyoriPowered","description":"A Gradle plugin to perform source code token replacements in Java-based projects","archived":false,"fork":false,"pushed_at":"2025-04-28T02:11:09.000Z","size":660,"stargazers_count":97,"open_issues_count":11,"forks_count":10,"subscribers_count":9,"default_branch":"main/2.x","last_synced_at":"2025-04-28T03:23:26.923Z","etag":null,"topics":["gradle","java","templating"],"latest_commit_sha":null,"homepage":"https://blossom.kyori.net","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KyoriPowered.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,"zenodo":null}},"created_at":"2015-08-25T07:47:24.000Z","updated_at":"2025-03-03T12:21:11.000Z","dependencies_parsed_at":"2022-07-07T21:03:40.688Z","dependency_job_id":"475d9403-1c81-4083-a292-e15afb883f01","html_url":"https://github.com/KyoriPowered/blossom","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoriPowered%2Fblossom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoriPowered%2Fblossom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoriPowered%2Fblossom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoriPowered%2Fblossom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KyoriPowered","download_url":"https://codeload.github.com/KyoriPowered/blossom/tar.gz/refs/heads/main/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252713077,"owners_count":21792423,"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":["gradle","java","templating"],"created_at":"2025-05-06T15:33:43.033Z","updated_at":"2025-05-06T15:33:43.611Z","avatar_url":"https://github.com/KyoriPowered.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"blossom [![Build Status](https://img.shields.io/github/actions/workflow/status/KyoriPowered/blossom/build.yml)](https://github.com/KyoriPowered/blossom/actions) [![License](https://img.shields.io/badge/license-LGPL_v2.1-lightgrey.svg?style=flat)][LGPL v2.1] [![Gradle Plugin](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/net/kyori/blossom/maven-metadata.xml.svg?label=gradle%20plugin\u0026style=flat)](https://plugins.gradle.org/plugin/net.kyori.blossom)\n=========\nblossom is a Gradle plugin for processing source templates to resources and sources across several languages. It is licensed under the [LGPL v2.1] license.\n\n## Usage\nApply the plugin to your project. Blossom requires a minimum of Java 11. It is tested with the latest revision of the current major release of Gradle, and the latest revision of the previous major release of Gradle, but we focus our development time on newer Gradle versions.\n\n```kotlin\nplugins {\n  id(\"net.kyori.blossom\") version \"2.1.0\"\n}\n```\n\nBlossom adds the `blossom` extension on every source set, allowing the configuration of templating for that source set. No template sets are enabled by default.\n\nBoth file names and source files can be templated as desired, using the [Pebble] templating language.\n\n### Resource templating\n\nCall the `resources()` method on the blossom extension to start applying resource templates:\n\n```kotlin\nversion = \"1.4.0-SNAPSHOT\"\n\nsourceSets {\n  main {\n    blossom {\n      resources {\n        property(\"version\", project.version.toString())\n      }\n    }\n  }\n}\n```\n\nThen place a file in the `src/main/resource-templates` folder:\n\n`build-vars.properties`:\n\n```properties\nversion={{ version }}\n```\n\nWhen the project is built, the `build-vars.properties` file will be processed into the final resource:\n\n```properties\nversion=1.4.0-SNAPSHOT\n```\n\n### Source templating\n\nSource templating works similarly, though there is a bit of added complexity due to supporting multiple JVM languages:\n\n`build.gradle.kts`:\n\n```kotlin\nsourceSets {\n  main {\n    blossom {\n      javaSources {\n        property(\"version\", project.version.toString())\n        property(\"gitCommit\", indraGit.commit.map { it.name() }.orNull())\n        property(\"decompilerVersion\", libs.versions.vineflower.get())\n      }\n    }\n  }\n}\n```\n\n`src/main/java-templates/net/kyori/blossomtest/BuildParameters.java.peb`:\n\n```pebble\npackage net.kyori.blossomtest;\n\nclass BuildParameters {\n    public static final String VERSION = \"{{ version }}\";\n    public static final String GIT_COMMIT = \"{{ gitCommit | default(\"unknown\") }}\";\n    public static final String DECOMPILER_VERSION = \"{{ decompilerVersion }}\";\n}\n```\n\nThe `BuildParameters` class will be processed and available to other files being compiled.\n\n## Variants and parameter files, oh my!\n\nWhile templates on their own allow generating quite a bit, Blossom adds an extra layer of power with *variants*. Each template set can have either the default variant,\nor several named variants, which produce output from the same template but different variables as input. When combined with templated file names, this allows generating \na whole lot of different source files from one input (for example, when working with java primitives).\n\nProperties themselves and property files can be set both for each template set individually, and per-variant.\n\nAs an example:\n\n`build.gradle.kts`:\n\n```kotlin\nsourceSets {\n  main {\n    blossom {\n      javaSources {\n        propertyFile(\"template-vars.yaml\")\n        variants(\"float\", \"int\", \"double\")\n      }\n    }\n  }\n}\n```\n\n`template-vars.yaml`:\n\n```yaml\ntype: potato # shared across variants\n\n# variants key has a special meaning if multiple variants exist - each subkey should match the name of one variant.\n# the values under each variant are \nvariants:\n  float:\n    suffix: \"f\"\n    wrapper: \"Float\"\n  int:\n    suffix: \"\"\n    wrapper: \"Integer\"\n  double:\n    suffix: \"d\"\n    wrapper: \"Double\"\n```\n\nThis will process all templates three times, once for each variant -- so a `src/main/java-templates/{{ wrapper }}Box.java.peb` would produce three class files:\n\n- `FloatBox.java`\n- `IntegerBox.java`\n- `DoubleBox.java`\n\nTemplate parameters set from different sources (via the DSL) will override each other, inheriting in the following order (where the last element in the list takes priority):\n\n- Default properties provided by Blossom\n  - `variant`: provides the variant name as a parameter (only present in named variant mode)\n- Template set, defined in a set property file\n- Template set, defined in-buildscript\n- Variant, defined in global files\n- Variant, defined in the variant-specific property files\n- Variant, defined in-buildscript\n\n## IDE Integration\n\nOn first import into an IDE, you may have to run the `generateTemplates` task to ensure templates have been generated. For some common IDEs, we hook into the IDE's refresh system in order to \n\n### Eclipse\n\nIn Eclipse, this task is registered as a \"synchronization\" task, which will update templates every time the project is synced with Gradle.\n\n### IntelliJ\n\nFor IntelliJ integration, also add the [`org.jetbrains.gradle.plugin.idea-ext`](https://github.com/JetBrains/gradle-idea-ext-plugin) plugin, and Blossom will automatically configure the appropriate post-import hooks. Eclipse integration requires no other plugins.\n\nThere is some IDE support for the Pebble syntax. An [IntelliJ plugin](https://plugins.jetbrains.com/plugin/9407-pebble) exists, though it does\nlittle more than syntax highlighting.\n\nIntelliJ also has a setting that attempts to highlight template files as Java source files\n(available under Preferences \u003e Languages \u0026 Frameworks \u003e Template Data Languages). This option is of varying effectiveness depending on the source file.\n\n### Others\n\nOn other IDEs, there is no current support, but we are open to adding such support if there's a way -- open an issue if you use an IDE with such facilities that is not yet supported.\n\n\n[Pebble]: https://pebbletemplates.io/\n[LGPL v2.1]: https://choosealicense.com/licenses/lgpl-2.1/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyoripowered%2Fblossom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyoripowered%2Fblossom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyoripowered%2Fblossom/lists"}