From e3523865ee9debab5955f0e2f92fcad661371391 Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Sat, 23 Mar 2024 15:11:47 +0100 Subject: [PATCH] Rename ociDependencies extension -> ociImageDependencies Rename image dependency collector -> runtime Rename imageScope(String) dependency collector -> runtimeScope(String) --- examples/java-app-groovy-dsl/build.gradle | 4 +- examples/java-app/build.gradle.kts | 4 +- .../github/sgtsilvio/gradle/oci/OciPlugin.kt | 12 +++--- .../oci/dsl/OciDependenciesExtension.kt | 36 ------------------ .../oci/dsl/OciImageDependenciesExtension.kt | 37 +++++++++++++++++++ ...t => OciImageDependenciesExtensionImpl.kt} | 24 ++++++------ 6 files changed, 59 insertions(+), 58 deletions(-) delete mode 100644 src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciDependenciesExtension.kt create mode 100644 src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciImageDependenciesExtension.kt rename src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/{OciDependenciesExtensionImpl.kt => OciImageDependenciesExtensionImpl.kt} (76%) diff --git a/examples/java-app-groovy-dsl/build.gradle b/examples/java-app-groovy-dsl/build.gradle index 51f62adc..3cc60466 100644 --- a/examples/java-app-groovy-dsl/build.gradle +++ b/examples/java-app-groovy-dsl/build.gradle @@ -57,8 +57,8 @@ testing { implementation(libs.testcontainers) implementation(libs.gradleOci.junitJupiter) } - ociDependencies.forTestSuite(it) { - image.add(project).tag("latest") + ociImageDependencies.forTestSuite(it) { + runtime.add(project).tag("latest") } } } diff --git a/examples/java-app/build.gradle.kts b/examples/java-app/build.gradle.kts index 74738381..5a1fd6e2 100644 --- a/examples/java-app/build.gradle.kts +++ b/examples/java-app/build.gradle.kts @@ -57,8 +57,8 @@ testing { implementation(libs.testcontainers) implementation(libs.gradleOci.junitJupiter) } - ociDependencies { - image(project).tag("latest") + ociImageDependencies { + runtime(project).tag("latest") } } } diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciPlugin.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciPlugin.kt index 0a53f41a..ab5ef42c 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciPlugin.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciPlugin.kt @@ -1,11 +1,11 @@ package io.github.sgtsilvio.gradle.oci import io.github.sgtsilvio.gradle.oci.attributes.DISTRIBUTION_TYPE_ATTRIBUTE -import io.github.sgtsilvio.gradle.oci.dsl.OciDependenciesExtension import io.github.sgtsilvio.gradle.oci.dsl.OciExtension +import io.github.sgtsilvio.gradle.oci.dsl.OciImageDependenciesExtension import io.github.sgtsilvio.gradle.oci.internal.concatCamelCase -import io.github.sgtsilvio.gradle.oci.internal.dsl.OciDependenciesExtensionImpl import io.github.sgtsilvio.gradle.oci.internal.dsl.OciExtensionImpl +import io.github.sgtsilvio.gradle.oci.internal.dsl.OciImageDependenciesExtensionImpl import io.github.sgtsilvio.gradle.oci.internal.mainToEmpty import org.gradle.api.Plugin import org.gradle.api.Project @@ -23,9 +23,9 @@ class OciPlugin : Plugin { val extension = project.extensions.create(OciExtension::class, EXTENSION_NAME, OciExtensionImpl::class) registerPushTasks(project, extension) project.extensions.create( - OciDependenciesExtension::class, - DEPENDENCIES_EXTENSION_NAME, - OciDependenciesExtensionImpl::class, + OciImageDependenciesExtension::class, + IMAGE_DEPENDENCIES_EXTENSION_NAME, + OciImageDependenciesExtensionImpl::class, extension, ) } @@ -48,5 +48,5 @@ class OciPlugin : Plugin { } const val EXTENSION_NAME = "oci" -const val DEPENDENCIES_EXTENSION_NAME = "ociDependencies" +const val IMAGE_DEPENDENCIES_EXTENSION_NAME = "ociImageDependencies" const val TASK_GROUP_NAME = "oci" diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciDependenciesExtension.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciDependenciesExtension.kt deleted file mode 100644 index 85485a4b..00000000 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciDependenciesExtension.kt +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.sgtsilvio.gradle.oci.dsl - -import org.gradle.api.Action -import org.gradle.api.plugins.jvm.JvmTestSuite -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.testing.Test - -/** - * @author Silvio Giebl - */ -interface OciDependenciesExtension : DependencyConstraintFactories { - - fun forTestSuite(testSuite: JvmTestSuite): OciDependencies - - fun forTestSuite(testSuite: JvmTestSuite, action: Action) = - action.execute(forTestSuite(testSuite)) - - fun forTest(testTask: TaskProvider): OciDependencies - - fun forTest(testTask: TaskProvider, action: Action) = action.execute(forTest(testTask)) - - // dsl syntactic sugar - - val JvmTestSuite.image get() = forTestSuite(this).image - - fun JvmTestSuite.imageScope(scope: String) = forTestSuite(this).imageScope(scope) - - // no dsl syntactic sugar for Test because is should not be used inside a lazy task configuration -} - -interface OciDependencies : DependencyConstraintFactories { - - val image: ResolvableOciImageDependencies - - fun imageScope(scope: String): ResolvableOciImageDependencies -} diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciImageDependenciesExtension.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciImageDependenciesExtension.kt new file mode 100644 index 00000000..99243831 --- /dev/null +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciImageDependenciesExtension.kt @@ -0,0 +1,37 @@ +package io.github.sgtsilvio.gradle.oci.dsl + +import org.gradle.api.Action +import org.gradle.api.plugins.jvm.JvmTestSuite +import org.gradle.api.tasks.TaskProvider +import org.gradle.api.tasks.testing.Test + +/** + * @author Silvio Giebl + */ +interface OciImageDependenciesExtension : DependencyConstraintFactories { + + fun forTestSuite(testSuite: JvmTestSuite): OciImageDependenciesForRuntime + + fun forTestSuite(testSuite: JvmTestSuite, action: Action) = + action.execute(forTestSuite(testSuite)) + + fun forTest(testTask: TaskProvider): OciImageDependenciesForRuntime + + fun forTest(testTask: TaskProvider, action: Action) = + action.execute(forTest(testTask)) + + // dsl syntactic sugar + + val JvmTestSuite.runtime get() = forTestSuite(this).runtime + + fun JvmTestSuite.runtimeScope(scope: String) = forTestSuite(this).runtimeScope(scope) + + // no dsl syntactic sugar for Test because is should not be used inside a lazy task configuration +} + +interface OciImageDependenciesForRuntime : DependencyConstraintFactories { + + val runtime: ResolvableOciImageDependencies + + fun runtimeScope(scope: String): ResolvableOciImageDependencies +} diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciDependenciesExtensionImpl.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDependenciesExtensionImpl.kt similarity index 76% rename from src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciDependenciesExtensionImpl.kt rename to src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDependenciesExtensionImpl.kt index 4f010214..30651ad6 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciDependenciesExtensionImpl.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDependenciesExtensionImpl.kt @@ -2,9 +2,9 @@ package io.github.sgtsilvio.gradle.oci.internal.dsl import io.github.sgtsilvio.gradle.oci.OciRegistryDataTask import io.github.sgtsilvio.gradle.oci.TASK_GROUP_NAME -import io.github.sgtsilvio.gradle.oci.dsl.OciDependencies -import io.github.sgtsilvio.gradle.oci.dsl.OciDependenciesExtension import io.github.sgtsilvio.gradle.oci.dsl.OciExtension +import io.github.sgtsilvio.gradle.oci.dsl.OciImageDependenciesExtension +import io.github.sgtsilvio.gradle.oci.dsl.OciImageDependenciesForRuntime import io.github.sgtsilvio.gradle.oci.dsl.ResolvableOciImageDependencies import io.github.sgtsilvio.gradle.oci.internal.concatCamelCase import org.gradle.api.artifacts.dsl.DependencyConstraintHandler @@ -22,16 +22,16 @@ import javax.inject.Inject /** * @author Silvio Giebl */ -internal abstract class OciDependenciesExtensionImpl @Inject constructor( +internal abstract class OciImageDependenciesExtensionImpl @Inject constructor( private val oci: OciExtension, private val objectFactory: ObjectFactory, private val taskContainer: TaskContainer, private val projectLayout: ProjectLayout, dependencyConstraintHandler: DependencyConstraintHandler, -) : DependencyConstraintFactoriesImpl(dependencyConstraintHandler), OciDependenciesExtension { +) : DependencyConstraintFactoriesImpl(dependencyConstraintHandler), OciImageDependenciesExtension { - private val testSuiteDependencies = HashMap() - private val testDependencies = HashMap() + private val testSuiteDependencies = HashMap() + private val testDependencies = HashMap() final override fun forTestSuite(testSuite: JvmTestSuite) = testSuiteDependencies.getOrPut(testSuite.name) { val testSuiteName = testSuite.name @@ -45,7 +45,7 @@ internal abstract class OciDependenciesExtensionImpl @Inject constructor( jvmArgumentProviders += OciTestArgumentProvider(objectFactory, registryDataTask) } } - objectFactory.newInstance(testSuiteName, registryDataTask, oci) + objectFactory.newInstance(testSuiteName, registryDataTask, oci) } final override fun forTest(testTask: TaskProvider) = testDependencies.getOrPut(testTask.name) { @@ -58,22 +58,22 @@ internal abstract class OciDependenciesExtensionImpl @Inject constructor( testTask { jvmArgumentProviders += OciTestArgumentProvider(objectFactory, registryDataTask) } - objectFactory.newInstance(testTaskName, registryDataTask, oci) + objectFactory.newInstance(testTaskName, registryDataTask, oci) } } -internal abstract class OciDependenciesImpl @Inject constructor( +internal abstract class OciImageDependenciesForRuntimeImpl @Inject constructor( private val name: String, private val registryDataTask: TaskProvider, private val oci: OciExtension, dependencyConstraintHandler: DependencyConstraintHandler, -) : DependencyConstraintFactoriesImpl(dependencyConstraintHandler), OciDependencies { +) : DependencyConstraintFactoriesImpl(dependencyConstraintHandler), OciImageDependenciesForRuntime { private val scopes = HashMap() - final override val image = imageScope("") + final override val runtime = runtimeScope("") - final override fun imageScope(scope: String): ResolvableOciImageDependencies = scopes.getOrPut(scope) { + final override fun runtimeScope(scope: String): ResolvableOciImageDependencies = scopes.getOrPut(scope) { val imageDependencies = oci.imageDependencies.create(name.concatCamelCase(scope)) registryDataTask { from(imageDependencies)