-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
f715a41
commit 267abaf
Showing
15 changed files
with
291 additions
and
19 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
71 changes: 71 additions & 0 deletions
71
...ersc/hubdle/project/extensions/kotlin/features/shared/HubdleKotlinKopyFeatureExtension.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,71 @@ | ||
package com.javiersc.hubdle.project.extensions.kotlin.features.shared | ||
|
||
import com.javiersc.hubdle.project.extensions.HubdleDslMarker | ||
import com.javiersc.hubdle.project.extensions._internal.ApplicablePlugin.Scope | ||
import com.javiersc.hubdle.project.extensions._internal.fallbackAction | ||
import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension | ||
import com.javiersc.hubdle.project.extensions.apis.BaseHubdleExtension | ||
import com.javiersc.hubdle.project.extensions.apis.HubdleConfigurableExtension | ||
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension | ||
import com.javiersc.hubdle.project.extensions.apis.enableAndExecute | ||
import com.javiersc.hubdle.project.extensions.kotlin.hubdleKotlinAny | ||
import com.javiersc.hubdle.project.extensions.shared.PluginId | ||
import com.javiersc.kotlin.kopy.args.KopyFunctions | ||
import com.javiersc.kotlin.kopy.args.KopyVisibility | ||
import com.javiersc.kotlin.kopy.gradle.plugin.KopyExtension | ||
import javax.inject.Inject | ||
import org.gradle.api.Action | ||
import org.gradle.api.Project | ||
import org.gradle.api.provider.Property | ||
|
||
public open class HubdleKotlinKopyFeatureExtension @Inject constructor(project: Project) : | ||
HubdleConfigurableExtension(project) { | ||
|
||
override val isEnabled: Property<Boolean> = property { false } | ||
|
||
override val oneOfExtensions: Set<HubdleEnableableExtension> | ||
get() = hubdleKotlinAny | ||
|
||
public val functions: Property<KopyFunctions> = property { KopyFunctions.All } | ||
|
||
@HubdleDslMarker | ||
public fun functions(functions: KopyFunctions = KopyFunctions.All) { | ||
this.functions.set(functions) | ||
} | ||
|
||
public val visibility: Property<KopyVisibility> = property { KopyVisibility.Auto } | ||
|
||
@HubdleDslMarker | ||
public fun visibility(visibility: KopyVisibility = KopyVisibility.Auto) { | ||
this.visibility.set(visibility) | ||
} | ||
|
||
@HubdleDslMarker | ||
public fun kopy(action: Action<KopyExtension> = Action {}): Unit = fallbackAction(action) | ||
|
||
override fun Project.defaultConfiguration() { | ||
applicablePlugin( | ||
scope = Scope.CurrentProject, | ||
pluginId = PluginId.JavierscKotlinKopyGradlePlugin, | ||
) | ||
applicablePlugin(scope = Scope.CurrentProject, pluginId = PluginId.JetbrainsKotlinAtomicfu) | ||
|
||
withPlugin(PluginId.JavierscKotlinKopyGradlePlugin) { | ||
configure<KopyExtension> { | ||
functions.set(this@HubdleKotlinKopyFeatureExtension.functions) | ||
visibility.set(this@HubdleKotlinKopyFeatureExtension.visibility) | ||
} | ||
} | ||
} | ||
} | ||
|
||
public interface HubdleKotlinKopyDelegateFeatureExtension : BaseHubdleExtension { | ||
|
||
public val kopy: HubdleKotlinKopyFeatureExtension | ||
get() = project.getHubdleExtension() | ||
|
||
@HubdleDslMarker | ||
public fun kopy(action: Action<HubdleKotlinKopyFeatureExtension> = Action {}) { | ||
kopy.enableAndExecute(action) | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...tional/kotlin/com/javiersc/hubdle/project/kotlin/jvm/features/KotlinJvmKopyFeatureTest.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,35 @@ | ||
package com.javiersc.hubdle.project.kotlin.jvm.features | ||
|
||
import com.javiersc.gradle.testkit.test.extensions.GradleTestKitTest | ||
import com.javiersc.hubdle.hubdle.gradle.plugin.HubdleGradlePluginProjectData | ||
import com.javiersc.hubdle.project.fixtures.KotlinVersionEnv | ||
import com.javiersc.hubdle.project.fixtures.KotlinVersionRegexOrEmptyOrNull | ||
import io.kotest.matchers.string.shouldContain | ||
import java.io.File | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty | ||
import org.junit.jupiter.api.condition.EnabledOnOs | ||
import org.junit.jupiter.api.condition.OS | ||
|
||
internal class KotlinJvmKopyFeatureTest : GradleTestKitTest() { | ||
|
||
@Test | ||
@EnabledOnOs(value = [OS.LINUX, OS.MAC, OS.WINDOWS]) | ||
@EnabledIfSystemProperty(named = KotlinVersionEnv, matches = KotlinVersionRegexOrEmptyOrNull) | ||
fun `kopy feature`() { | ||
gradleTestKitTest("kotlin/jvm/features/kopy") { | ||
val hubdleTomlDestination = | ||
projectDir.resolve("gradle/hubdle.libs.versions.toml").apply { | ||
parentFile.mkdirs() | ||
createNewFile() | ||
} | ||
File(HubdleGradlePluginProjectData.RootDirAbsolutePath) | ||
.resolve("gradle/hubdle.libs.versions.toml") | ||
.copyTo(target = hubdleTomlDestination, overwrite = true) | ||
withArguments("run", "--no-scan").build().outputTrimmed.apply { | ||
shouldContain("A(b=B(c=Hello world))") | ||
shouldContain("A(b=B(c=Hello, World!))") | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
hubdle-gradle-plugin/testFunctional/resources/kotlin/jvm/features/kopy/build.gradle.kts
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,24 @@ | ||
@file:Suppress("PackageDirectoryMismatch") | ||
|
||
plugins { | ||
id("com.javiersc.hubdle") | ||
} | ||
|
||
hubdle { | ||
config { | ||
versioning { | ||
isEnabled.set(false) | ||
} | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
features { | ||
application { | ||
mainClass.set("com.javiersc.kotlin.jvm.kopy.MainKt") | ||
} | ||
kopy() | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
hubdle-gradle-plugin/testFunctional/resources/kotlin/jvm/features/kopy/gradle.properties
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 @@ | ||
#################################################################################################### | ||
### CONFIGURATION ### | ||
#################################################################################################### | ||
root.project.name=sandbox-project | ||
project.group=com.kotlin.jvm | ||
main.project.name=bar.baz | ||
#################################################################################################### | ||
### CODE ANALYSIS ### | ||
#################################################################################################### | ||
analysis.sonar.organization=javiersc | ||
#################################################################################################### | ||
### POM ### | ||
#################################################################################################### | ||
pom.name=Sandbox name | ||
pom.description=Sandbox description | ||
pom.url=https://github.com/JavierSegoviaCordoba/sandbox-project | ||
pom.license.name=The Apache License, Version 2.0 | ||
pom.license.url=https://www.apache.org/licenses/LICENSE-2.0.txt | ||
pom.developer.id=JavierSegoviaCordoba | ||
pom.developer.name=Javier Segovia Cordoba | ||
pom.developer.email=[email protected] | ||
pom.scm.url=https://github.com/JavierSegoviaCordoba/sandbox-project | ||
pom.scm.connection=scm:git:[email protected]:JavierSegoviaCordoba/sandbox-project.git | ||
pom.scm.developerConnection=scm:git:[email protected]:JavierSegoviaCordoba/sandbox-project.git | ||
#################################################################################################### | ||
### Gradle ### | ||
#################################################################################################### |
21 changes: 21 additions & 0 deletions
21
...ional/resources/kotlin/jvm/features/kopy/main/kotlin/com/javiersc/kotlin/jvm/kopy/Main.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,21 @@ | ||
@file:Suppress("PackageDirectoryMismatch") | ||
|
||
package com.javiersc.kotlin.jvm.kopy | ||
|
||
import com.javiersc.kotlin.kopy.Kopy | ||
|
||
fun main() { | ||
val a1 = A(b = B(c = "Hello world")) | ||
val a2 = a1.copy { | ||
b.c = "Hello, World!" | ||
} | ||
|
||
check(a1.b.c == "Hello world") | ||
check(a2.b.c == "Hello, World!") | ||
|
||
println(a1) | ||
println(a2) | ||
} | ||
|
||
@Kopy data class A(val b: B) | ||
@Kopy data class B(val c: String) |
36 changes: 36 additions & 0 deletions
36
hubdle-gradle-plugin/testFunctional/resources/kotlin/jvm/features/kopy/settings.gradle.kts
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,36 @@ | ||
@file:Suppress("PackageDirectoryMismatch") | ||
|
||
pluginManagement { | ||
repositories { | ||
google { | ||
mavenContent { | ||
includeGroupByRegex("androidx.*") | ||
includeGroupByRegex("com\\.android.*") | ||
includeGroupByRegex("com\\.google.*") | ||
} | ||
} | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
plugins { // | ||
id("com.javiersc.hubdle") | ||
} | ||
|
||
hubdleSettings { | ||
catalog { // | ||
isEnabled.set(false) | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
register("hubdle") { // | ||
from(files("gradle/hubdle.libs.versions.toml")) | ||
} | ||
} | ||
repositories { // | ||
mavenLocalTest() | ||
} | ||
} |