mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
refactor(templates): move base models to separate files
This commit is contained in:
+2
-1
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
+1
-12
@@ -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)
|
||||
}
|
||||
+23
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user