-
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.
Add settings-include-dsl Gradle plugin
- Loading branch information
Showing
6 changed files
with
125 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import gradle.kotlin.dsl.accessors._3446ec0516f3690bb745eb6b3e74e05f.signing | ||
import publishing.trySignAll | ||
|
||
plugins { | ||
id("com.gradle.plugin-publish") | ||
`java-gradle-plugin` | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
dependencies { | ||
compileOnly(gradleKotlinDsl()) | ||
} | ||
|
||
java { withSourcesJar() } | ||
signing { trySignAll() } |
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 @@ | ||
plugins { | ||
`gradle-plugin` | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "org.splitties.incubator" | ||
|
||
gradlePlugin { | ||
plugins { | ||
create(project.name) { | ||
id = "org.splitties.incubator.settings-include-dsl" | ||
displayName = "Settings include DSL" | ||
description = "For Gradle projects with nested modules where you call include a lot." | ||
implementationClass = "org.splitties.incubator.gradle.SettingsIncludeDslPlugin" | ||
} | ||
} | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(8) | ||
} | ||
|
||
pluginBundle { | ||
website = "https://github.com/LouisCAD/LibPublishingHelpers" | ||
vcsUrl = "https://github.com/LouisCAD/LibPublishingHelpers.git" | ||
tags = listOf("kotlin-dsl", "kotlin") | ||
} |
29 changes: 29 additions & 0 deletions
29
gradle-plugins/settings-include-dsl/src/main/kotlin/ModuleParentScope.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,29 @@ | ||
package org.splitties.incubator.gradle | ||
|
||
import org.gradle.api.initialization.Settings | ||
|
||
class ModuleParentScope( | ||
private val settings: Settings, | ||
private val name: String, | ||
private val parent: ModuleParentScope? = null | ||
) { | ||
|
||
operator fun String.invoke(block: (ModuleParentScope.() -> Unit)? = null) { | ||
check(startsWith(':').not()) | ||
val moduleName = ":$this" | ||
val projectName = "$parentalPath$moduleName" | ||
settings.include(projectName) | ||
block?.let { buildNode -> | ||
ModuleParentScope( | ||
settings = settings, | ||
name = moduleName, | ||
parent = this@ModuleParentScope | ||
).buildNode() | ||
} | ||
} | ||
|
||
private val parentalPath: String = | ||
generateSequence(this) { it.parent } | ||
.map { it.name }.toList().reversed().joinToString("") | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
gradle-plugins/settings-include-dsl/src/main/kotlin/SettingsIncludeDslPlugin.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,8 @@ | ||
package org.splitties.incubator.gradle | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.initialization.Settings | ||
|
||
class SettingsIncludeDslPlugin : Plugin<Settings> { | ||
override fun apply(target: Settings) = Unit | ||
} |
8 changes: 8 additions & 0 deletions
8
gradle-plugins/settings-include-dsl/src/main/kotlin/org/gradle/kotlin/dsl/include.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,8 @@ | ||
package org.gradle.kotlin.dsl | ||
|
||
import org.gradle.api.initialization.Settings | ||
import org.splitties.incubator.gradle.ModuleParentScope | ||
|
||
inline fun Settings.include(block: ModuleParentScope.() -> Unit) { | ||
ModuleParentScope(settings = this, name = "").block() | ||
} |
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