|
18 | 18 |
|
19 | 19 | package com.hyperdevs.poeditor.gradle |
20 | 20 |
|
| 21 | +import com.android.build.api.extension.ApplicationAndroidComponentsExtension |
| 22 | +import com.android.build.api.extension.LibraryAndroidComponentsExtension |
21 | 23 | import com.android.build.gradle.AppPlugin |
22 | 24 | import com.android.build.gradle.LibraryExtension |
23 | 25 | import com.android.build.gradle.LibraryPlugin |
@@ -83,16 +85,15 @@ class PoEditorPlugin : Plugin<Project> { |
83 | 85 | // configurations with Android app modules. |
84 | 86 | val configsExtensionContainer = project.container<PoEditorPluginExtension>() |
85 | 87 | val androidExtension = project.the<BaseAppModuleExtension>() |
| 88 | + val androidComponentsExtension = project.the<ApplicationAndroidComponentsExtension>() |
86 | 89 | (androidExtension as ExtensionAware).extensions.add(POEDITOR_CONFIG_NAME, configsExtensionContainer) |
87 | 90 |
|
88 | 91 | val configPoEditorTaskProvidersMap: MutableMap<ConfigName, TaskProvider<*>> = mutableMapOf() |
89 | 92 |
|
90 | 93 | // Add tasks for every flavor or build type |
91 | | - androidExtension.onVariants { |
92 | | - // Add main extension since we have the main extension evaluated here |
| 94 | + androidComponentsExtension.beforeVariants { |
93 | 95 | addMainPoEditorTask(project, mainExtension) |
94 | | - |
95 | | - val configs = getConfigs(this.productFlavors.map { it.second }, this.buildType) |
| 96 | + val configs = getConfigs(it.productFlavors.map { it.second }, it.buildType) |
96 | 97 |
|
97 | 98 | generatePoEditorTasks(configs, |
98 | 99 | project, |
@@ -121,16 +122,17 @@ class PoEditorPlugin : Plugin<Project> { |
121 | 122 | // configurations with Android library modules. |
122 | 123 | val configsExtensionContainer = project.container<PoEditorPluginExtension>() |
123 | 124 | val androidExtension = project.the<LibraryExtension>() |
| 125 | + val androidComponentsExtension = project.the<LibraryAndroidComponentsExtension>() |
124 | 126 | (androidExtension as ExtensionAware).extensions.add(POEDITOR_CONFIG_NAME, configsExtensionContainer) |
125 | 127 |
|
126 | 128 | val configPoEditorTaskProvidersMap: MutableMap<ConfigName, TaskProvider<*>> = mutableMapOf() |
127 | 129 |
|
128 | 130 | // Add tasks for every flavor or build type |
129 | | - androidExtension.onVariants { |
| 131 | + androidComponentsExtension.beforeVariants { |
130 | 132 | // Add main extension since we have the main extension evaluated here |
131 | 133 | addMainPoEditorTask(project, mainExtension) |
132 | 134 |
|
133 | | - val configs = getConfigs(this.productFlavors.map { it.second }, this.buildType) |
| 135 | + val configs = getConfigs(it.productFlavors.map { it.second }, it.buildType) |
134 | 136 |
|
135 | 137 | generatePoEditorTasks(configs, |
136 | 138 | project, |
|
0 commit comments