Skip to content

Commit 0661fe5

Browse files
authored
Add support for Android Gradle Plugin 7.+. Upgrade dependencies and publishing mechanics (#51)
1 parent afe1383 commit 0661fe5

File tree

8 files changed

+129
-44
lines changed

8 files changed

+129
-44
lines changed

.idea/.name

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
### Security
3535
- No security issues fixed!
3636

37+
## [3.0.0] - 2022-02-03
38+
### Changed
39+
- BREAKING: Update dependencies to work with Android Gradle Plugin 7.+. This will break compatibility with
40+
projects that use versions lower than 7.0
41+
3742
## [2.4.2] - 2021-10-17
3843
### Changed
3944
- Change detekt rules according to library update to version 1.18.1
4045
### Removed
41-
- Remove `jcenter()` from project.
46+
- Remove `jcenter()` from project
4247

4348
## [2.4.1] - 2021-09-16
4449
### Fixed
@@ -406,7 +411,8 @@ res_dir_path -> resDirPath
406411
### Added
407412
- Initial release.
408413

409-
[Unreleased]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.4.2...HEAD
414+
[Unreleased]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/3.0.0...HEAD
415+
[3.0.0]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.4.2...3.0.0
410416
[2.4.2]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.4.1...2.4.2
411417
[2.4.1]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.4.0...2.4.1
412418
[2.4.0]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.3.0...2.4.0

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Simple plug-in that eases importing [PoEditor](https://poeditor.com) localized s
77
This plug-in super-charges your Android project by providing tasks to download your localized strings from the PoEditor service into you Android project.
88
It also provides a built-in syntax to handle placeholders to enhance the already awesome Android support from PoEditor.
99

10+
## Minimum requirements
11+
* Android Gradle Plug-in 7.0 or above
12+
1013
## Setting Up
1114
In your main `build.gradle`, add [jitpack.io](https://jitpack.io/) repository in the `buildscript` block and include the plug-in as a dependency:
1215

build.gradle.kts

Lines changed: 75 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
group = "com.github.hyperdevs-team"
20-
2119
buildscript {
2220
repositories {
2321
mavenCentral()
@@ -30,16 +28,17 @@ buildscript {
3028
}
3129

3230
dependencies {
33-
classpath(kotlin("gradle-plugin", version = "1.4.20"))
31+
classpath(libs.kotlin.gradle)
3432
}
3533
}
3634

3735
plugins {
3836
`java-gradle-plugin`
3937
`kotlin-dsl`
4038
groovy
41-
maven
42-
id("io.gitlab.arturbosch.detekt").version("1.18.1")
39+
`maven-publish`
40+
alias(libs.plugins.detekt)
41+
alias(libs.plugins.gitVersionGradle)
4342
}
4443

4544
repositories {
@@ -55,40 +54,46 @@ repositories {
5554
dependencies {
5655
implementation(localGroovy())
5756

58-
compileOnly("com.android.tools.build:gradle:4.2.0")
59-
60-
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.20")
61-
62-
implementation("com.squareup.moshi:moshi:1.12.0")
63-
implementation("com.squareup.moshi:moshi-kotlin:1.12.0")
64-
implementation("com.squareup.moshi:moshi-adapters:1.12.0")
65-
66-
implementation("com.squareup.retrofit2:retrofit:2.9.0")
67-
implementation("com.squareup.retrofit2:converter-moshi:2.9.0")
57+
compileOnly(libs.android.buildTools)
6858

69-
implementation("com.squareup.okhttp3:logging-interceptor:4.9.1")
70-
implementation("com.squareup.okhttp3:okhttp:4.9.1")
71-
72-
implementation("io.github.cdimascio:dotenv-kotlin:6.2.2")
59+
implementation(libs.kotlin.stdlib)
60+
implementation(libs.bundles.moshi)
61+
implementation(libs.bundles.retrofit)
62+
implementation(libs.bundles.okhttp3)
63+
implementation(libs.dotenvKotlin)
7364

7465
testImplementation(gradleTestKit())
7566
testImplementation(kotlin("test"))
76-
testImplementation("junit:junit:4.13.2")
67+
testImplementation(libs.junit)
7768

78-
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.18.1")
69+
detektPlugins(libs.detekt.formatting)
7970
}
8071

8172
java {
8273
sourceCompatibility = JavaVersion.VERSION_1_8
8374
targetCompatibility = JavaVersion.VERSION_1_8
75+
76+
withJavadocJar()
77+
withSourcesJar()
78+
}
79+
80+
tasks.javadoc {
81+
if (JavaVersion.current().isJava9Compatible) {
82+
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
83+
}
8484
}
8585

8686
detekt {
87-
toolVersion = "1.18.1"
87+
toolVersion = libs.versions.detekt.get()
8888
config = files("${project.rootDir}/config/detekt.yml")
8989
autoCorrect = true
9090
}
9191

92+
androidGitVersion {
93+
codeFormat = "MMNNPP"
94+
format = "%tag%"
95+
}
96+
9297
tasks {
9398
test {
9499
useJUnit()
@@ -110,21 +115,54 @@ tasks {
110115
// Install hooks automatically before building a new compilation
111116
// Idea from: https://gist.github.com/KenVanHoeylandt/c7a928426bce83ffab400ab1fd99054a
112117
getByPath("compileKotlin").dependsOn(installGitHooks)
118+
}
113119

114-
val sourcesJar by creating(Jar::class) {
115-
dependsOn(JavaPlugin.CLASSES_TASK_NAME)
116-
archiveClassifier.set("sources")
117-
from(sourceSets["main"].allSource)
118-
}
119-
120-
val javadocJar by creating(Jar::class) {
121-
val javadoc by tasks
122-
from(javadoc)
123-
archiveClassifier.set("javadoc")
124-
}
125-
126-
artifacts {
127-
add("archives", sourcesJar)
128-
add("archives", javadocJar)
120+
group = "com.github.hyperdevs-team"
121+
version = androidGitVersion.name()
122+
123+
publishing {
124+
publications {
125+
// Edit the `pluginMaven` publication, which is the name for the default publication task of the `java-gradle-plugin`
126+
register<MavenPublication>("pluginMaven") {
127+
groupId = "com.github.hyperdevs-team"
128+
artifactId = "poeditor-android-gradle-plugin"
129+
130+
pom {
131+
name.set("PoEditor Android Gradle Plug-in")
132+
description.set("Gradle plug-in that enables importing PoEditor localized strings directly to an Android project")
133+
url.set("https://github.com/hyperdevs-team/poeditor-android-gradle-plugin")
134+
version = androidGitVersion.name()
135+
inceptionYear.set("2016")
136+
137+
licenses {
138+
license {
139+
name.set("The Apache License, Version 2.0")
140+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
141+
}
142+
}
143+
144+
developers {
145+
developer {
146+
name.set("Iván Martínez")
147+
id.set("imartinez")
148+
url.set("https://github.com/imartinez")
149+
roles.set(listOf("Initial work"))
150+
}
151+
152+
developer {
153+
name.set("Adrián García")
154+
id.set("adriangl")
155+
url.set("https://github.com/adriangl")
156+
roles.set(listOf("Maintainer"))
157+
158+
organization {
159+
name.set("HyperDevs")
160+
id.set("hyperdevs-team")
161+
url.set("https://github.com/hyperdevs-team")
162+
}
163+
}
164+
}
165+
}
166+
}
129167
}
130168
}

gradle/libs.versions.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[versions]
2+
kotlin = "1.6.10"
3+
detekt = "1.19.0"
4+
moshi = "1.12.0"
5+
retrofit = "2.9.0"
6+
okhttp = "4.9.3"
7+
8+
[libraries]
9+
android-buildTools = "com.android.tools.build:gradle:7.1.0"
10+
11+
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
12+
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
13+
14+
moshi = { group = "com.squareup.moshi", name = "moshi", version.ref = "moshi"}
15+
moshi-kotlin = { group = "com.squareup.moshi", name = "moshi-kotlin", version.ref = "moshi"}
16+
moshi-adapters = { group = "com.squareup.moshi", name = "moshi-adapters", version.ref = "moshi"}
17+
18+
retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit"}
19+
retrofit-converterMoshi = { group = "com.squareup.retrofit2", name = "converter-moshi", version.ref = "retrofit"}
20+
21+
okhttp3 = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp"}
22+
okhttp3-loggingInterceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp"}
23+
24+
dotenvKotlin = "io.github.cdimascio:dotenv-kotlin:6.2.2"
25+
26+
junit = "junit:junit:4.13.2"
27+
28+
detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt"}
29+
30+
[plugins]
31+
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
32+
gitVersionGradle = { id = "com.gladed.androidgitversion", version = "0.4.14"}
33+
34+
[bundles]
35+
moshi = ["moshi", "moshi-kotlin", "moshi-adapters"]
36+
retrofit = ["retrofit", "retrofit-converterMoshi"]
37+
okhttp3 = ["okhttp3", "okhttp3-loggingInterceptor"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

settings.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
rootProject.name = "poeditor"
19+
enableFeaturePreview("VERSION_CATALOGS")
20+
21+
rootProject.name = "poeditor-android-gradle-plugin"

src/main/kotlin/com/hyperdevs/poeditor/gradle/PoEditorPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
package com.hyperdevs.poeditor.gradle
2020

21-
import com.android.build.api.extension.ApplicationAndroidComponentsExtension
22-
import com.android.build.api.extension.LibraryAndroidComponentsExtension
21+
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
22+
import com.android.build.api.variant.LibraryAndroidComponentsExtension
2323
import com.android.build.gradle.AppPlugin
2424
import com.android.build.gradle.LibraryExtension
2525
import com.android.build.gradle.LibraryPlugin

0 commit comments

Comments
 (0)