diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f0efa80..8036369 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -28,7 +28,20 @@ jobs: with: java-version: '17' distribution: 'temurin' - - name: Build with Gradle + + - name: Ensure lint baseline present + run: | + if [ ! -f app/lint-baseline.xml ]; then + echo "::error file=app/lint-baseline.xml::Missing lint-baseline.xml (generate locally with ./gradlew lintDebug -Dlint.baselines.continue=true and commit)." + exit 1 + fi + + - name: Run Android Lint (fail on new issues) + uses: gradle/gradle-build-action@v2 + with: + arguments: lintRelease --warning-mode=all --stacktrace + + - name: Run Unit Tests uses: gradle/gradle-build-action@v2 with: - arguments: build --continue + arguments: test build --warning-mode=all --stacktrace -PcompilerArgs=-Xlint:deprecation \ No newline at end of file diff --git a/.gitignore b/.gitignore index 27b7a4e..164ba0b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,12 @@ /captures .externalNativeBuild .cxx -gradle + +/gradle/.tmp/ +/gradle/android/ +/gradle/caches/ +/gradle/daemon/ +/gradle/jdks/ +/gradle/native/ +/gradle/workers/ +/gradle/wrapper/ diff --git a/app/build.gradle b/app/build.gradle index bfd9dc7..3d3b756 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,16 +1,18 @@ -apply plugin: 'com.android.application' +plugins { + alias(libs.plugins.android.application) +} android { - compileSdk = 36 + compileSdk = libs.versions.compileSdk.get().toInteger() namespace = 'com.sshdaemon' defaultConfig { applicationId "com.daemon.ssh" - minSdkVersion 26 - targetSdkVersion 36 - versionCode 52 - versionName "2.1.34" + minSdkVersion libs.versions.minSdk.get().toInteger() + targetSdkVersion libs.versions.targetSdk.get().toInteger() + versionCode libs.versions.versionCode.get().toInteger() + versionName libs.versions.versionName.get() testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true } @@ -54,9 +56,10 @@ android { } lint { - baseline = file('lint-baseline.xml') - abortOnError = false - checkReleaseBuilds = false + baseline = file("lint-baseline.xml") + abortOnError = true + warningsAsErrors = true + checkDependencies = true } tasks.withType(JavaCompile).configureEach { @@ -64,31 +67,18 @@ android { } } -ext { - sshdVersion = '2.16.0' -} - dependencies { - api 'com.google.android.material:material:1.13.0' + api libs.android.material - implementation "org.apache.sshd:sshd-core:${sshdVersion}" - implementation "org.apache.sshd:sshd-sftp:${sshdVersion}" - implementation "org.apache.sshd:sshd-contrib:${sshdVersion}" - implementation "org.slf4j:slf4j-api:2.0.17" - implementation "org.slf4j:slf4j-log4j12:2.0.17" - implementation "org.bouncycastle:bcpkix-jdk15to18:1.82" - implementation "net.i2p.crypto:eddsa:0.3.0" + // SSH and crypto libraries using bundles + implementation libs.bundles.sshd + implementation libs.bundles.slf4j + implementation libs.bundles.crypto - testImplementation "org.junit.jupiter:junit-jupiter-api:5.13.4" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.13.4" - testImplementation "org.junit.jupiter:junit-jupiter-params:5.13.4" - testImplementation "org.junit.platform:junit-platform-launcher:1.13.4" + // Testing libraries using bundles + testImplementation libs.bundles.junit.testing + testRuntimeOnly libs.bundles.junit.runtime - testImplementation "org.hamcrest:hamcrest-all:1.3" - testImplementation "org.mockito:mockito-core:5.19.0" - testImplementation "org.mockito:mockito-junit-jupiter:5.2.0" - androidTestImplementation "androidx.test:core:1.7.0" - androidTestImplementation "androidx.test.ext:junit:1.3.0" - androidTestImplementation "androidx.test:runner:1.7.0" - androidTestImplementation "androidx.test.espresso:espresso-core:3.7.0" + // Android testing libraries using bundle + androidTestImplementation libs.bundles.androidx.testing } diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index cbe0de4..d883da3 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1,13 +1,145 @@ - + - - + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.gradle b/build.gradle index 6c76391..47ca2bb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,23 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - - repositories { - mavenCentral() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:8.13.0' - } -} - -allprojects { - repositories { - mavenCentral() - google() - } -} - tasks.register('clean', Delete) { delete rootProject.layout.buildDirectory } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..c76b16c --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,73 @@ +[versions] +# Android SDK versions +compileSdk = "36" +minSdk = "26" +targetSdk = "36" + +# App version +versionCode = "53" +versionName = "2.1.35" + +# Build tools +androidGradlePlugin = "8.13.1" + +# Core dependencies +sshd = "2.16.0" +slf4j = "2.0.17" +bouncycastle = "1.82" +eddsa = "0.3.0" + +# Android libraries +material = "1.13.0" + +# Testing libraries +junit = "6.0.1" +junitPlatform = "6.0.1" +hamcrest = "1.3" +mockito = "5.20.0" +mockitoJunitJupiter = "5.20.0" +androidxTest = "1.7.0" +androidxTestJunit = "1.3.0" +androidxTestRunner = "1.7.0" +espresso = "3.7.0" + +[libraries] + +# Android libraries +android-material = { group = "com.google.android.material", name = "material", version.ref = "material" } + +# SSH and crypto libraries +sshd-core = { group = "org.apache.sshd", name = "sshd-core", version.ref = "sshd" } +sshd-sftp = { group = "org.apache.sshd", name = "sshd-sftp", version.ref = "sshd" } +sshd-contrib = { group = "org.apache.sshd", name = "sshd-contrib", version.ref = "sshd" } +slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" } +slf4j-log4j12 = { group = "org.slf4j", name = "slf4j-log4j12", version.ref = "slf4j" } +bouncycastle-bcpkix = { group = "org.bouncycastle", name = "bcpkix-jdk15to18", version.ref = "bouncycastle" } +eddsa = { group = "net.i2p.crypto", name = "eddsa", version.ref = "eddsa" } + +# Testing libraries +junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" } +junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" } +junit-jupiter-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit" } +junit-platform-launcher = { group = "org.junit.platform", name = "junit-platform-launcher", version.ref = "junitPlatform" } +hamcrest-all = { group = "org.hamcrest", name = "hamcrest-all", version.ref = "hamcrest" } +mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" } +mockito-junit-jupiter = { group = "org.mockito", name = "mockito-junit-jupiter", version.ref = "mockitoJunitJupiter" } + +# Android testing libraries +androidx-test-core = { group = "androidx.test", name = "core", version.ref = "androidxTest" } +androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidxTestJunit" } +androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidxTestRunner" } +androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" } + +[bundles] +# Bundle related dependencies together +sshd = ["sshd-core", "sshd-sftp", "sshd-contrib"] +slf4j = ["slf4j-api", "slf4j-log4j12"] +crypto = ["bouncycastle-bcpkix", "eddsa"] +junit-testing = ["junit-jupiter-api", "junit-jupiter-params", "hamcrest-all", "mockito-core", "mockito-junit-jupiter"] +junit-runtime = ["junit-jupiter-engine", "junit-platform-launcher"] +androidx-testing = ["androidx-test-core", "androidx-test-junit", "androidx-test-runner", "androidx-test-espresso-core"] + +[plugins] +android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } diff --git a/settings.gradle b/settings.gradle index 0db858e..9cac775 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,18 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + include ':app' -rootProject.name = "SshDaemon" \ No newline at end of file +rootProject.name = "SshDaemon"