{"id":20666415,"url":"https://github.com/hosuaby/inject-resources","last_synced_at":"2025-10-29T23:31:42.782Z","repository":{"id":47276341,"uuid":"241732178","full_name":"hosuaby/inject-resources","owner":"hosuaby","description":"Simple and convenient way to read content of resource in Java.","archived":false,"fork":false,"pushed_at":"2024-08-16T17:31:41.000Z","size":711,"stargazers_count":56,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-30T14:09:14.284Z","etag":null,"topics":["gson","jackson","java","json","jsonl","junit","jupiter","load","loading","parse","parse-resources","parsing","resource","resources","snakeyaml","spring","tests","text","yaml"],"latest_commit_sha":null,"homepage":"http://inject-resources.hosuaby.io","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/hosuaby.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-02-19T21:39:55.000Z","updated_at":"2025-01-22T00:00:19.000Z","dependencies_parsed_at":"2024-08-15T17:55:56.172Z","dependency_job_id":"7d861183-41f6-476a-9233-68942e586ac5","html_url":"https://github.com/hosuaby/inject-resources","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hosuaby%2Finject-resources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hosuaby%2Finject-resources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hosuaby%2Finject-resources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hosuaby%2Finject-resources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hosuaby","download_url":"https://codeload.github.com/hosuaby/inject-resources/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237575798,"owners_count":19332525,"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":["gson","jackson","java","json","jsonl","junit","jupiter","load","loading","parse","parse-resources","parsing","resource","resources","snakeyaml","spring","tests","text","yaml"],"created_at":"2024-11-16T19:37:25.232Z","updated_at":"2025-10-29T23:31:42.076Z","avatar_url":"https://github.com/hosuaby.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @InjectResources\n\n[![CI](https://github.com/hosuaby/inject-resources/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/hosuaby/inject-resources/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/hosuaby/inject-resources/badge.svg?branch=master)](https://coveralls.io/github/hosuaby/inject-resources?branch=master)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.hosuaby/inject-resources-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.hosuaby/inject-resources-core)\n[![User guide](https://img.shields.io/badge/User%20guide-1.0.0-red)](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/)\n[![Core Javadoc](https://img.shields.io/badge/Core%20Javadoc-1.0.0-orange)](https://javadoc.io/doc/io.hosuaby/inject-resources-core/1.0.0)\n[![Spring Javadoc](https://img.shields.io/badge/Spring%20Javadoc-1.0.0-green)](https://javadoc.io/doc/io.hosuaby/inject-resources-spring/1.0.0)\n[![JUnit Jupiter Javadoc](https://img.shields.io/badge/JUnit%20Jupiter%20Javadoc-1.0.0-blueviolet)](https://javadoc.io/doc/io.hosuaby/inject-resources-junit-jupiter/1.0.0)\n[![JUnit 4 Javadoc](https://img.shields.io/badge/JUnit%204%20Javadoc-1.0.0-yellow)](https://javadoc.io/doc/io.hosuaby/inject-resources-junit-vintage/1.0.0)\n\n*Reading content of resource files in Java is harder that it should be*. Great libraries like\n[Guava](https://github.com/google/guava) or [Spring](https://github.com/spring-projects/spring-framework) made it much\neasier, but it's time to make another step forward. Use `@InjectResources` is the easiest and most convenient way to load\nand parse content of resources without boilerplate code that opens/closes streams and handles I/O exceptions. This library\nmade of [inject-resources-core](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-core),\nfluid Java DSL, and of extensions for\n[Spring](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-spring),\n[JUnit5](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-junit-jupiter) and\n[JUnit4](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-junit-vintage) that allow to do\nthat with simple annotations.\n\n## Examples\n\n### Core\n\n```java\nvar text = resource()\n        .onClassLoaderOf(this.getClass())\n        .withPath(\"/io/hosuaby/junit/jupiter\", \"resource.txt\")\n        .text();\n```\n\nCheck [Core](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-core) user guide for more information and examples.\n\n### With Spring\n\n```java\n@Component\npublic class MyBean {\n\n    // Field 'text' is injected with content of '/io/hosuaby/junit/jupiter/resource.txt'\n    @TextResource(\"/io/hosuaby/junit/jupiter/resource.txt\")\n    private String text;\n}\n```\n\nCheck [Spring extension](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-spring) user guide for more information and examples.\n\n### With JUnit\n\n#### JUnit5\n\n```java\n@TestWithResources\nclass InjectTextResourcesTests {\n\n    @GivenTextResource(\"/io/hosuaby/junit/jupiter/resource.txt\")\n    String instanceField;\n\n    @Test\n    public void testInjectTextIntoStringInstanceField() {\n        assertThat(instanceField)\n                .isEqualTo(\"The quick brown fox jumps over the lazy dog.\");\n    }\n}\n```\n\nCheck [JUnit5 extension](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-junit-jupiter) user guide for more information and examples.\n\n#### JUnit4\n\n```java\nclass MyTestClass {\n\n    @Rule\n    public ResourceRule\u003cString\u003e textResource = givenResource()\n            .text(\"/io/hosuaby/junit/jupiter/resource.txt\")\n            .withCharset(StandardCharsets.UTF_8);\n\n    @Test\n    public void testWithTextResource() {\n        assertThat(textResource.get())\n                .isEqualTo(\"The quick brown fox jumps over the lazy dog.\");\n    }\n}\n```\n\nCheck [JUnit4 extension](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-junit-vintage) user guide for more information and examples.\n\n## Supported formats\n\n- Binary\n- Text\n- Java properties\n- JSON \u0026 JSON Lines\n- YAML \u0026 YAML Documents\n\n## News\n\n- 2024-08-16: Release `v1.0.0`. Ensure compatibility. Java: up to 22, Spring Boot: up to 3.3, JUnit Jupiter: up to 5.11,\nJackson: up to 2.17, Gson: up to 2.11, Snakeyaml: up to 2.2. :warning: Major change in package names: \n`com.adelean` -\u003e `io.hosuaby`.\n- 2023-05-28: Release `v0.3.3`. Removed dependency on deprecated InstantiationAwareBeanPostProcessorAdapter.\n- 2022-04-07: Release `v0.3.2`. Upgrade `org.reflections` to `0.10.2`.\n- 2022-03-23: Release `v0.3.1`. Limit classpath search for `TestsAdvice`s.\n- 2021-09-04: Release `v0.3.0`. Fix source compatibility (Gradle). JUnit (5/4) modules now depends on core. \nImplementation no longer relies on classpath scan to find annotations of the project.\n- 2021-05-10: Release `v0.2.2`. Use reflexions.org instead of JUnit ReflectionSupport\n- 2021-04-23: Release `v0.2.1`. Fix reflexion on annotations on JDK 1.8 \n- 2021-03-07: Release `v0.2.0`. Publish to Maven Central.\n- 2020-08-13: Release `v0.1.0`. This release includes Spring extension.\n- 2020-07-29: Release `v0.1.0-beta`. This release contains support of YAML files (Snakeyaml) and JUnit 4 extension.\n- 2020-06-20: Release `v0.1.0-alpha`. The first ever release. Contains only module `core` and JUnit 5 extension.\nSupport files in formats: binary, text, java properties and JSON.\n\n## Documentation\n\n### User guides\n- [Core](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-core),\n- [Spring extension](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-spring),\n- [JUnit5 extension](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-junit-jupiter),\n- [JUnit4 extension](https://hosuaby.github.io/inject-resources/1.0.0/asciidoc/#inject-resources-junit-vintage)\n\n### Javadoc\n\n- [Core](https://javadoc.io/doc/io.hosuaby/inject-resources-core/1.0.0),\n- [Spring extension](https://javadoc.io/doc/io.hosuaby/inject-resources-spring/1.0.0),\n- [JUnit5 extension](https://javadoc.io/doc/io.hosuaby/inject-resources-junit-jupiter/1.0.0),\n- [JUnit4 extension](https://javadoc.io/doc/io.hosuaby/inject-resources-junit-vintage/1.0.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhosuaby%2Finject-resources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhosuaby%2Finject-resources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhosuaby%2Finject-resources/lists"}