Skip to content

Commit

Permalink
Update Project to use Gradle 8.4, AGP 8.2.0, Fix Detekt Foundings, an…
Browse files Browse the repository at this point in the history
…d uses version catalog (#14)

* Update Project to use Gradle 8.4, AGP 8.2.0, and uses version catalog

* set jvmtoolchain to 11

* Revert "set jvmtoolchain to 11"

This reverts commit 35747cb.

* change the build pipeline to use java 17

* fix codesmell and update some rules on detekt
  • Loading branch information
muhrifqii committed Jan 1, 2024
1 parent 0d985e1 commit b8bd6bf
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: 'temurin'
- uses: gradle/gradle-build-action@v2
with:
Expand Down
17 changes: 6 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
plugins {
id 'com.android.application' version "${agp_version}" apply false
id 'com.android.library' version "${agp_version}" apply false
id 'org.jetbrains.kotlin.android' version "${kotlin_version}" apply false
id "io.gitlab.arturbosch.detekt" version "1.20.0-RC2"
id "com.diffplug.spotless" version "6.4.1" apply false
alias libs.plugins.android.library apply false
alias libs.plugins.android.application apply false
alias libs.plugins.kotlin.android apply false
alias libs.plugins.detekt
alias libs.plugins.spotless apply false
}
apply from: 'root-reportings.gradle'

task clean(type: Delete) {
delete rootProject.buildDir
}

detekt {
toolVersion = "1.19.0"
buildUponDefaultConfig = true
config = files("$projectDir/detekt.yml")
parallel = true
Expand All @@ -26,5 +21,5 @@ detekt {
}

dependencies {
detektPlugins('io.gitlab.arturbosch.detekt:detekt-formatting:1.20.0-RC2')
detektPlugins(libs.detekt.formatting)
}
4 changes: 4 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,9 @@ style:
max: 3
PreferToOverPairSyntax:
active: true
UnnecessaryAbstractClass:
active: true
excludes: *excludedDirs

formatting:
excludes: *excludedDirs
30 changes: 16 additions & 14 deletions fuel/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
plugins {
alias libs.plugins.android.library
alias libs.plugins.kotlin.android
}
apply from: '../reportings.gradle'

group 'com.github.muhrifqii.ParseRSS'

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

android {
compileSdkVersion compilesdk_version as int
namespace 'com.github.muhrifqii.ParseRSS'
compileSdk compilesdk_version as int
//noinspection GradleDependency
buildToolsVersion buildtools_version
defaultConfig {
minSdkVersion minsdk_version
targetSdkVersion targetsdk_version
versionCode project_version_code as int
versionName project_version
}
buildTypes {
release {
Expand All @@ -24,14 +28,12 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':parserss')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation 'com.github.kittinunf.fuel:fuel:2.3.1'
implementation libs.fuel

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.7.3'
testImplementation 'org.mockito:mockito-core:4.4.0'
testImplementation 'com.google.truth:truth:1.1.3'
testImplementation libs.junit
testImplementation libs.robolectric
testImplementation libs.mockito.core
testImplementation libs.truth
}
2 changes: 0 additions & 2 deletions fuel/src/main/AndroidManifest.xml

This file was deleted.

3 changes: 0 additions & 3 deletions fuel/src/main/res/values/strings.xml

This file was deleted.

31 changes: 5 additions & 26 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
org.gradle.jvmargs=-Xmx5g -Dfile.encoding=UTF-8
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=false
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Declare versions
agp_version=7.0.2
kotlin_version=1.6.10
compilesdk_version=31
buildtools_version=30.0.2
minsdk_version=14
targetsdk_version=31
project_version=0.6.0
project_version_code=600
compilesdk_version=34
minsdk_version=16
project_version=0.7.0
project_version_code=700
46 changes: 46 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[versions]
agp = "8.2.0"
appcompat = "1.6.1"
constraintlayout = "2.1.4"
core-ktx = "1.12.0"
detekt = "1.23.4"
espresso-core = "3.5.1"
fuel = "2.3.1"
junit = "4.13.2"
kotlin = "1.9.21"
kotlinx-coroutines-core = "1.7.3"
material = "1.11.0"
mockito-core = "5.3.1"
ktlint = "1.0.1"
ktor = "2.3.7"
retrofit = "2.9.0"
robolectric = "4.7.3"
runner = "1.5.2"
spotless = "6.23.3"
truth = "1.1.3"

[libraries]
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" }
core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso-core" }
fuel = { module = "com.github.kittinunf.fuel:fuel", version.ref = "fuel" }
junit = { module = "junit:junit", version.ref = "junit" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
material = { module = "com.google.android.material:material", version.ref = "material" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito-core" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
runner = { module = "androidx.test:runner", version.ref = "runner" }
truth = { module = "com.google.truth:truth", version.ref = "truth" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
android-lint = { id = "com.android.lint", version.ref = "agp" }
android-test = { id = "com.android.test", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
32 changes: 17 additions & 15 deletions parserss/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
plugins {
alias libs.plugins.android.library
alias libs.plugins.kotlin.android
}
apply from: '../reportings.gradle'

group 'com.github.muhrifqii.ParseRSS'

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

android {
compileSdkVersion compilesdk_version as int
compileSdk compilesdk_version as int
namespace 'com.github.muhrifqii.ParseRSS'
//noinspection GradleDependency
buildToolsVersion buildtools_version
defaultConfig {
minSdkVersion minsdk_version
targetSdkVersion targetsdk_version
versionCode project_version_code as int
versionName project_version
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.7.3'
testImplementation 'org.mockito:mockito-core:4.4.0'
testImplementation 'com.google.truth:truth:1.1.3'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1"
testImplementation libs.junit
testImplementation libs.robolectric
testImplementation libs.mockito.core
testImplementation libs.truth
testImplementation libs.kotlinx.coroutines.core
}
2 changes: 0 additions & 2 deletions parserss/src/main/AndroidManifest.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class ParserExecutor<T>(
if (element.name != RSSVersion.RSS_V1.elementName &&
element.name != RSSVersion.RSS_V2.elementName &&
element.name != RSSVersion.RSS_ATOM.elementName
) return element
) {
return element
}
val attrCount = parser.attributeCount
for (i in 0 until attrCount) {
val attribute = parser.getRSSAttributeElement(i, pullParserNSAware)
Expand Down Expand Up @@ -186,10 +188,11 @@ class ParserExecutor<T>(
ParseRSSKeyword.LINK -> mode[LinkEnabledObject::class.java] = {
val rel = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_REL) ?: ""
val href = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_HREF)
if (rel == "self" && it is RSSFeed)
if (rel == "self" && it is RSSFeed) {
it.link = href
else if (rel == "alternate" && it is RSSItem)
} else if (rel == "alternate" && it is RSSItem) {
it.link = href
}
}
ParseRSSKeyword.RIGHTS -> mode[CopyrightsEnabledObject::class.java] = {
it?.copyright = parser.nextTextTrimmed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ sealed class ParsingMode(val nameToken: String) : ParsingModeOperation {
is Read -> return
is MediaNS.Group -> {
val item = modes.lastValue()
if (item !is Item) throw ParseRSSException(
"Error ${other.nameToken} should be under the item element",
)
if (item !is Item) {
throw ParseRSSException(
"Error ${other.nameToken} should be under the item element",
)
}
other.rssObject = item.rssObject
}
is Author -> {
Expand Down
31 changes: 17 additions & 14 deletions retrofit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
plugins {
alias libs.plugins.android.library
alias libs.plugins.kotlin.android
}
apply from: '../reportings.gradle'

group 'com.github.muhrifqii.ParseRSS'

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

android {
compileSdkVersion compilesdk_version as int
namespace 'com.github.muhrifqii.ParseRSS'
compileSdk compilesdk_version as int
//noinspection GradleDependency
buildToolsVersion buildtools_version
defaultConfig {
minSdkVersion minsdk_version
targetSdkVersion targetsdk_version
versionCode project_version_code as int
versionName project_version
}
buildTypes {
release {
Expand All @@ -23,14 +28,12 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':parserss')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation libs.retrofit

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.7.3'
testImplementation 'org.mockito:mockito-core:4.4.0'
testImplementation 'com.google.truth:truth:1.1.3'
testImplementation libs.junit
testImplementation libs.robolectric
testImplementation libs.mockito.core
testImplementation libs.truth
}
2 changes: 0 additions & 2 deletions retrofit/src/main/AndroidManifest.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ParseRSSConverterFactory<R : RSSFeed> private constructor() : Converter.Fa
annotations: Array<Annotation>,
retrofit: Retrofit
): Converter<ResponseBody, *> {

return ParseRSSConverter<R>()
}

Expand Down
8 changes: 4 additions & 4 deletions root-reportings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: 'jacoco'

jacoco {
toolVersion '0.8.7'
}
//jacoco {
// toolVersion '0.8.7'
//}

tasks.withType(Test) {
tasks.withType(Test).configureEach {
jacoco.includeNoLocationClasses = true
}

Expand Down
Loading

0 comments on commit b8bd6bf

Please sign in to comment.