Skip to content

Commit 89620ab

Browse files
committed
Configure artifact publish
1 parent 2c58482 commit 89620ab

File tree

6 files changed

+59
-20
lines changed

6 files changed

+59
-20
lines changed

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ Warning on new versions available even when using Kotlin-DSL plugin.
33

44
![](example.png)
55

6+
## How to use?
7+
- Add lint dependency
8+
```groovy
9+
dependencies {
10+
lintChecks "com.picpay.gradlelint:version-checker:VERSION"
11+
}
12+
```
13+
- Enable lint with `lintOptions`
14+
```groovy
15+
lintOptions {
16+
enable "VersionCheckerGradleLint"
17+
}
18+
```
19+
620
## `buildSrc` module with kotlin-dsl plugin
721
- `buildSrc/src/main/java/Dependencies.kt`
822
```kotlin
@@ -24,13 +38,4 @@ object TestLibs {
2438

2539
val junit4 = "junit:junit:${Versions.junit4Version}"
2640
}
27-
```
28-
29-
## How install?
30-
- Copy latest release `.jar` to `${USER_DIR}/.android/lint/`
31-
- Enable lint with `lintOptions`
32-
```groovy
33-
lintOptions {
34-
enable "VersionCheckerGradleLint"
35-
}
3641
```

app/build.gradle

-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
42

53
android {
64
compileSdkVersion 29
@@ -30,17 +28,10 @@ android {
3028
}
3129

3230
dependencies {
33-
implementation fileTree(dir: 'libs', include: ['*.jar'])
34-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3531
implementation Libs.appCompat
3632
implementation Libs.retrofit
3733
implementation Libs.playServiceLocation
3834
implementation Libs.koinCore
3935
implementation Libs.mpchart
40-
implementation 'androidx.core:core-ktx:1.2.0'
41-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
4236
testImplementation TestLibs.junit
43-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
44-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
45-
4637
}

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.71'
4+
ext.kotlin_version = '1.3.72'
55
repositories {
66
google()
77
jcenter()

gradle.properties

+6
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ android.useAndroidX=true
1919
android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
2121
kotlin.code.style=official
22+
23+
# Info to Maven Publish
24+
library.version=0.1.0
25+
library.groupId=com.picpay.gradlelint
26+
library.artifactId=version-checker
27+
library.repository=version-checker-gradle-lint

lintversioncheck/build.gradle.kts

+34
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import java.text.SimpleDateFormat
2+
import java.util.Date
3+
14
plugins {
25
id("java-library")
36
id("kotlin")
47
id("jacoco")
8+
id("maven-publish")
59
}
610

711
repositories {
@@ -54,3 +58,33 @@ tasks {
5458
executionData.from("$buildDir/jacoco/test.exec")
5559
}
5660
}
61+
62+
publishing {
63+
publications {
64+
register("publishArtifact", MavenPublication::class) {
65+
from(components["java"])
66+
groupId = project.findProperty("library.groupId") as String
67+
artifactId = project.findProperty("library.artifactId") as String
68+
version = (project.findProperty("library.version") as String) + versionSuffix()
69+
}
70+
}
71+
repositories {
72+
maven {
73+
name = "GitHubPackages"
74+
val repository = project.findProperty("library.repository")
75+
url = uri("https://maven.pkg.github.com/PicPay/$repository")
76+
credentials {
77+
username = System.getenv("GITHUB_USER")
78+
password = System.getenv("GITHUB_USER_TOKEN")
79+
}
80+
}
81+
}
82+
}
83+
84+
fun versionSuffix(): String {
85+
val sufix = System.getenv("VERSION_SUFIX").orEmpty()
86+
if (sufix.isNotEmpty()) {
87+
return "$sufix-${SimpleDateFormat("yyyyMMddHHmmss").format(Date())}"
88+
}
89+
return sufix
90+
}

lintversioncheck/src/main/java/com/picpay/gradlelint/versioncheck/VersionCheckerGradleLint.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ class VersionCheckerGradleLint : Detector(), Detector.GradleScanner {
8787
val linesFromDependencyFile = getDependenciesFileLines(
8888
dependenciesFile = File(
8989
getBuildSrcDir(context.project.dir).absolutePath,
90-
"src/main/java/$dependenciesFileName.kt"
90+
"src${File.separator}" +
91+
"main${File.separator}" +
92+
"java${File.separator}" +
93+
"$dependenciesFileName.kt"
9194
)
9295
)
9396

0 commit comments

Comments
 (0)