{"id":19508652,"url":"https://github.com/commit451/resourcespoet","last_synced_at":"2025-04-26T02:33:59.722Z","repository":{"id":43732066,"uuid":"65568112","full_name":"Commit451/ResourcesPoet","owner":"Commit451","description":"Kotlin API for generating Android XML Resources","archived":false,"fork":false,"pushed_at":"2024-01-22T08:10:31.000Z","size":327,"stargazers_count":111,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-04T07:04:25.542Z","etag":null,"topics":["android","automation","drawables","javapoet","kotlin","kotlinpoet","plurals","resource","strings","xml"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/Commit451.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-08-12T16:33:57.000Z","updated_at":"2024-08-31T17:54:19.000Z","dependencies_parsed_at":"2022-09-02T08:51:00.109Z","dependency_job_id":null,"html_url":"https://github.com/Commit451/ResourcesPoet","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/Commit451%2FResourcesPoet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Commit451%2FResourcesPoet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Commit451%2FResourcesPoet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Commit451%2FResourcesPoet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Commit451","download_url":"https://codeload.github.com/Commit451/ResourcesPoet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250922213,"owners_count":21508290,"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":["android","automation","drawables","javapoet","kotlin","kotlinpoet","plurals","resource","strings","xml"],"created_at":"2024-11-10T23:08:35.267Z","updated_at":"2025-04-26T02:33:59.443Z","avatar_url":"https://github.com/Commit451.png","language":"Kotlin","readme":"# ResourcePoet\nKotlin API for generating Android XML Resources\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.commit451/resourcespoet/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.commit451/resourcespoet)\n\n## Gradle\n```groovy\ndependencies {\n    implementation(\"com.commit451:resourcespoet:latest.release.here\")\n}\n```\n\n## Basic Usage\nWrite variables to the poet like:\n```kotlin\nval poet = ResourcesPoet.create()\n    .addString(\"app_name\", \"Test\")\n    .addColor(\"color_primary\", \"#FF0000\")\n    .addBool(\"is_cool\", true)\n    .addComment(\"This is a comment\")\n    .addDrawable(\"logo\", \"@drawable/logo\")\n    .addStyle(\"AppTheme.Dark\", \"Base.AppTheme.Dark\")\n    // etc\n    .indent(true)\nval xml: String = poet.build()\nprintln(xml)\n```\nwhich would output this XML:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?\u003e\n\u003cresources\u003e\n    \u003cstring name=\"app_name\"\u003eTest\u003c/string\u003e\n    \u003ccolor name=\"color_primary\"\u003e#FF0000\u003c/color\u003e\n    \u003cbool name=\"is_cool\"\u003etrue\u003c/bool\u003e\n    \u003c!--This is a comment--\u003e\n    \u003cdrawable name=\"logo\"\u003e@drawable/logo\u003c/drawable\u003e\n    \u003cstyle name=\"AppTheme.Dark\" parent=\"Base.AppTheme.Dark\"/\u003e\n\u003c/resources\u003e\n```\n\nTo get the XML result as a file:\n```kotlin\nval valuesFolder = File(resFolderPath + File.separator + \"values\")\nvaluesFolder.mkdirs()\nval configXml = File(valuesFolder, \"config.xml\")\nconfigXml.createNewFile()\npoet.build(configXml)\n```\n\nYou can even start with and modify an existing resource file:\n```kotlin\nval file = File(\"some/path/to/file\")\nval poet = ResourcesPoet.create(file)\n    .remove(Type.STRING, \"app_name\")\n    .addString(\"app_name\", \"Even Better App Name\")\n    .add(Type.BOOL, \"is_cool\", \"true\")\n```\n\n## Supported Types\nMost [resource types](https://developer.android.com/guide/topics/resources/available-resources.html) are supported. All look similar in usage:\n```kotlin\nval poet = ResourcesPoet.create()\n    .addBool(\"is_cool\", true)\n    .addColor(\"color_primary\", \"#FF0000\")\n    .addComment(\"This is a comment\")\n    .addDimension(\"margin\", \"2dp\")\n    .addDrawable(\"logo\", \"@drawable/logo\")\n    .addId(\"some_id\")\n    .addInteger(\"number\", 0)\n    .addIntegerArray(\"numbers\", numbers)\n    .addPlurals(\"songs\", plurals)\n    .addString(\"app_name\", \"Test\")\n    .addStringArray(\"stuff\", strings)\n    .addStyle(\"AppTheme.Dark\", \"Base.AppTheme.Dark\")\n    .addTypedArray(\"some_typed_array\", typedArray)\n```\nWe do not allow configuration of more complicated resources like `drawable` and `anim` in the creation sense.\n\nLicense\n--------\n\n    Copyright 2024 Commit 451\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommit451%2Fresourcespoet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommit451%2Fresourcespoet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommit451%2Fresourcespoet/lists"}