Skip to content

Commit

Permalink
Create install script and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeziellago committed Sep 7, 2020
1 parent abbe180 commit 9b6e855
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 11 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
77 changes: 66 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -25,7 +48,7 @@ object Versions {
val junit4Version = "4.12"
}
```
### Create lib files
## Create libraries files
```kotlin
object Libs {

Expand All @@ -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.
```
35 changes: 35 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9b6e855

Please # to comment.