From 35ce4007623e58d0a604ccb36fff12c58916c6fe Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 16:49:34 +0100 Subject: [PATCH 01/13] Suppress `unused` --- tool-base/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/tool-base/build.gradle.kts b/tool-base/build.gradle.kts index 7e95809f..d9aac673 100644 --- a/tool-base/build.gradle.kts +++ b/tool-base/build.gradle.kts @@ -170,6 +170,7 @@ fun Project.applyGeneratedDirectories(generatedDir: String) { * somewhere inside either ProtoData or McJava. */ project.afterEvaluate { + @Suppress("unused") // Used via `by` syntax. val sourcesJar by tasks.getting { this as Jar duplicatesStrategy = DuplicatesStrategy.INCLUDE From 6172a40c427e73c49fd97b37d6257b33b1a4391a Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 16:50:06 +0100 Subject: [PATCH 02/13] Suppres `ConstPropertyName` --- .../main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt index 7c11bbcd..67716d89 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt @@ -51,6 +51,7 @@ import org.gradle.api.Project * Ordering said hooks is a non-trivial operation and the result is usually quite fragile. * Thus, we choose to do this small piece of configuration manually. */ +@Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names internal object CloudArtifactRegistry { private const val spineRepoLocation = "https://europe-maven.pkg.dev/spine-event-engine" From 97220c405a3b74cce89a94874074d705235d0cf0 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 17:52:20 +0100 Subject: [PATCH 03/13] Bump version -> `2.0.0-SNAPSHOT.309` --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index 867681e1..8daa96e0 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -24,4 +24,4 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -val versionToPublish: String by extra("2.0.0-SNAPSHOT.308") +val versionToPublish: String by extra("2.0.0-SNAPSHOT.309") From e3bff88cd2d59d722b67a8c1a20edb5d1cf50221 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 18:38:45 +0100 Subject: [PATCH 04/13] Make publication handlers apply destinations only once --- .../publish/CustomPublicationHandler.kt | 16 ++- .../gradle/publish/PublicationHandler.kt | 117 ++++++++++++++---- .../io/spine/gradle/publish/PublishingExts.kt | 9 +- .../spine/gradle/publish/SpinePublishing.kt | 58 +++++++-- .../publish/StandardJavaPublicationHandler.kt | 32 ++++- 5 files changed, 187 insertions(+), 45 deletions(-) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt index 13b86386..152455dc 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt @@ -46,13 +46,25 @@ import org.gradle.api.publish.maven.MavenPublication * the [standard][org.gradle.api.publish.maven.MavenPublication] publication, and custom ones. * To have both standard and custom publications, please specify custom artifact IDs or * classifiers for each custom publication. + * + * @see StandardJavaPublicationHandler */ -internal class CustomPublicationHandler(project: Project, destinations: Set) : - PublicationHandler(project, destinations) { +internal class CustomPublicationHandler private constructor( + project: Project, + destinations: Set +) : PublicationHandler(project, destinations) { override fun handlePublications() { project.publications.forEach { (it as MavenPublication).copyProjectAttributes() } } + + companion object : HandlerFactory() { + override fun create( + project: Project, + destinations: Set, + vararg params: Any + ): CustomPublicationHandler = CustomPublicationHandler(project, destinations) + } } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt index 03848a9d..4dfeefac 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt @@ -42,43 +42,53 @@ private const val MAVEN_PUBLISH = "maven-publish" /** * Abstract base for handlers of publications in a project * with [spinePublishing] settings declared. + * + * @param project The project to which the handler applied. + * @param destinations The repositories for publishing artifacts of this project. + * In a multi-module project the destinations can be re-defined by + * specifying custom values of in + * the [`spinePublishing`][io.spine.gradle.publish.SpinePublishing.destinations] + * of the subproject. */ internal sealed class PublicationHandler( protected val project: Project, - private val destinations: Set + protected var destinations: Set ) { + + private var applied: Boolean = false + /** - * Tells if this publication handler already [applied][apply]. - * - * This safeguard is needed because we call the [apply] method - * under [Project.afterEvaluate] block, which could be called more than once. - * This flag helps to ensure that we call the [doApply] only once, thus - * avoiding repeated calls of the publication settings code. + * Overwrites the [destinations] property with the given set. */ - private var applied = false - - fun apply() { - synchronized(this) { - if (applied) { - return@synchronized - } - doApply() - this.applied = true + fun publishTo(alternativeDestinations: Set) { + if (alternativeDestinations.isEmpty()) { + project.logger.info( + "The project ${project.path} is not going to be published because" + + " the publication handler `${this@PublicationHandler}`" + + " got an empty set of new `destinations`." + ) } + destinations = alternativeDestinations } /** * Configures the publication of the associated [project]. */ - private fun doApply() { - project.run { - if (!hasCustomPublishing) { - apply(plugin = MAVEN_PUBLISH) + fun apply() { + synchronized(project) { + if (applied) { + return } - pluginManager.withPlugin(MAVEN_PUBLISH) { - handlePublications() - registerDestinations() - configurePublishTask(destinations) + project.run { + if (!hasCustomPublishing) { + apply(plugin = MAVEN_PUBLISH) + } + pluginManager.withPlugin(MAVEN_PUBLISH) { + handlePublications() + registerDestinations() + configurePublishTask(destinations) + applied = true + } } } } @@ -131,6 +141,65 @@ internal sealed class PublicationHandler( } } } + + /** + * The abstract base for factories of producing instances of classes + * derived from [io.spine.gradle.publish.PublicationHandler]. + * + * The factory maintains associations between a path of the project to + * its publication handler. + * + * If the handler already exists, its settings are updated when + * the [serving] factory method is called. + * + * Otherwise, a new handler is created and associated with the project. + * + * @see serving + */ + abstract class HandlerFactory { + + /** + * Maps a project path to the associated handler, if available. + */ + private val handlers = mutableMapOf() + + /** + * Obtains an instance of [PublicationHandler] for the given project. + * + * If the handler for the given [project] was already created, the handler + * gets new [destinations], [overwriting][publishTo] previously specified. + * + * @return the handler for the given project which would handle publishing to + * the specified [destinations]. + */ + fun serving(project: Project, destinations: Set, vararg params: Any): H { + synchronized(handlers) { + val path = project.path + var handler = handlers[path] + if (handler == null) { + handler = create(project, destinations, *params) + handlers[path] = handler + } else { + handler.publishTo(destinations) + } + return handler + } + } + + /** + * Creates a new publication handler for the given project. + * + * @param project The project to which the handler applies. + * @param destinations The repositories for publishing artifacts of this project. + * @param params Optional parameters to be passed as constructor parameters for + * classes of the type [H]. + */ + protected abstract fun create( + project: Project, + destinations: Set, + vararg params: Any + ): H + } } /** diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt index 4bf03e65..0a24b56b 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt @@ -58,6 +58,13 @@ internal val Project.publishingExtension: PublishingExtension internal val Project.publications: PublicationContainer get() = publishingExtension.publications +/** + * Obtains an instance, if available, of [SpinePublishing] extension + * applied to this project. + */ +internal val Project.localSpinePublishing: SpinePublishing? + get() = extensions.findByType() + /** * Obtains [SpinePublishing] extension from this [Project]. * @@ -66,7 +73,7 @@ internal val Project.publications: PublicationContainer */ internal val Project.spinePublishing: SpinePublishing get() { - val local = this.extensions.findByType() + val local = localSpinePublishing if (local != null) { return local } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt index d07a0f20..9dc7d7c9 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt @@ -134,8 +134,8 @@ import org.gradle.kotlin.dsl.findByType * and can be disabled via [SpinePublishing.protoJar]. * * 3. [javadocJar] — Javadoc, generated upon Java sources from the `main` source set. - * If Javadoc for Kotlin is also needed, apply the Dokka plugin. It tunes `javadoc` task to generate - * docs upon Kotlin sources as well. + * If Javadoc for Kotlin is also needed, apply the Dokka plugin. + * It tunes the `javadoc` task to generate docs upon Kotlin sources as well. * * 4. [dokkaKotlinJar] — documentation generated by Dokka for Kotlin and Java sources * using the Kotlin API mode. @@ -147,6 +147,7 @@ import org.gradle.kotlin.dsl.findByType * of the `test` source set. Use [SpinePublishing.testJar] to enable its publishing. * * @see [artifacts] + * @see SpinePublishing */ fun Project.spinePublishing(block: SpinePublishing.() -> Unit) { apply() @@ -161,7 +162,16 @@ fun Project.spinePublishing(block: SpinePublishing.() -> Unit) { } /** - * A Gradle extension for setting up publishing of spine modules using `maven-publish` plugin. + * A Gradle extension for setting up publishing of modules of Spine SDK modules + * using `maven-publish` plugin. + * + * ### Implementation Note + * + * This extension is overloaded with responsibilities. + * It basically does what an extension AND a Gradle plugin would normally do. + * + * We [should introduce a plugin class](https://github.com/SpineEventEngine/config/issues/562) + * and move the code related to creating tasks or setting dependencies between them into the plugin. * * @param project The project in which the extension is opened. By default, this project will be * published as long as a [set][modules] of modules to publish is not specified explicitly. @@ -240,9 +250,10 @@ open class SpinePublishing(private val project: Project) { * )} * ``` * - * Empty by default. + * If the property is not initialized, the destinations will be taken from + * the parent project. */ - var destinations: Set = emptySet() + lateinit var destinations: Set /** * A prefix to be added before the name of each artifact. @@ -318,8 +329,8 @@ open class SpinePublishing(private val project: Project) { * } * ``` * - * The resulting artifact is available under "test" classifier. For example, - * in Gradle 7+, one could depend on it like this: + * The resulting artifact is available under the "test" classifier. + * For example, in Gradle 7+, one could depend on it like this: * * ``` * implementation("io.spine:spine-client:$version@test") @@ -419,16 +430,36 @@ open class SpinePublishing(private val project: Project) { */ private fun Project.setUpPublishing(jarFlags: JarFlags) { val customPublishing = modulesWithCustomPublishing.contains(name) || customPublishing + val destinations = project.publishTo() val handler = if (customPublishing) { - CustomPublicationHandler(project, destinations) + CustomPublicationHandler.serving(project, destinations) } else { - StandardJavaPublicationHandler(project, jarFlags, destinations) + StandardJavaPublicationHandler.serving(project, destinations, jarFlags) } afterEvaluate { handler.apply() } } + /** + * Obtains the set of repositories for publishing. + * + * If there is a local instance of [io.spine.gradle.publish.SpinePublishing] extension, + * the [destinations] are obtained from this instance. + * Otherwise, the function attempts to obtain it from a [parent project][Project.getParent]. + * If there is no a parent project, an empty set is returned. + * + * The normal execution should end up at the root project of a multi-module project + * if there are no custom destinations specified by the local extension. + */ + private fun Project.publishTo(): Set { + val ext = localSpinePublishing + if (ext != null && ext::destinations.isInitialized) { + return destinations + } + return parent?.publishTo() ?: emptySet() + } + /** * Obtains an artifact ID for the given project. * @@ -447,8 +478,11 @@ open class SpinePublishing(private val project: Project) { private fun ensureProtoJarExclusionsArePublished() { val nonPublishedExclusions = protoJar.exclusions.minus(modules) if (nonPublishedExclusions.isNotEmpty()) { - throw IllegalStateException("One or more modules are marked as `excluded from proto " + - "JAR publication`, but they are not even published: $nonPublishedExclusions") + error( + "One or more modules are marked as" + + " `excluded from proto JAR publication`," + + " but they are not even published: $nonPublishedExclusions." + ) } } @@ -472,7 +506,7 @@ open class SpinePublishing(private val project: Project) { /** * Ensures that publishing of a module is configured only from a single place. * - * We allow configuration of publishing from two places - a root project and module itself. + * We allow configuration of publishing from two places - a root project and the module itself. * Here we verify that publishing of a module is not configured in both places simultaneously. */ private fun ensureModulesNotDuplicated() { diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt index 3b5b731a..06d78c10 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt @@ -40,25 +40,45 @@ import org.gradle.kotlin.dsl.create * A publication has a name and consists of one or more artifacts plus information about * those artifacts – the metadata. * - * An instance of this class represents [org.gradle.api.publish.maven.MavenPublication] named "mavenJava". It is generally - * accepted that a publication with this name contains a Java project published to one or - * more Maven repositories. + * An instance of this class represents + * [MavenPublication][org.gradle.api.publish.maven.MavenPublication] + * named [`"mavenJava"`][PUBLICATION_NAME]. + * It is generally accepted that a publication with this name contains a Java project + * published to one or more Maven repositories. * * By default, only a jar with the compilation output of `main` source set and its * metadata files are published. Other artifacts are specified through the - * [constructor parameter][jarFlags]. Please, take a look on [specifyArtifacts] for additional info. + * [constructor parameter][jarFlags]. + * Please take a look on [specifyArtifacts] for additional info. * * @param jarFlags The flags for additional JARs published along with the compilation output. * @param destinations Maven repositories to which the produced artifacts will be sent. * @see * The Maven Publish Plugin | Publications + * @see CustomPublicationHandler */ -internal class StandardJavaPublicationHandler( +internal class StandardJavaPublicationHandler private constructor( project: Project, private val jarFlags: JarFlags, destinations: Set, ) : PublicationHandler(project, destinations) { + companion object : HandlerFactory() { + + /** + * The name of the publication created by [StandardJavaPublicationHandler]. + */ + const val PUBLICATION_NAME = "mavenJava" + + override fun create( + project: Project, + destinations: Set, + vararg params: Any + ): StandardJavaPublicationHandler { + return StandardJavaPublicationHandler(project, params[0] as JarFlags, destinations) + } + } + /** * Creates a new `"mavenJava"` [MavenPublication][org.gradle.api.publish.maven.MavenPublication] * in the [project] associated with this publication handler. @@ -66,7 +86,7 @@ internal class StandardJavaPublicationHandler( override fun handlePublications() { val jars = project.artifacts(jarFlags) val publications = project.publications - publications.create("mavenJava") { + publications.create(PUBLICATION_NAME) { copyProjectAttributes() specifyArtifacts(jars) } From 8a4d9928d40de255ac3b39c95fcee7d165de1982 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 18:38:54 +0100 Subject: [PATCH 05/13] Update dependency reports --- dependencies.md | 44 ++++++++++++++++++++++---------------------- pom.xml | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dependencies.md b/dependencies.md index e6129636..f7533d05 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:spine-gradle-plugin-api:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-gradle-plugin-api:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.18.3. @@ -879,12 +879,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:50 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-gradle-plugin-api-test-fixtures:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-gradle-plugin-api-test-fixtures:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.18.3. @@ -1267,12 +1267,12 @@ This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:50 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-gradle-root-plugin:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-gradle-root-plugin:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 26.0.2. @@ -2060,12 +2060,12 @@ This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:51 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:intellij-platform:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:intellij-platform:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -2574,12 +2574,12 @@ This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:51 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:intellij-platform-java:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:intellij-platform-java:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -3860,12 +3860,12 @@ This report was generated on **Thu Apr 24 20:24:32 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-plugin-api:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-plugin-api:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 26.0.2. @@ -4601,12 +4601,12 @@ This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-plugin-base:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-plugin-base:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -5470,12 +5470,12 @@ This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-plugin-testlib:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-plugin-testlib:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : com.google.auto.value. **Name** : auto-value-annotations. **Version** : 1.10.2. @@ -6442,12 +6442,12 @@ This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-psi:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-psi:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -7541,12 +7541,12 @@ This report was generated on **Thu Apr 24 20:24:33 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:34 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-psi-java:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-psi-java:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -9370,12 +9370,12 @@ This report was generated on **Thu Apr 24 20:24:34 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:34 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-tool-base:2.0.0-SNAPSHOT.308` +# Dependencies of `io.spine.tools:spine-tool-base:2.0.0-SNAPSHOT.309` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -10260,4 +10260,4 @@ This report was generated on **Thu Apr 24 20:24:34 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 24 20:24:34 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2c22a87a..16009933 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.tools tool-base -2.0.0-SNAPSHOT.308 +2.0.0-SNAPSHOT.309 2015 From a030db6aad4d1f8ffecc5e753e37d18adf6471a6 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 19:05:25 +0100 Subject: [PATCH 06/13] Improve documentation --- .../io/spine/gradle/publish/PublicationHandler.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt index 4dfeefac..45c0bc21 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt @@ -54,7 +54,9 @@ internal sealed class PublicationHandler( protected val project: Project, protected var destinations: Set ) { - + /** + * Remembers if the [apply] function was called by this handler. + */ private var applied: Boolean = false /** @@ -80,9 +82,18 @@ internal sealed class PublicationHandler( return } project.run { + // We apply the `maven-publish` plugin for modules with standard + // publishing automatically because they don't need custom DSL + // in their `build.gradle.kts` files. + // All the job is done by the `SpinePublishing` extension and + // `StandardPublicationHandler` instance associated with this project. if (!hasCustomPublishing) { apply(plugin = MAVEN_PUBLISH) } + // And we do not apply the plugin for modules with custom publishing + // because they will need the `maven-publish` DSL to tune the publishing. + // Therefore, we only arrange the execution of our code when the plugin + // is applied. pluginManager.withPlugin(MAVEN_PUBLISH) { handlePublications() registerDestinations() From 72b9844232f5d411dc7536f203612d8ee45fc595 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 19:06:17 +0100 Subject: [PATCH 07/13] Update build time --- dependencies.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dependencies.md b/dependencies.md index f7533d05..dbb58c60 100644 --- a/dependencies.md +++ b/dependencies.md @@ -879,7 +879,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:50 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -1267,7 +1267,7 @@ This report was generated on **Fri Apr 25 18:33:50 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:50 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2060,7 +2060,7 @@ This report was generated on **Fri Apr 25 18:33:50 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:51 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2574,7 +2574,7 @@ This report was generated on **Fri Apr 25 18:33:51 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:51 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -3860,7 +3860,7 @@ This report was generated on **Fri Apr 25 18:33:51 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -4601,7 +4601,7 @@ This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -5470,7 +5470,7 @@ This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -6442,7 +6442,7 @@ This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -7541,7 +7541,7 @@ This report was generated on **Fri Apr 25 18:33:52 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -9370,7 +9370,7 @@ This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -10260,4 +10260,4 @@ This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 18:33:53 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file From 132ce60571ae5c67db500d8511b5a21f21ef7400 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 19:07:47 +0100 Subject: [PATCH 08/13] Fix doc language --- .../main/kotlin/io/spine/gradle/publish/PublicationHandler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt index 45c0bc21..1d88e188 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt @@ -43,7 +43,7 @@ private const val MAVEN_PUBLISH = "maven-publish" * Abstract base for handlers of publications in a project * with [spinePublishing] settings declared. * - * @param project The project to which the handler applied. + * @param project The project to which the handler is applied. * @param destinations The repositories for publishing artifacts of this project. * In a multi-module project the destinations can be re-defined by * specifying custom values of in From c89266aa982633aa8e6f0cc8d2d669a334bb658a Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 19:08:48 +0100 Subject: [PATCH 09/13] Fix doc language --- .../main/kotlin/io/spine/gradle/publish/PublicationHandler.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt index 1d88e188..1e10302c 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt @@ -46,9 +46,9 @@ private const val MAVEN_PUBLISH = "maven-publish" * @param project The project to which the handler is applied. * @param destinations The repositories for publishing artifacts of this project. * In a multi-module project the destinations can be re-defined by - * specifying custom values of in + * specifying custom values in * the [`spinePublishing`][io.spine.gradle.publish.SpinePublishing.destinations] - * of the subproject. + * extension applied to the subproject. */ internal sealed class PublicationHandler( protected val project: Project, From 4d7817ac4f64e96cc2837e5e2c26ce8e39a2658a Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 19:10:40 +0100 Subject: [PATCH 10/13] Document generic parameter --- .../main/kotlin/io/spine/gradle/publish/PublicationHandler.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt index 1e10302c..ce25f513 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt @@ -154,7 +154,7 @@ internal sealed class PublicationHandler( } /** - * The abstract base for factories of producing instances of classes + * The abstract base for factories producing instances of classes * derived from [io.spine.gradle.publish.PublicationHandler]. * * The factory maintains associations between a path of the project to @@ -165,6 +165,7 @@ internal sealed class PublicationHandler( * * Otherwise, a new handler is created and associated with the project. * + * @param H The type of the publication handlers produced by this repository. * @see serving */ abstract class HandlerFactory { From ac498ba969705fcefc1bb9ace139aaa20422e70e Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 20:08:18 +0100 Subject: [PATCH 11/13] Move `ProtobufTaskName` to proper package ... thus addressing #119. --- .../tools/gradle/protobuf/ProtobufTaskName.kt | 76 +++++++++++++++++++ .../tools/gradle/task/ProtobufTaskName.kt | 49 ++++++++++-- .../spine/tools/gradle/given/StubProject.java | 4 +- .../gradle/task/GradleTaskBuilderSpec.kt | 6 +- 4 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 plugin-base/src/main/kotlin/io/spine/tools/gradle/protobuf/ProtobufTaskName.kt diff --git a/plugin-base/src/main/kotlin/io/spine/tools/gradle/protobuf/ProtobufTaskName.kt b/plugin-base/src/main/kotlin/io/spine/tools/gradle/protobuf/ProtobufTaskName.kt new file mode 100644 index 00000000..e8c65987 --- /dev/null +++ b/plugin-base/src/main/kotlin/io/spine/tools/gradle/protobuf/ProtobufTaskName.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2025, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.tools.gradle.protobuf + +import io.spine.tools.code.SourceSetName +import io.spine.tools.code.SourceSetName.Companion.main +import io.spine.tools.code.SourceSetName.Companion.test +import io.spine.tools.gradle.task.TaskName +import io.spine.tools.gradle.task.TaskWithSourceSetName + +/** + * Names of Gradle tasks defined by the Protobuf Gradle plugin. + * + * ### API Note + * + * The class is made open only to support package migration of + * [io.spine.tools.gradle.task.ProtobufTaskName], which is deprecated in favor of + * this one. Once the deprecated class is removed, this class should become final. + * + * @see Protobuf Gradle plugin + */ +public open class ProtobufTaskName(value: String, ssn: SourceSetName) : + TaskWithSourceSetName(value, ssn) { + + public companion object { + + /** + * Obtains a name of the `generateProto` task for the specified source set. + */ + @JvmStatic + public fun generateProto(ssn: SourceSetName): TaskName = + ProtobufTaskName("generate${ssn.toInfix()}Proto", ssn) + + /** + * Generates production code from Protobuf. + * + * Note that this task is not a public API of the plugin. + * Users should be conscious and cautious when depending on it. + */ + @JvmField + public val generateProto: TaskName = generateProto(main) + + /** + * Generates test code from Protobuf. + * + * Note that this task is not a public API of the plugin. + * Users should be conscious and cautious when depending on it. + */ + @JvmField + public val generateTestProto: TaskName = generateProto(test) + } +} diff --git a/plugin-base/src/main/kotlin/io/spine/tools/gradle/task/ProtobufTaskName.kt b/plugin-base/src/main/kotlin/io/spine/tools/gradle/task/ProtobufTaskName.kt index f7a1686b..9435fc2b 100644 --- a/plugin-base/src/main/kotlin/io/spine/tools/gradle/task/ProtobufTaskName.kt +++ b/plugin-base/src/main/kotlin/io/spine/tools/gradle/task/ProtobufTaskName.kt @@ -1,11 +1,11 @@ /* - * Copyright 2022, TeamDev. All rights reserved. + * Copyright 2025, TeamDev. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Redistribution and use in source and/or binary forms, with or without * modification, must retain the above copyright notice and the following @@ -23,28 +23,49 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package io.spine.tools.gradle.task import io.spine.tools.code.SourceSetName import io.spine.tools.code.SourceSetName.Companion.main import io.spine.tools.code.SourceSetName.Companion.test +import io.spine.tools.gradle.protobuf.ProtobufTaskName + +private const val NEW_CLASS_NAME = "io.spine.tools.gradle.protobuf.ProtobufTaskName" + +private const val IMPORT = "NEW_CLASS_NAME" /** * Names of Gradle tasks defined by the Protobuf Gradle plugin. * * @see Protobuf Gradle plugin */ +@Deprecated( + message = "Please use `$NEW_CLASS_NAME`.", + replaceWith = ReplaceWith( + "ProtobufTaskName", + imports = [IMPORT] + ) +) public class ProtobufTaskName(value: String, ssn: SourceSetName) : - TaskWithSourceSetName(value, ssn) { + ProtobufTaskName(value, ssn) { public companion object { /** * Obtains a name of the `generateProto` task for the specified source set. */ + @Deprecated( + message = + "Please use `$NEW_CLASS_NAME.generateProto` instead.", + replaceWith = ReplaceWith( + "ProtobufTaskName.generateProto", + imports = [IMPORT] + ) + ) @JvmStatic public fun generateProto(ssn: SourceSetName): TaskName = - ProtobufTaskName("generate${ssn.toInfix()}Proto", ssn) + ProtobufTaskName.generateProto(ssn) /** * Generates production code from Protobuf. @@ -52,8 +73,16 @@ public class ProtobufTaskName(value: String, ssn: SourceSetName) : * Note that this task is not a public API of the plugin. * Users should be conscious and cautious when depending on it. */ + @Deprecated( + message = + "Please use `$NEW_CLASS_NAME.generateProto` instead.", + replaceWith = ReplaceWith( + "ProtobufTaskName.generateProto", + imports = [IMPORT] + ) + ) @JvmField - public val generateProto: TaskName = generateProto(main) + public val generateProto: TaskName = ProtobufTaskName.generateProto(main) /** * Generates test code from Protobuf. @@ -61,7 +90,15 @@ public class ProtobufTaskName(value: String, ssn: SourceSetName) : * Note that this task is not a public API of the plugin. * Users should be conscious and cautious when depending on it. */ + @Deprecated( + message = + "Please use `$NEW_CLASS_NAME.generateTestProto` instead.", + replaceWith = ReplaceWith( + "ProtobufTaskName.generateTestProto", + imports = [IMPORT] + ) + ) @JvmField - public val generateTestProto: TaskName = generateProto(test) + public val generateTestProto: TaskName = ProtobufTaskName.generateProto(test) } } diff --git a/plugin-base/src/test/java/io/spine/tools/gradle/given/StubProject.java b/plugin-base/src/test/java/io/spine/tools/gradle/given/StubProject.java index b38f6076..e6de4938 100644 --- a/plugin-base/src/test/java/io/spine/tools/gradle/given/StubProject.java +++ b/plugin-base/src/test/java/io/spine/tools/gradle/given/StubProject.java @@ -32,8 +32,8 @@ import java.io.File; -import static io.spine.tools.gradle.task.ProtobufTaskName.generateProto; -import static io.spine.tools.gradle.task.ProtobufTaskName.generateTestProto; +import static io.spine.tools.gradle.protobuf.ProtobufTaskName.generateProto; +import static io.spine.tools.gradle.protobuf.ProtobufTaskName.generateTestProto; import static org.gradle.internal.impldep.com.google.common.base.Preconditions.checkNotNull; /** diff --git a/plugin-base/src/test/kotlin/io/spine/tools/gradle/task/GradleTaskBuilderSpec.kt b/plugin-base/src/test/kotlin/io/spine/tools/gradle/task/GradleTaskBuilderSpec.kt index e7d28a0a..979ac838 100644 --- a/plugin-base/src/test/kotlin/io/spine/tools/gradle/task/GradleTaskBuilderSpec.kt +++ b/plugin-base/src/test/kotlin/io/spine/tools/gradle/task/GradleTaskBuilderSpec.kt @@ -37,8 +37,8 @@ import io.spine.tools.gradle.task.GivenTaskName.preClean import io.spine.tools.gradle.task.GivenTaskName.verifyModel import io.spine.tools.gradle.task.JavaTaskName.Companion.classes import io.spine.tools.gradle.task.JavaTaskName.Companion.compileJava -import io.spine.tools.gradle.task.ProtobufTaskName.Companion.generateProto -import io.spine.tools.gradle.task.ProtobufTaskName.Companion.generateTestProto +import io.spine.tools.gradle.protobuf.ProtobufTaskName.Companion.generateProto +import io.spine.tools.gradle.protobuf.ProtobufTaskName.Companion.generateTestProto import io.spine.tools.gradle.testing.GradleProject import io.spine.tools.gradle.testing.NoOp import java.io.File @@ -156,6 +156,6 @@ internal class GradleTaskBuilderSpec { inputs.files.files ) inputFiles shouldHaveSize 1 - inputFiles[0]!!.canonicalFile shouldBe input.canonicalFile + inputFiles[0].canonicalFile shouldBe input.canonicalFile } } From c3c7adc8f78dd4be6a079306475aeef39d43b833 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 20:10:32 +0100 Subject: [PATCH 12/13] Remove the duplication strategy ... because the task is not yet available, and the build fails. This is related to the changes in the mechanism of applying publication handlers we've introduced. --- tool-base/build.gradle.kts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tool-base/build.gradle.kts b/tool-base/build.gradle.kts index d9aac673..844345c1 100644 --- a/tool-base/build.gradle.kts +++ b/tool-base/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2024, TeamDev. All rights reserved. + * Copyright 2025, TeamDev. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,15 +164,3 @@ fun Project.applyGeneratedDirectories(generatedDir: String) { } } } - -/** - * Make the `sourcesJar` task accept duplicated input which seems to occur - * somewhere inside either ProtoData or McJava. - */ -project.afterEvaluate { - @Suppress("unused") // Used via `by` syntax. - val sourcesJar by tasks.getting { - this as Jar - duplicatesStrategy = DuplicatesStrategy.INCLUDE - } -} From b1b46020f8a7283bef9c697b9388e196c7f5ac64 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Fri, 25 Apr 2025 20:10:39 +0100 Subject: [PATCH 13/13] Update build time --- dependencies.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dependencies.md b/dependencies.md index dbb58c60..86568b9b 100644 --- a/dependencies.md +++ b/dependencies.md @@ -879,7 +879,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:41 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -1267,7 +1267,7 @@ This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:41 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2060,7 +2060,7 @@ This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:41 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2574,7 +2574,7 @@ This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:41 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -3860,7 +3860,7 @@ This report was generated on **Fri Apr 25 19:05:37 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:41 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -4601,7 +4601,7 @@ This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:42 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -5470,7 +5470,7 @@ This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:42 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -6442,7 +6442,7 @@ This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:42 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -7541,7 +7541,7 @@ This report was generated on **Fri Apr 25 19:05:38 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:42 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -9370,7 +9370,7 @@ This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Fri Apr 25 20:04:43 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -10260,4 +10260,4 @@ This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 25 19:05:39 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Fri Apr 25 20:04:43 WEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file