{"id":13604888,"url":"https://github.com/zsoltk/paperwork","last_synced_at":"2025-04-12T02:32:08.475Z","repository":{"id":41374523,"uuid":"48524181","full_name":"zsoltk/paperwork","owner":"zsoltk","description":"Generate build info for your Android project without breaking incremental compilation","archived":false,"fork":false,"pushed_at":"2016-03-04T17:41:34.000Z","size":176,"stargazers_count":358,"open_issues_count":4,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-02T19:36:36.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/zsoltk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-24T04:07:16.000Z","updated_at":"2024-07-22T17:34:26.000Z","dependencies_parsed_at":"2022-08-31T22:41:38.288Z","dependency_job_id":null,"html_url":"https://github.com/zsoltk/paperwork","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsoltk%2Fpaperwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsoltk%2Fpaperwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsoltk%2Fpaperwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsoltk%2Fpaperwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zsoltk","download_url":"https://codeload.github.com/zsoltk/paperwork/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223489691,"owners_count":17153805,"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-08-01T19:00:52.363Z","updated_at":"2024-11-07T09:31:12.067Z","avatar_url":"https://github.com/zsoltk.png","language":"Java","funding_links":[],"categories":["Gradle","Java"],"sub_categories":["Mock"],"readme":"# Paperwork\n[![Build Status](https://travis-ci.org/zsoltk/paperwork.svg?branch=master)](https://travis-ci.org/zsoltk/paperwork)\n\nGenerate build info for your Android project without breaking incremental compilation\n\n### The problem\nA common use case is that you want to include the git hash of the last commit and build time into your project, so that you can use their values in your crash reporting tool (for example).\n\nThe easiest way to do this is to generate them into your ```BuildConfig``` by adding these to your ```build.gradle```\n\n```groovy\ndef gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()\ndef buildTime = new Date().format(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", TimeZone.getTimeZone(\"UTC\"))\n\nandroid {\n    defaultConfig {\n        buildConfigField \"String\", \"GIT_SHA\", \"\\\"${gitSha}\\\"\"\n        buildConfigField \"String\", \"BUILD_TIME\", \"\\\"${buildTime}\\\"\"\n    }\n}\n```\n\nBut this will break incremental builds, resulting in increased build times all the time.\n\n\n### What this lib offers\nPaperwork can generate this information (and more) for you, and put it into a ```paperwork.json``` file inside your assets folder instead of using ```BuildConfig```, and helps you read it from there:\n\n```java\nPaperwork paperwork = new Paperwork(context);\nString gitSha = paperwork.get(\"gitSha\");\nString buildTime = paperwork.get(\"buildTime\");\n```\n\nNot just git hash, not just build time: you define what gets generated, and you can use anything that otherwise would break incremental builds.\n\nMany helpers are available for the most common scenarios. See the configuration below.\n\n### Build time comparison\nMeasured three consecutive builds per type, running gradle daemon, hitting \"Run 'app'\" in Android Studio without touching anything else. Generated info: git hash and build time (using seconds) so that it has a new value every time.\n\n* Without generating build info: *3.989s*, *3.915s*, *3.902s*\n* Using BuildConfig fields: *14.843s*, *13.844s*, *13.194s*\n* Using Paperwork: *4.356s*, *4.075s*, *4.042s*\n\n### Download and setup\nAdd these dependencies to your ```build.gradle```:\n\n```groovy\nbuildscript {\n    repositories {\n        mavenCentral()\n    }\n\n    dependencies {\n        classpath 'hu.supercluster:paperwork-plugin:1.2.7'\n    }\n}\n\napply plugin: 'hu.supercluster.paperwork'\n\npaperwork {\n    // Configuration comes here, see next section for details\n}\n\ndependencies {\n    compile 'hu.supercluster:paperwork:1.2.7'\n}\n```\n\nLastly, don't forget to add ```paperwork.json``` to your ```.gitignore``` file.\n\n### Configuration\nPaperwork doesn't generate anything by default, you have to define whatever data you need in simple key-value pairings. For a list of helper methods you can use, see next section.\n\n```groovy\npaperwork {\n    set = [\n        someKey1: \"someValue\",\n        someKey2: someHelperMethod()\n    ]\n}\n```\n\nAll the data will be available at runtime by querying for your own defined keys:\n\n```java\nPaperwork paperwork = new Paperwork(context);\nString data1 = paperwork.get(\"someKey1\");        // will return \"someValue\"\nString data1 = paperwork.get(\"someKey2\");        // will return the result of someHelperMethod()\n```\n\nYou can also change the default filename or generate the file somewhere else:\n\n```groovy\npaperwork {\n    filename = 'src/main/assets/paperwork.json'\n}\n```\n\nNote however, that in order for it to be available in Paperwork runtime,\nit has to be in the assets folder, and if the filename is not\npaperwork.json, you have to inject its name in the constructor:\n\n```java\nPaperwork paperwork = new Paperwork(context, \"paperwork.json\");\n```\n\n\n### Helpers\n\n```groovy\nbuildTime()\n```\nSimple unix timestamp (ms)\n\n\n```groovy\nbuildTime(\"yyyy-MM-dd HH:mm:ss\")\n```\nFormatted date string\n\n\n```groovy\nbuildTime(\"yyyy-MM-dd HH:mm:ss\", \"GMT\")\n```\nFormatted date string for a given timezone\n\n\n```groovy\ngitSha()\n```\nThe current git SHA\n\n\n```groovy\ngitTag()\n```\nThe last git tag (lightweight tags included)\n\n\n```groovy\ngitInfo()\n```\nRuns ```git describe --tags --always --dirty```. Returns a result like \"v2.1.0-71-gb88c59a-dirty\"\n(The last tag + how many commits ahead of that tag are we now in the working tree + current hash + whether the working tree has uncommited changes)\n\n\n```groovy\ngitBranch()\n```\nThe current git branch\n\n```groovy\nshell(\"scripts/test.sh\")\n```\nRuns a shell command and returns its output (doesn't have to be a script)\n\n\n```groovy\nenv(\"SOME_ENV\")\n```\nReturns the value of an environment variable\n\n\n### Contributing\n\nContributions are welcome! Got a question, found a bug, have a new helper method idea? Submit an issue and discuss it!\n\nI'd love to hear about your use case too, especially if it's not covered perfectly.\n\n\n### License\n\n    Copyright 2015 Zsolt Kocsi\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsoltk%2Fpaperwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzsoltk%2Fpaperwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsoltk%2Fpaperwork/lists"}