Skip to content

Commit 440d33f

Browse files
author
ADMSK\AVROGAL1
committed
docs: updates on documentation
Added informational and corporate documentation
1 parent 9ea0dfe commit 440d33f

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

buildSrc/src/main/kotlin/extensions/ProjectHandler.kt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,30 @@ import utils.shouldTreatCompilerWarningsAsErrors
2929
/**
3030
* An extension to create main Kotlin source set.
3131
*
32-
* @param namedDomainObjectContainer The container to create the corresponding source set
32+
* @param sourceSet The container to create the corresponding source set
3333
*
3434
* @return The main Kotlin [SourceSet]
3535
*/
36-
fun Project.createKotlinMainSources(
37-
namedDomainObjectContainer: NamedDomainObjectContainer<SourceSet>
38-
) = MainSources.create(namedDomainObjectContainer, this)
36+
fun Project.createKotlinMainSources(sourceSet: NamedDomainObjectContainer<SourceSet>) =
37+
MainSources.create(sourceSet, this)
38+
39+
fun Project.isJavaProject() =
40+
listOf("java-library", "java", "java-gradle-plugin").any { plugins.hasPlugin(it) }
41+
42+
fun Project.isKotlinProject() =
43+
listOf("kotlin", "kotlin-android", "kotlin-platform-jvm").any { plugins.hasPlugin(it) }
44+
45+
fun Project.isAndroidProject() = listOf(
46+
"com.android.library",
47+
"com.android.application",
48+
"com.android.test",
49+
"com.android.feature",
50+
"com.android.instantapp"
51+
).any { plugins.hasPlugin(it) }
52+
53+
fun Project.isJsProject() = plugins.hasPlugin("kotlin2js")
54+
55+
fun Project.isCommonsProject() = plugins.hasPlugin("org.jetbrains.kotlin.platform.common")
3956

4057
/**
4158
* An extension to create test Kotlin source set.

buildSrc/src/main/kotlin/utils/StringUtils.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,30 @@
1515
*/
1616
package utils
1717

18+
import org.gradle.api.Project
1819
import java.io.File
1920

21+
private val whitespaceRegex = Regex("\\s")
22+
23+
internal val String.dotIdentifier
24+
get() = replace("-", "")
25+
.replace(".", "")
26+
.replace(whitespaceRegex, "")
27+
28+
internal val Project.dotIdentifier get() = "$group$name".dotIdentifier
29+
30+
internal fun String.nonEmptyPrepend(prepend: String) =
31+
if (isNotEmpty()) prepend + this else this
32+
33+
internal fun String.toHyphenCase(): String {
34+
if (isBlank()) return this
35+
36+
return this[0].toLowerCase().toString() + toCharArray()
37+
.map { it.toString() }
38+
.drop(1)
39+
.joinToString(separator = "") { if (it[0].isUpperCase()) "-${it[0].toLowerCase()}" else it }
40+
}
41+
2042
/**
2143
* Executes the given command in specified working dir
2244
*

0 commit comments

Comments
 (0)