diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..3550e0e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 PicPay + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 62e4c71..8ad8e3c 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,43 @@ Warning on new versions available even when using Kotlin-DSL plugin. ![](example.png) -## How to use? -- Add lint dependency: -> copy `version-checker.jar` to `HOME/.android/lint/` +This detector checks with a central repository to see if there are newer versions available for the dependencies used by your project. +This is similar to the `GradleDependency` check, which checks for newer versions available. This works with any Google, MavenCentral, JCenter, or Jitpack dependency, and connects to the remote library if the reference does not exist in the local cache. The cache lifetime default is 60 minutes but can be modified in `versionlint.properties` into `buildSrc` module. -- Enable/Disable lint with `lintOptions` (default: `enabled`) -```groovy -lintOptions { - enable "VersionCheckerGradleLint" -} +## Install + +Run script [install.sh](https://github.com/PicPay/version-checker-gradle-lint/blob/master/install.sh): +> bash install.sh + +Or [copy manually](https://github.com/PicPay/version-checker-gradle-lint/releases/latest) `version-checker.jar` to `$HOME/.android/lint/` + +## Configuration: _buildSrc/versionlint.properties_: + +#### Default values +``` +versionlint.cache.time.minutes=60 +versionlint.prerelease.enable=false +versionlint.versions.file=Versions +versionlint.dependencies.suffix=Libs ``` -## `buildSrc` module with kotlin-dsl plugin +- Cache +> `versionlint.cache.time.minutes=60` + +- Versions file name: +> `versionlint.versions.file=Versions` + +- Suffix for libraries declaration files: +> `versionlint.dependencies.suffix=Libs` + +You can create files with this suffix. +> Examples: `Libs`, `AndroidLibs`, `TestLibs`, etc. + +- Enables find release candidates (alpha, beta, rc): +> `versionlint.prerelease.enable=false` + -### Create `version` file +## Create your _version_ file ```kotlin object Versions { @@ -25,7 +48,7 @@ object Versions { val junit4Version = "4.12" } ``` -### Create lib files +## Create libraries files ```kotlin object Libs { @@ -45,4 +68,36 @@ object OtherLibs { val myLib = "mylib:mylib:${Versions.myLib}" } +``` + +## Enable/Disable lint with `lintOptions` (default: `enabled`) +```groovy +lintOptions { + enable "VersionCheckerGradleLint" +} +``` + +## License +``` +MIT License + +Copyright (c) 2020 PicPay + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. ``` \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..2862de4 --- /dev/null +++ b/install.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +version_checker_file="version-checker.jar" +install_dir="${HOME}/.android/lint" +latest_url=https://api.github.com/repos/PicPay/version-checker-gradle-lint/releases/latest + +function request_github() { + url=$1 + response=$(curl -s $latest_url | grep browser_download_url | sed 's/"//g' | \ + awk '{split($0,a,": "); print a[2]}') + echo "${response}" +} + +function download_jar() { + output=$1 + url_to_download=$2 + curl -sLo ${output} -H "Accept: application/octet-stream" "${url_to_download}" +} + +function install_version_checker_lint() { + mkdir ${install_dir} + printf "Installing Version Checker Gradle Lint\n" + + asset_url=$(request_github) + + jar_url=$(request_github "${asset_url}") + + download_jar ${version_checker_file} "${jar_url}" + + mv ${version_checker_file} ${install_dir} + + printf "Version Checker Gradle Lint installed.\n" +} + +install_version_checker_lint