-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore conventions for uninitialized properties and fix flavor-speci…
…fic configs not picking up the default resource path (#74) * Restore conventions for uninitialized properties * Fix flavor-specific configs not picking up the default resource path for the brand
- Loading branch information
Showing
7 changed files
with
116 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/kotlin/com/hyperdevs/poeditor/gradle/DefaultValues.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2023 HyperDevs | ||
* | ||
* 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 com.hyperdevs.poeditor.gradle | ||
|
||
import com.hyperdevs.poeditor.gradle.network.api.OrderType | ||
import java.io.File | ||
|
||
/** | ||
* Object that holds default and convention values for the plugin properties. | ||
*/ | ||
@Suppress("MayBeConst", "MayBeConstant") | ||
object DefaultValues { | ||
internal val ENABLED = true | ||
internal val MAIN_CONFIG_NAME: ConfigName = "main" | ||
internal val DEFAULT_LANG = "en" | ||
internal val FILTERS = emptyList<String>() | ||
internal val ORDER_TYPE = OrderType.NONE.name.lowercase() | ||
internal val TAGS = emptyList<String>() | ||
internal val LANGUAGE_VALUES_OVERRIDE_PATH_MAP = emptyMap<String, String>() | ||
internal val MINIMUM_TRANSLATION_PERCENTAGE = -1 | ||
internal val RES_FILE_NAME = "string" | ||
internal val UNQUOTED = false | ||
internal val UNESCAPE_HTML_TAGS = true | ||
|
||
/** | ||
* Apply the default convention to a [PoEditorPluginExtension]. | ||
*/ | ||
fun applyDefaultConvention(extension: PoEditorPluginExtension, resourceDirectory: File) { | ||
with(extension) { | ||
enabled.convention(ENABLED) | ||
defaultResPath.convention(resourceDirectory.absolutePath) | ||
defaultLang.convention(DEFAULT_LANG) | ||
filters.convention(FILTERS) | ||
order.convention(ORDER_TYPE) | ||
tags.convention(TAGS) | ||
languageValuesOverridePathMap.convention(LANGUAGE_VALUES_OVERRIDE_PATH_MAP) | ||
minimumTranslationPercentage.convention(MINIMUM_TRANSLATION_PERCENTAGE) | ||
resFileName.convention(RES_FILE_NAME) | ||
unquoted.convention(UNQUOTED) | ||
unescapeHtmlTags.convention(UNESCAPE_HTML_TAGS) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/com/hyperdevs/poeditor/gradle/utils/ProjectUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2023 HyperDevs | ||
* | ||
* 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 com.hyperdevs.poeditor.gradle.utils | ||
|
||
import com.hyperdevs.poeditor.gradle.ConfigName | ||
import org.gradle.api.Project | ||
import java.io.File | ||
|
||
/** | ||
* Gets the resource directory for a given config name. | ||
*/ | ||
fun getResourceDirectory(project: Project, configName: ConfigName) = | ||
File(File(File(project.layout.projectDirectory.asFile, "src"), configName), "res") |