refactor(templates): move base models to separate files

This commit is contained in:
Akash Yadav
2023-05-08 19:40:28 +05:30
parent 991a84ba28
commit 6996a2a37a
6 changed files with 52 additions and 15 deletions
@@ -23,8 +23,9 @@ import com.itsaky.androidide.templates.RecipeExecutor
import com.itsaky.androidide.templates.SrcSet
import com.itsaky.androidide.templates.TemplateBuilder
import com.itsaky.androidide.templates.TemplateRecipe
import com.itsaky.androidide.templates.base.models.Dependency
import com.itsaky.androidide.templates.base.models.defaultDependency
import com.itsaky.androidide.templates.base.util.JavaSourceBuilder
import com.itsaky.androidide.templates.base.util.ModuleTemplateConfigurator
import java.io.File
/**
@@ -15,14 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.templates.base
import com.itsaky.androidide.templates.base.DependencyConfiguration.Implementation
enum class DependencyConfiguration(val configName: String) { Api("api"), ApiOnly(
"apiOnly"),
Implementation("implementation"), Runtime("runtime"), RuntimeOnly("runtimeOnly")
}
package com.itsaky.androidide.templates.base.models
class Dependency(val configuration: DependencyConfiguration, val group: String,
val artifact: String, val version: String
@@ -33,8 +26,4 @@ class Dependency(val configuration: DependencyConfiguration, val group: String,
${configuration.configName}("${group}:${artifact}:${version}")
""".trimIndent()
}
}
fun defaultDependency(group: String, artifact: String, version: String): Dependency {
return Dependency(Implementation, group, artifact, version)
}
@@ -0,0 +1,23 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE 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.
*
* AndroidIDE 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 AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.templates.base.models
enum class DependencyConfiguration(val configName: String) { Api("api"), ApiOnly(
"apiOnly"),
Implementation("implementation"), Runtime("runtime"), RuntimeOnly("runtimeOnly")
}
@@ -0,0 +1,24 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE 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.
*
* AndroidIDE 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 AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.templates.base.models
import com.itsaky.androidide.templates.base.models.DependencyConfiguration.Implementation
fun defaultDependency(group: String, artifact: String, version: String): Dependency {
return Dependency(Implementation, group, artifact, version)
}
@@ -32,7 +32,7 @@ internal fun ModuleTemplateBuilder.dependencies(): String {
return StringBuilder().apply {
append("dependencies {")
for (dep in dependencies) {
append(" ${dep.configuration.configName}(\"${dep.group}:${dep.artifact}:${dep.version}\")")
append(" ${dep.value()}")
}
append("}")
}.toString()
@@ -21,8 +21,8 @@ import androidx.test.core.app.ApplicationProvider
import com.google.common.truth.Truth.assertThat
import com.itsaky.androidide.managers.PreferenceManager
import com.itsaky.androidide.preferences.internal.prefManager
import com.itsaky.androidide.templates.base.util.ProjectTemplateConfigurator
import com.itsaky.androidide.templates.base.baseProject
import com.itsaky.androidide.templates.base.ProjectTemplateConfigurator
import com.itsaky.androidide.utils.Environment
import com.itsaky.androidide.utils.FileProvider
import io.mockk.every