-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from makeevrserg/updated-info-root
add auto hierarchy group
- Loading branch information
Showing
4 changed files
with
41 additions
and
5 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
24 changes: 20 additions & 4 deletions
24
...gic/plugins/convention/src/main/kotlin/ru/astrainteractive/gradleplugin/InfoRootPlugin.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 |
---|---|---|
@@ -1,16 +1,32 @@ | ||
package ru.astrainteractive.gradleplugin | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.findByType | ||
import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.hierarchyGroup | ||
import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.requireProjectInfo | ||
|
||
class InfoRootPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
val projectInfo = target.requireProjectInfo | ||
target.rootProject.allprojects { | ||
group = projectInfo.group | ||
version = projectInfo.versionString | ||
description = projectInfo.description | ||
if (target.rootProject.group.toString().isEmpty()) { | ||
target.rootProject.group = projectInfo.group | ||
} | ||
if (target.group.toString().isEmpty()) { | ||
target.group = target.hierarchyGroup | ||
} | ||
if (target.version.toString().isEmpty()) { | ||
target.version = projectInfo.versionString | ||
} | ||
if (target.description.isNullOrBlank()) { | ||
target.description = projectInfo.description | ||
} | ||
target.afterEvaluate { | ||
val baseExtension = extensions.findByType<BaseExtension>() | ||
if (baseExtension?.namespace.isNullOrBlank()) { | ||
baseExtension?.namespace = target.hierarchyGroup | ||
} | ||
} | ||
} | ||
} |
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