Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle, checkstyle and fix errors, introduce Gradle version catalog #20

Merged
merged 10 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply from: file("${rootDir}/gradle/artifact-settings.gradle")

buildscript {
apply from: "${rootDir}/gradle/dependencies.gradle"

repositories {
maven { url 'https://plugins.gradle.org/m2' }
google()
mavenCentral()
jcenter()
}
}

dependencies {
// Adding CheckStyle dependency without having to declare specific version explicitly here.
dependencies.create(pluginDependencies.checkstyle) {
transitive = false
}

classpath pluginDependencies.jacoco
classpath pluginDependencies.gradleNexus
}
plugins {
alias libs.plugins.gradle.nexus
}

apply from: file("${rootDir}/gradle/artifact-settings.gradle")


tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs += ['-Xlint:all', '-Xlint:unchecked']
}

subprojects {
apply from: "${rootDir}/gradle/dependencies.gradle"
apply plugin: 'java'
apply plugin: 'idea'
apply from: "${rootDir}/gradle/checkstyle.gradle"

// Fixes issue with test resources not being found inside Intellij
idea {
Expand All @@ -45,14 +36,13 @@ subprojects {
repositories {
google()
mavenCentral()
jcenter()
}

dependencies {
// Test Dependencies
testImplementation dependenciesList.junit
testImplementation dependenciesList.hamcrestJunit
testImplementation dependenciesList.mockito
testImplementation libs.junit
testImplementation libs.hamcrestJunit
testImplementation libs.mockito
}
}

Expand Down
38 changes: 17 additions & 21 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
<!-- 100 char per line max, unless unavoidable -->
<module name="LineLength">
<property name="max" value="100"/>
<property name="ignorePattern"
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<property name="fileExtensions" value="java, properties, xml"/>

<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppressions.xml"/>
<property name="file" value="${config_loc}/suppressions.xml"/>
<property name="optional" value="false"/>
</module>

Expand Down Expand Up @@ -134,7 +141,7 @@
-->
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<property name="format" value="^[a-z][a-zA-Z0-9][a-zA-Z0-9]*$"/>
<property name="allowOneCharVarInForLoop" value="true"/>
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must be at least two characters long."/>
Expand Down Expand Up @@ -190,10 +197,10 @@
imports. Within these groups (separated by an empty line), imports should
be lexicographially sorted with no further subcategorization required.
-->
<module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="false"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
</module>
<!-- <module name="CustomImportOrder">-->
<!-- <property name="sortImportsInGroupAlphabetically" value="false"/>-->
<!-- <property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>-->
<!-- </module>-->

<!-- Forbid imports from sun.* -->
<module name="IllegalImport"/>
Expand Down Expand Up @@ -351,13 +358,6 @@
-->
<module name="CommentsIndentation"/>

<!-- 100 char per line max, unless unavoidable -->
<module name="LineLength">
<property name="max" value="100"/>
<property name="ignorePattern"
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<!-- Checks for the placement of left curly braces ('{') for code blocks. -->
<module name="LeftCurly"/>

Expand All @@ -384,16 +384,15 @@
<!--################ JAVADOC CHECKS ################-->
<!--################################################-->

<module name="MissingJavadocMethodCheck">
<property name="allowMissingPropertyJavadoc" value="true"/>
</module>

<!--
Require Javadoc for public methods:
https://source.android.com/source/code-style.html#use-javadoc-standard-comments
-->
<module name="JavadocMethod">
<property name="scope" value="public"/>

<!-- exception: property methods (getX, setX, isX) -->
<property name="allowMissingPropertyJavadoc" value="true"/>

<!-- exception: method overrides, test methods -->
<property name="allowedAnnotations" value="Override, Test, Before, After"/>

Expand All @@ -406,8 +405,6 @@
descriptions.
-->
<property name="allowMissingReturnTag" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="suppressLoadErrors" value="true"/>
</module>

<!-- Javadoc required for public fields (part of API) -->
Expand Down Expand Up @@ -522,7 +519,6 @@
<module name="OverloadMethodsDeclarationOrder"/>

<!-- Require variables to be declared close to where they are used -->
<module name="VariableDeclarationUsageDistance"/>

<!-- Require that equals() and hashCode() are overridden together -->
<module name="EqualsHashCode"/>
Expand Down
7 changes: 7 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@
<suppress checks="MagicNumber" files="[\\/]TurfHelpers.java$"/>
<suppress checks="MagicNumber" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="WriteTag" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="MissingJavadocMethod" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="LineLength" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="JavadocVariable" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="JavadocMethod" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="OperatorWrap" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="JavadocPackage" files=".*[\\/]src[\\/](test|it)[\\/]"/>

</suppressions>
2 changes: 1 addition & 1 deletion gradle/checkstyle.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'checkstyle'

checkstyle.toolVersion = '7.8.2'
checkstyle.toolVersion = '10.15.0'
checkstyle.configFile = rootProject.file('config/checkstyle/checkstyle.xml')
checkstyleMain.exclude '**/BuildConfig.java'

Expand Down
36 changes: 0 additions & 36 deletions gradle/dependencies.gradle

This file was deleted.

5 changes: 2 additions & 3 deletions gradle/jacoco.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apply plugin: 'jacoco'

jacoco {
toolVersion = pluginVersion.jacoco
}

jacocoTestReport{
Expand All @@ -10,7 +9,7 @@ jacocoTestReport{
description = 'Generates a test coverage report for a project'

reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
}
20 changes: 20 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[versions]
junit = "4.12"
hamcrestJunit = "2.0.0.0"
mockito = "2.28.2"
supportAnnotation = "1.0.0"
okhttp3Mockwebserver = "3.12.7"
gson = "2.8.6"

gradleNexus = "1.1.0"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
hamcrestJunit = { group = "org.hamcrest", name = "hamcrest-junit", version.ref = "hamcrestJunit" }
mockito = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
supportAnnotation = { group = "androidx.annotation", name = "annotation", version.ref = "supportAnnotation" }
okhttp3Mockwebserver = { group = "com.squareup.okhttp3", name = "mockwebserver", version.ref = "okhttp3Mockwebserver" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }

[plugins]
gradle-nexus = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradleNexus" }
4 changes: 2 additions & 2 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ afterEvaluate {
project.logger.info("Publishing project with version: ${versionName}")

artifact sourcesJar {
classifier "sources"
archiveClassifier.set("sources")
}

artifact javadocJar {
classifier "javadoc"
archiveClassifier.set("javadoc")
}

pom {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading