diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a4a4b1ee16..92febf82d9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,6 +17,7 @@ @file:Suppress("UnstableApiUsage") import com.android.build.api.variant.FilterConfiguration.FilterType.ABI +import extension.allEnterpriseImpl import extension.allFeaturesImpl import extension.allLibrariesImpl import extension.allServicesImpl @@ -46,7 +47,11 @@ android { namespace = "io.element.android.x" defaultConfig { - applicationId = "io.element.android.x" + if (isEnterpriseBuild) { + applicationId = "io.element.enterprise" + } else { + applicationId = "io.element.android.x" + } targetSdk = Versions.targetSdk versionCode = Versions.versionCode versionName = Versions.versionName @@ -170,6 +175,20 @@ android { buildConfigField("String", "FLAVOR_DESCRIPTION", "\"FDroid\"") } } + + packaging { + resources.pickFirsts.addAll( + listOf( + "kotlin/annotation/annotation.kotlin_builtins", + "kotlin/collections/collections.kotlin_builtins", + "kotlin/coroutines/coroutines.kotlin_builtins", + "kotlin/internal/internal.kotlin_builtins", + "kotlin/kotlin.kotlin_builtins", + "kotlin/ranges/ranges.kotlin_builtins", + "kotlin/reflect/reflect.kotlin_builtins", + ) + ) + } } androidComponents { @@ -222,6 +241,7 @@ knit { dependencies { allLibrariesImpl() allServicesImpl() + allEnterpriseImpl(rootDir, logger) allFeaturesImpl(rootDir, logger) implementation(projects.features.migration.api) implementation(projects.anvilannotations) diff --git a/enterprise b/enterprise index 1ae9686f0e..2e9be17450 160000 --- a/enterprise +++ b/enterprise @@ -1 +1 @@ -Subproject commit 1ae9686f0e4b40e5f78d4b21a6fd898325409f73 +Subproject commit 2e9be1745035ee60a3e9f32f5a65be363ea24a92 diff --git a/features/enterprise/api/build.gradle.kts b/features/enterprise/api/build.gradle.kts new file mode 100644 index 0000000000..6e9cd26834 --- /dev/null +++ b/features/enterprise/api/build.gradle.kts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +plugins { + id("io.element.android-library") +} + +android { + namespace = "io.element.android.features.enterprise.api" +} + +dependencies { + implementation(projects.libraries.architecture) + implementation(projects.libraries.matrix.api) +} diff --git a/features/enterprise/api/src/main/kotlin/io.element.android.features.enterprise.api/EnterpriseService.kt b/features/enterprise/api/src/main/kotlin/io.element.android.features.enterprise.api/EnterpriseService.kt new file mode 100644 index 0000000000..74d56b3191 --- /dev/null +++ b/features/enterprise/api/src/main/kotlin/io.element.android.features.enterprise.api/EnterpriseService.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.features.enterprise.api + +interface EnterpriseService { + suspend fun isEnterpriseUser(): Boolean +} diff --git a/features/enterprise/impl/build.gradle.kts b/features/enterprise/impl/build.gradle.kts new file mode 100644 index 0000000000..e6d477b0ed --- /dev/null +++ b/features/enterprise/impl/build.gradle.kts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +plugins { + id("io.element.android-library") + alias(libs.plugins.anvil) +} + +android { + namespace = "io.element.android.features.enterprise.impl" +} + +dependencies { + implementation(projects.anvilannotations) + api(libs.anvil.compiler.api) + api(projects.features.enterprise.api) + implementation(projects.libraries.architecture) +} diff --git a/features/enterprise/impl/src/main/kotlin/io.element.android.features.enterprise.impl/DefaultEnterpriseService.kt b/features/enterprise/impl/src/main/kotlin/io.element.android.features.enterprise.impl/DefaultEnterpriseService.kt new file mode 100644 index 0000000000..751c189c76 --- /dev/null +++ b/features/enterprise/impl/src/main/kotlin/io.element.android.features.enterprise.impl/DefaultEnterpriseService.kt @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.features.enterprise.impl + +import com.squareup.anvil.annotations.ContributesBinding +import io.element.android.features.enterprise.api.EnterpriseService +import io.element.android.libraries.di.SessionScope +import javax.inject.Inject + +@ContributesBinding(SessionScope::class) +class DefaultEnterpriseService @Inject constructor( +) : EnterpriseService { + override suspend fun isEnterpriseUser(): Boolean = false +} diff --git a/plugins/src/main/kotlin/Enterprise.kt b/plugins/src/main/kotlin/Enterprise.kt new file mode 100644 index 0000000000..65762c05d6 --- /dev/null +++ b/plugins/src/main/kotlin/Enterprise.kt @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File + +/** + * Are we building with the enterprise sources? + */ +val isEnterpriseBuild = File("enterprise/README.md").exists() diff --git a/plugins/src/main/kotlin/Versions.kt b/plugins/src/main/kotlin/Versions.kt index 76a66dd519..97ac5aeaf5 100644 --- a/plugins/src/main/kotlin/Versions.kt +++ b/plugins/src/main/kotlin/Versions.kt @@ -64,7 +64,7 @@ object Versions { const val compileSdk = 34 const val targetSdk = 33 // When updating the `minSdk`, make sure to update the value of `minSdkVersion` in the file `tools/release/release.sh` - const val minSdk = 24 + val minSdk = if (isEnterpriseBuild) 26 else 24 val javaCompileVersion = JavaVersion.VERSION_17 val javaLanguageVersion: JavaLanguageVersion = JavaLanguageVersion.of(11) } diff --git a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt index 4aa635b489..9fd82af4ae 100644 --- a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt +++ b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt @@ -130,6 +130,11 @@ fun DependencyHandlerScope.allServicesImpl() { implementation(project(":services:toolbox:impl")) } +fun DependencyHandlerScope.allEnterpriseImpl(rootDir: File, logger: Logger) { + val enterpriseDir = File(rootDir, "enterprise") + addImplementationProjects(enterpriseDir, ":enterprise", "impl", logger) +} + fun DependencyHandlerScope.allFeaturesApi(rootDir: File, logger: Logger) { val featuresDir = File(rootDir, "features") addImplementationProjects(featuresDir, ":features", "api", logger) diff --git a/settings.gradle.kts b/settings.gradle.kts index b154f4585e..693a258447 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -87,6 +87,7 @@ fun includeProjects(directory: File, path: String, maxDepth: Int = 1) { } } +includeProjects(File(rootDir, "enterprise"), ":enterprise", maxDepth = 2) includeProjects(File(rootDir, "features"), ":features") includeProjects(File(rootDir, "libraries"), ":libraries") includeProjects(File(rootDir, "services"), ":services") diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt index f126640149..a34f0282a7 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt @@ -112,6 +112,7 @@ class KonsistClassNameTest { "DBov", "Default", "DataStore", + "Enterprise", "FileExtensionExtractor", "KeyStore", "Matrix",