Skip to content

Commit

Permalink
Configure artifact publish
Browse files Browse the repository at this point in the history
  • Loading branch information
jeziellago committed May 19, 2020
1 parent 2c58482 commit 89620ab
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 20 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ Warning on new versions available even when using Kotlin-DSL plugin.

![](example.png)

## How to use?
- Add lint dependency
```groovy
dependencies {
lintChecks "com.picpay.gradlelint:version-checker:VERSION"
}
```
- Enable lint with `lintOptions`
```groovy
lintOptions {
enable "VersionCheckerGradleLint"
}
```

## `buildSrc` module with kotlin-dsl plugin
- `buildSrc/src/main/java/Dependencies.kt`
```kotlin
Expand All @@ -24,13 +38,4 @@ object TestLibs {

val junit4 = "junit:junit:${Versions.junit4Version}"
}
```

## How install?
- Copy latest release `.jar` to `${USER_DIR}/.android/lint/`
- Enable lint with `lintOptions`
```groovy
lintOptions {
enable "VersionCheckerGradleLint"
}
```
9 changes: 0 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
Expand Down Expand Up @@ -30,17 +28,10 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation Libs.appCompat
implementation Libs.retrofit
implementation Libs.playServiceLocation
implementation Libs.koinCore
implementation Libs.mpchart
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation TestLibs.junit
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.71'
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
Expand Down
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

# Info to Maven Publish
library.version=0.1.0
library.groupId=com.picpay.gradlelint
library.artifactId=version-checker
library.repository=version-checker-gradle-lint
34 changes: 34 additions & 0 deletions lintversioncheck/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import java.text.SimpleDateFormat
import java.util.Date

plugins {
id("java-library")
id("kotlin")
id("jacoco")
id("maven-publish")
}

repositories {
Expand Down Expand Up @@ -54,3 +58,33 @@ tasks {
executionData.from("$buildDir/jacoco/test.exec")
}
}

publishing {
publications {
register("publishArtifact", MavenPublication::class) {
from(components["java"])
groupId = project.findProperty("library.groupId") as String
artifactId = project.findProperty("library.artifactId") as String
version = (project.findProperty("library.version") as String) + versionSuffix()
}
}
repositories {
maven {
name = "GitHubPackages"
val repository = project.findProperty("library.repository")
url = uri("https://maven.pkg.github.com/PicPay/$repository")
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_USER_TOKEN")
}
}
}
}

fun versionSuffix(): String {
val sufix = System.getenv("VERSION_SUFIX").orEmpty()
if (sufix.isNotEmpty()) {
return "$sufix-${SimpleDateFormat("yyyyMMddHHmmss").format(Date())}"
}
return sufix
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ class VersionCheckerGradleLint : Detector(), Detector.GradleScanner {
val linesFromDependencyFile = getDependenciesFileLines(
dependenciesFile = File(
getBuildSrcDir(context.project.dir).absolutePath,
"src/main/java/$dependenciesFileName.kt"
"src${File.separator}" +
"main${File.separator}" +
"java${File.separator}" +
"$dependenciesFileName.kt"
)
)

Expand Down

0 comments on commit 89620ab

Please sign in to comment.