Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3dac4867 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

build: introduce data, domain and ui modules

parent 288c1b53
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8,3 +8,6 @@
.externalNativeBuild
.cxx
local.properties
data/build
domain/build
ui/build
+44 −13
Original line number Diff line number Diff line
@@ -161,26 +161,53 @@ android.applicationVariants.configureEach { variant ->
            html.required = true
        }

        def javaClasses = fileTree("${buildDir}/intermediates/javac/${variant.name}/classes") {
        def moduleProjects = [
                project(":app"),
                project(":data"),
                project(":domain"),
                project(":ui")
        ]

        moduleProjects.each { moduleProject ->
            def moduleTestTask = moduleProject.tasks.findByName(unitTestTaskName)
            if (moduleTestTask != null) {
                dependsOn(moduleTestTask)
            }
        }

        def classTrees = moduleProjects.collectMany { moduleProject ->
            def javaClasses = fileTree("${moduleProject.buildDir}/intermediates/javac/${variant.name}/classes") {
                exclude jacocoFileFilter
            }
        def kotlinClasses = fileTree("${buildDir}/tmp/kotlin-classes/${variant.name}") {
            def kotlinClasses = fileTree("${moduleProject.buildDir}/tmp/kotlin-classes/${variant.name}") {
                exclude jacocoFileFilter
            }
            [javaClasses, kotlinClasses]
        }

        classDirectories.from = files(javaClasses, kotlinClasses)
        classDirectories.from = files(classTrees)

        def sourceDirs = variant.sourceSets.collect { sourceSet ->
        def sourceDirs = moduleProjects.collectMany { moduleProject ->
            def androidExtension = moduleProject.extensions.findByName("android")
            if (androidExtension == null) {
                return []
            }
            androidExtension.sourceSets.collectMany { sourceSet ->
                def dirs = []
                dirs.addAll(sourceSet.java.srcDirs)
                if (sourceSet.hasProperty('kotlin')) {
                    dirs.addAll(sourceSet.kotlin.srcDirs)
                }
            return dirs
        }.flatten()
                dirs
            }
        }

        sourceDirectories.from = files(sourceDirs)
        executionData.from = file("${buildDir}/jacoco/${unitTestTaskName}.exec")

        def execFiles = moduleProjects.collect { moduleProject ->
            file("${moduleProject.buildDir}/jacoco/${unitTestTaskName}.exec")
        }
        executionData.from = files(execFiles)
    }
}

@@ -195,6 +222,8 @@ dependencies {
    // Project dependencies
    implementation(project(":auth-data-lib"))
    implementation(project(":parental-control-data"))
    implementation(project(":data"))
    implementation(project(":ui"))

    // eFoundation libraries
    implementation(libs.telemetry)
@@ -253,6 +282,8 @@ dependencies {
    // Testing dependencies
    testImplementation(libs.truth)
    testImplementation(libs.junit)
    testImplementation(project(":domain"))
    testImplementation(project(":parental-control-data"))
    androidTestImplementation(libs.ext.junit)
    androidTestImplementation(libs.espresso.core)
    testImplementation(libs.core)

data/build.gradle

0 → 100644
+146 −0
Original line number Diff line number Diff line
plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'com.google.devtools.ksp'
    id 'com.google.dagger.hilt.android'
    id 'kotlin-allopen'
    id 'jacoco'
    alias libs.plugins.kotlin.serialization
}

jacoco {
    toolVersion = libs.versions.jacoco.get()
}

tasks.withType(Test).configureEach {
    jacoco {
        includeNoLocationClasses = true
        excludes = ['jdk.internal.*']
    }
}

def versionMajor = 2

def versionMinor = 16

def versionPatch = 0

def parentalControlPkgName = "foundation.e.parentalcontrol"

def getGitHashProvider = providers.exec {
    commandLine 'git', 'log', '--pretty=format:%h', '-n', '1'
}

def getGitHash = {
    return getGitHashProvider.standardOutput.asText.get().trim()
}

def getDate = { ->
    return new Date().format('yyyyMMddHHmmss')
}

android {
    compileSdk = 36

    defaultConfig {
        minSdk = 30
        targetSdk = 34

        buildConfigField "String", "APPLICATION_ID", "\"foundation.e.apps\""
        buildConfigField "String", "VERSION_NAME", "\"${versionMajor}.${versionMinor}.${versionPatch}\""
        buildConfigField "String", "BUILD_ID", "\"${getGitHash() + "." + getDate()}\""
        buildConfigField "String", "USER_AGENT", "\"${retrieveKey("user_agent", "Dalvik/2.1.0 (Linux; U; Android %s)")}\""
        buildConfigField "String", "PACKAGE_NAME_PARENTAL_CONTROL", "\"${parentalControlPkgName}\""
    }

    buildFeatures {
        buildConfig = true
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_21
        targetCompatibility = JavaVersion.VERSION_21
    }

    kotlinOptions {
        jvmTarget = '21'
    }

    namespace = 'foundation.e.apps.data'

    kotlin.sourceSets.configureEach {
        languageSettings.optIn("kotlin.RequiresOptIn")
    }
}

allOpen {
    annotation 'foundation.e.apps.OpenClass'
    annotation 'foundation.e.apps.OpenForTesting'
}

dependencies {
    api(project(":domain"))
    implementation(project(":auth-data-lib"))
    implementation(project(":parental-control-data"))

    implementation(libs.gplayapi)
    implementation(libs.elib)

    implementation(libs.core.ktx)
    implementation(libs.preference.ktx)
    implementation(libs.datastore.preferences)
    implementation(libs.activity.ktx)
    implementation(libs.paging.runtime.ktx)

    implementation(libs.lifecycle.livedata.ktx)
    implementation(libs.lifecycle.runtime.ktx)

    implementation(libs.work.runtime.ktx)
    testImplementation(libs.work.testing)

    ksp(libs.room.compiler)
    implementation(libs.room.ktx)
    implementation(libs.room.runtime)

    ksp(libs.hilt.compile)
    implementation(libs.hilt.android)
    implementation(libs.hilt.work)
    ksp(libs.hilt.compiler)

    implementation(libs.kotlinx.coroutines.core)
    implementation(libs.kotlinx.coroutines.android)
    testImplementation(libs.kotlinx.coroutines.test)
    testImplementation(libs.kotlin.test)
    implementation(libs.kotlinx.serialization.json)

    implementation(libs.gson)
    implementation(libs.protobuf.javalite)
    implementation(libs.retrofit)
    implementation(libs.converter.moshi)
    implementation(libs.converter.jackson)
    implementation(libs.converter.gson)
    implementation(libs.moshi.kotlin)
    implementation(libs.okhttp)
    implementation(libs.logging.interceptor)
    implementation(libs.jackson.dataformat.yaml)

    implementation(libs.bcpg.jdk15on)
    implementation(libs.timber)

    testImplementation(libs.truth)
    testImplementation(libs.junit)
    testImplementation(libs.core)
    testImplementation(libs.mockito.core)
    testImplementation(libs.mockito.kotlin)
    testImplementation(libs.mockito.inline)
    testImplementation(libs.core.testing)
    testImplementation(libs.mockk)
    testImplementation(libs.robolectric)
}

def retrieveKey(String keyName, String defaultValue) {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())

    return properties.getProperty(keyName, defaultValue)
}
+46 −0
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2022  ECORP
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.apps

/**
 * This annotation allows us to open some classes for mocking purposes while they are final in
 * release builds.
 */
@Target(
    allowedTargets = [
        AnnotationTarget.FUNCTION,
        AnnotationTarget.PROPERTY_GETTER,
        AnnotationTarget.PROPERTY_SETTER,
        AnnotationTarget.CLASS,
    ]
)
annotation class OpenClass

/**
 * Annotate a class with [OpenForTesting] if you want it to be extendable in debug builds.
 */
@OpenClass
@Target(
    allowedTargets = [
        AnnotationTarget.FUNCTION,
        AnnotationTarget.PROPERTY_GETTER,
        AnnotationTarget.PROPERTY_SETTER,
        AnnotationTarget.CLASS,
    ]
)
annotation class OpenForTesting
+14 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <application>
        <service
            android:name="androidx.work.impl.foreground.SystemForegroundService"
            android:foregroundServiceType="dataSync"
            tools:node="merge" />
    </application>
</manifest>
Loading