1- @file:Suppress(" ObjectPropertyName" )
2-
31import org.gradle.api.JavaVersion
42import org.gradle.api.Project
53import org.gradle.api.artifacts.dsl.RepositoryHandler
64import org.gradle.api.tasks.Delete
75import org.gradle.kotlin.dsl.ScriptHandlerScope
6+ import org.gradle.kotlin.dsl.embeddedKotlinVersion
87import org.gradle.kotlin.dsl.repositories
8+ import tools.forma.android.utils.register
9+ import tools.forma.config.ConfigurationStore
910import tools.forma.config.FormaConfiguration
1011import tools.forma.config.FormaConfigurationStore
11- import tools.forma.android.utils.register
1212
1313// TODO: add docs for every fun param
1414/* *
@@ -22,45 +22,49 @@ import tools.forma.android.utils.register
2222 * @param mandatoryOwners is a flag that enables mandatory owners for all modules
2323 * @param extraPlugins is a list of extra plugins that will be applied to project
2424 */
25+
2526fun ScriptHandlerScope.androidProjectConfiguration (
2627 project : Project ,
2728 minSdk : Int ,
2829 targetSdk : Int ,
2930 compileSdk : Int ,
30- kotlinVersion : String ,
31+ kotlinVersion : String = embeddedKotlinVersion ,
3132 agpVersion : String ,
3233 repositories : RepositoryHandler .() -> Unit = {},
3334 dataBinding : Boolean = false,
35+ compose : Boolean = false,
3436 javaVersionCompatibility : JavaVersion = JavaVersion .VERSION_1_8 , // Java/Kotlin configuration
3537 mandatoryOwners : Boolean = false,
36- extraPlugins : List <Any >
38+ vectorDrawablesUseSupportLibrary : Boolean = false,
39+ extraPlugins : List <String > = emptyList()
3740) {
38- Forma .buildScriptConfiguration(this , extraPlugins)
39- with (project) {
41+ buildScriptConfiguration(this , extraPlugins)
4042
41- /* *
42- * Default Android project clean task implementation
43- */
43+ /* *
44+ * Default Android project clean task implementation
45+ */
46+ with (project) {
4447 tasks.register(" clean" , Delete ::class ) {
4548 delete(project.buildDir)
4649 }
50+ }
4751
48- val configuration = FormaConfiguration (
49- minSdk = minSdk,
50- targetSdk = targetSdk,
51- compileSdk = compileSdk,
52- // we don't need check properties for exist, we read it successfully in forma configuration
53- kotlinVersion = kotlinVersion,
54- agpVersion = agpVersion,
55- repositories = repositories,
56- dataBinding = dataBinding,
57- javaVersionCompatibility = javaVersionCompatibility,
58- mandatoryOwners = mandatoryOwners
59- )
60-
61- Forma .store(configuration )
52+ val configuration = FormaConfiguration (
53+ minSdk = minSdk,
54+ targetSdk = targetSdk,
55+ compileSdk = compileSdk,
56+ // we don't need check properties for exist, we read it successfully in forma configuration
57+ kotlinVersion = kotlinVersion,
58+ agpVersion = agpVersion,
59+ repositories = repositories,
60+ dataBinding = dataBinding,
61+ javaVersionCompatibility = javaVersionCompatibility,
62+ mandatoryOwners = mandatoryOwners,
63+ compose = compose,
64+ vectorDrawablesUseSupportLibrary = vectorDrawablesUseSupportLibrary
65+ )
6266
63- }
67+ Forma .store(configuration)
6468}
6569
6670@Deprecated(" Old approach to configuration, use ScriptHandlerScope Extension" )
@@ -76,6 +80,8 @@ fun Project.androidProjectConfiguration(
7680 generateMissedManifests : Boolean = false,
7781 javaVersionCompatibility : JavaVersion = JavaVersion .VERSION_1_8 , // Java/Kotlin configuration
7882 mandatoryOwners : Boolean = false,
83+ compose : Boolean = false,
84+ vectorDrawablesUseSupportLibrary : Boolean = true,
7985) {
8086
8187 /* *
@@ -95,29 +101,27 @@ fun Project.androidProjectConfiguration(
95101 repositories = repositories,
96102 dataBinding = dataBinding,
97103 javaVersionCompatibility = javaVersionCompatibility,
98- mandatoryOwners = mandatoryOwners
104+ mandatoryOwners = mandatoryOwners,
105+ compose = compose,
106+ vectorDrawablesUseSupportLibrary = vectorDrawablesUseSupportLibrary
99107 )
100108
101109 Forma .store(configuration)
102110}
103111
112+ val buildScriptConfiguration: ScriptHandlerScope .(List <Any >) -> Unit = { classpathDeps ->
113+ // TODO pass repositories configuration
114+ repositories {
115+ google()
116+ mavenCentral()
117+ }
118+ dependencies {
119+ classpathDeps.forEach { classpath(it) }
120+ }
121+ }
122+
104123/* *
105124 * Singleton project configuration store
125+ * TODO remove
106126 */
107- object Forma {
108-
109- val configuration: FormaConfiguration get() = FormaConfigurationStore .configuration
110-
111- fun store (configuration : FormaConfiguration ) = FormaConfigurationStore .store(configuration)
112-
113- val buildScriptConfiguration: ScriptHandlerScope .(List <Any >) -> Unit = { classpathDeps ->
114- // TODO pass repositories configuration
115- repositories {
116- google()
117- mavenCentral()
118- }
119- dependencies {
120- classpathDeps.forEach { classpath(it) }
121- }
122- }
123- }
127+ object Forma: ConfigurationStore<FormaConfiguration> by FormaConfigurationStore
0 commit comments