-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9394150
commit 7ec2b89
Showing
10 changed files
with
120 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../ksp-annotations/build | ||
build |
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,3 +1,3 @@ | ||
POM_NAME=Ksp Processor | ||
POM_ARTIFACT_ID=ksp-processor | ||
POM_DESCRIPTION=The KSP routing processor | ||
POM_NAME=Ksp Core Annotations | ||
POM_ARTIFACT_ID=ksp-core-annotations | ||
POM_DESCRIPTION=Core annotations to generate basic behaviors |
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 +1 @@ | ||
../../ksp-processor/build | ||
build |
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,3 +1,3 @@ | ||
POM_NAME=Ksp Processor | ||
POM_ARTIFACT_ID=ksp-processor | ||
POM_DESCRIPTION=The KSP routing processor | ||
POM_NAME=Ksp Core Processor | ||
POM_ARTIFACT_ID=ksp-core-processor | ||
POM_DESCRIPTION=Ksp core processor to generate basic behaviors |
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 @@ | ||
build |
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,41 @@ | ||
import com.android.build.gradle.internal.tasks.factory.dependsOn | ||
|
||
plugins { | ||
kotlin("jvm") | ||
id("java-gradle-plugin") | ||
id("com.gradle.plugin-publish") version "1.2.1" | ||
id("org.jetbrains.kotlinx.kover") | ||
alias(libs.plugins.maven.publish) | ||
} | ||
|
||
dependencies { | ||
implementation(libs.plugin.kotlin) | ||
} | ||
|
||
gradlePlugin { | ||
website.set("https://github.com/programadorthi/kotlin-routing") | ||
vcsUrl.set("https://github.com/programadorthi/kotlin-routing") | ||
|
||
plugins { | ||
create("kotlin-routing-plugin") { | ||
id = "dev.programadorthi.routing" | ||
implementationClass = "dev.programadorthi.routing.gradle.KotlinRoutingGradlePlugin" | ||
displayName = "Kotlin Routing Gradle Plugin" | ||
description = "Gradle Plugin for Kotlin Routing" | ||
tags.set(listOf("router", "kotlin", "kotlin-mpp", "ktor", "routing", "navigation")) | ||
} | ||
} | ||
} | ||
|
||
val versionRegister = tasks.register<Exec>("version-register") { | ||
commandLine( | ||
"find", "./src", | ||
"-type", "f", | ||
"-exec", | ||
"sed", "-i", | ||
"''", """s/<version>/${providers.gradleProperty("version").get()}/g""", | ||
"{}", "+" | ||
) | ||
} | ||
|
||
tasks.named("processResources").dependsOn(versionRegister) |
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,3 @@ | ||
POM_NAME=Ksp Gradle Plugin | ||
POM_ARTIFACT_ID=ksp-gradle-plugin | ||
POM_DESCRIPTION=The KSP Gradle Plugin |
56 changes: 56 additions & 0 deletions
56
...dle-plugin/src/main/kotlin/dev/programadorthi/routing/gradle/KotlinRoutingGradlePlugin.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,56 @@ | ||
package dev.programadorthi.routing.gradle | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension | ||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension | ||
import java.util.Locale | ||
|
||
class KotlinRoutingGradlePlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
checkNotNull(plugins.findPlugin("com.google.devtools.ksp")) { | ||
"KSP plugin not found. Please, apply ksp plugin before routing plugin" | ||
} | ||
|
||
val kex = kotlinExtension | ||
if (kex is KotlinSingleTargetExtension<*>) { | ||
dependencies.add("implementation", ANNOTATIONS) | ||
dependencies.add("ksp", PROCESSOR) | ||
return@with | ||
} | ||
|
||
if (kex is KotlinMultiplatformExtension) { | ||
kex.targets.configureEach { kTarget -> | ||
kTarget.compilations.configureEach { compilation -> | ||
println(">>>> $kTarget -> $compilation") | ||
} | ||
if (kTarget.platformType.name == "common") { | ||
dependencies.add("kspCommonMainMetadata", PROCESSOR) | ||
return@configureEach | ||
} | ||
val capitalizedTargetName = | ||
kTarget.targetName.replaceFirstChar { | ||
if (it.isLowerCase()) { | ||
it.titlecase(Locale.US) | ||
} else { | ||
it.toString() | ||
} | ||
} | ||
dependencies.add("ksp$capitalizedTargetName", PROCESSOR) | ||
|
||
if (kTarget.compilations.any { it.name == "test" }) { | ||
dependencies.add("ksp${capitalizedTargetName}Test", PROCESSOR) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private companion object { | ||
// Version will be replaced by Gradle Exec Task | ||
private const val ANNOTATIONS = "dev.programadorthi.routing:ksp-core-annotations:<version>" | ||
private const val PROCESSOR = "dev.programadorthi.routing:ksp-core-processor:<version>" | ||
} | ||
} |
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,11 +1,17 @@ | ||
plugins { | ||
alias(libs.plugins.ksp) | ||
kotlin("jvm") | ||
alias(libs.plugins.ksp) | ||
//id("dev.programadorthi.routing") version "0.0.99" | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core) | ||
implementation(projects.ksp.coreAnnotations) | ||
implementation(projects.ksp.coreProcessor) | ||
ksp(projects.ksp.coreProcessor) | ||
} | ||
|
||
configurations.all { | ||
resolutionStrategy.dependencySubstitution { | ||
substitute(module("dev.programadorthi.routing:core")) | ||
.using(project(":core")) | ||
.because("KSP gradle plugin have maven central dependencies") | ||
} | ||
} |
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