diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 26ca9a0..3796f0e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -12,7 +12,7 @@ repositories { dependencies { implementation(kotlin("stdlib")) implementation(gradleApi()) - implementation("com.google.protobuf:protobuf-java:3.24.1") + implementation("com.google.protobuf:protobuf-javalite:3.24.2") } kotlin { @@ -21,6 +21,16 @@ kotlin { protobuf { protoc { - artifact = "com.google.protobuf:protoc:3.24.1" + artifact = "com.google.protobuf:protoc:3.24.2" + } + + generateProtoTasks { + ofSourceSet("main").forEach { task -> + task.builtins { + getByName("java") { + option("lite") + } + } + } } } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt index 63052ed..2bc1191 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt @@ -7,53 +7,57 @@ import org.gradle.api.Project * Gradle build configurator. */ object BuildWorkflow { + /** * Returns build configuration handler of this project. */ - fun of(project: Project): ConfigurationHandler { - /** - * Build configuration handler that applies configuration to project. - */ - class BuildConfigurationHandler(private val project: Project) : ConfigurationHandler { + fun of(project: Project): BuildConfigurationHandler { + /** inheritDoc */ + class Handler(private val project: Project) : BuildConfigurationHandler { /** inheritDoc */ - override fun use(plugin: Plugin): ConfigurationHandler { + override fun use(plugin: Plugin): BuildConfigurationHandler { plugin.apply(this.project) return this } /** inheritDoc */ - override fun setGroup(group: String): ConfigurationHandler { + override fun setGroup(group: String): BuildConfigurationHandler { this.project.group = group return this } /** inheritDoc */ - override fun setVersion(version: String): ConfigurationHandler { + override fun setVersion(version: String): BuildConfigurationHandler { this.project.version = version return this } } - return BuildConfigurationHandler(project) + + return Handler(project) } - interface ConfigurationHandler { + /** + * Build configuration handler that applies configuration to a project. + */ + interface BuildConfigurationHandler { + /** * Puts plugin into operation */ - fun use(plugin: Plugin): ConfigurationHandler + fun use(plugin: Plugin): BuildConfigurationHandler /** * Sets the group of this project. * * @param group The group of this project. */ - fun setGroup(group: String): ConfigurationHandler + fun setGroup(group: String): BuildConfigurationHandler /** * Sets the version of this project. * * @param version The version of this project. */ - fun setVersion(version: String): ConfigurationHandler + fun setVersion(version: String): BuildConfigurationHandler } } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleConfiguration.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleConfiguration.kt index adb8bf9..714c346 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleConfiguration.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleConfiguration.kt @@ -6,55 +6,64 @@ import org.gradle.api.Project import org.gradle.api.plugins.quality.Checkstyle import org.gradle.api.plugins.quality.CheckstyleExtension -private const val CHECKSTYLE_PLUGIN_ID = "checkstyle" - +/** + * Checkstyle plugin configuration. + */ class CheckstyleConfiguration( private val toolVersion: String, private val reportFormats: List ) : Plugin { - override fun apply(project: Project) { - this.setupPlugin(project) - this.enableReports(project) - } - - private fun setupPlugin(project: Project) { - project.plugins.apply(CHECKSTYLE_PLUGIN_ID) - project.extensions - .getByType(CheckstyleExtension::class.java) - .toolVersion = this.toolVersion - } - - private fun enableReports(project: Project) { - project.tasks - .withType(Checkstyle::class.java) - .configureEach { checkstyle -> - for (format in this.reportFormats) { - format.subscribeTo(checkstyle.reports) - } - } - } - companion object { + private const val CHECKSTYLE_PLUGIN_ID = "checkstyle" + + /** Returns new plugin configuration builder. */ fun newBuilder() = Builder() + /** The configuration builder */ class Builder { private var toolVersion = Presets.CHECKSTYLE.version() private val enabledFormats = mutableListOf() + /** Sets Checkstyle tool version. */ fun setVersion(version: String): Builder { this.toolVersion = version return this } + /** Enables Checkstyle report format. */ fun enable(reportFormat: CheckstyleReportFormat): Builder { this.enabledFormats.add(reportFormat) return this } + /** Returns new Checkstyle plugin configuration. */ fun build() = CheckstyleConfiguration(this.toolVersion, this.enabledFormats) } } + + /** @inheritDoc */ + override fun apply(project: Project) { + this.setupPlugin(project) + this.enableReports(project) + } + + private fun setupPlugin(project: Project) { + project.plugins.apply(CHECKSTYLE_PLUGIN_ID) + project.extensions + .getByType(CheckstyleExtension::class.java) + .toolVersion = this.toolVersion + } + + private fun enableReports(project: Project) { + project.tasks + .withType(Checkstyle::class.java) + .configureEach { checkstyle -> + for (format in this.reportFormats) { + format.subscribeTo(checkstyle.reports) + } + } + } } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleReportFormat.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleReportFormat.kt index f1a3f64..93f5504 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleReportFormat.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/checkstyle/CheckstyleReportFormat.kt @@ -5,16 +5,19 @@ import org.gradle.api.plugins.quality.CheckstyleReports enum class CheckstyleReportFormat { HTML { + /**@inheritDoc */ override fun subscribeTo(checkstyleReports: CheckstyleReports) { checkstyleReports.html.required.set(true) } }, XML { + /**@inheritDoc */ override fun subscribeTo(checkstyleReports: CheckstyleReports) { checkstyleReports.xml.required.set(true) } }; + /** Subscribes to generate report type. */ abstract fun subscribeTo(checkstyleReports: CheckstyleReports) } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoConfiguration.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoConfiguration.kt index 99324e7..2793f27 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoConfiguration.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoConfiguration.kt @@ -5,14 +5,41 @@ import org.gradle.api.Project import org.gradle.api.tasks.testing.Test import org.gradle.testing.jacoco.tasks.JacocoReport -private const val JACOCO_PLUGIN_ID = "jacoco" +/** + * Jacoco plugin configuration. + */ +class JacocoConfiguration private constructor( + private val reportFormats: List +) : Plugin { -class JacocoConfiguration private constructor(private val reportFormats: List) : - Plugin { + companion object { + + private const val JACOCO_PLUGIN_ID = "jacoco" + + /** Returns new plugin configuration builder. */ + fun newBuilder() = Builder() + + /** The configuration builder */ + class Builder { + + private val enabledFormats = mutableListOf() + + /** Enables Jacoco report format. */ + fun enable(reportFormat: JacocoReportFormat): Builder { + this.enabledFormats.add(reportFormat) + return this + } + + /** Returns new Jacoco plugin configuration. */ + fun build() = JacocoConfiguration(this.enabledFormats) + } + } + /** @inheritDoc */ override fun apply(project: Project) { this.setupPlugin(project) this.enableReports(project) + this.addTaskFinalizer(project) } private fun setupPlugin(project: Project) { @@ -28,29 +55,12 @@ class JacocoConfiguration private constructor(private val reportFormats: List test.finalizedBy(project.tasks.withType(JacocoReport::class.java)) } } - - companion object { - /** - * Returns new JacocoConfigurationBuilder instance. - */ - fun newBuilder() = Builder() - - class Builder { - - private val enabledFormats = mutableListOf() - - fun enable(reportFormat: JacocoReportFormat): Builder { - this.enabledFormats.add(reportFormat) - return this - } - - fun build() = JacocoConfiguration(this.enabledFormats) - } - } } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoReportFormat.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoReportFormat.kt index e5ce2ad..4ff1a68 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoReportFormat.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/jacoco/JacocoReportFormat.kt @@ -5,22 +5,26 @@ import org.gradle.testing.jacoco.tasks.JacocoReportsContainer enum class JacocoReportFormat { HTML { + /**@inheritDoc */ override fun subscribeTo(jacocoReportContainer: JacocoReportsContainer) { jacocoReportContainer.html.required.set(true); } }, XML { + /**@inheritDoc */ override fun subscribeTo(jacocoReportContainer: JacocoReportsContainer) { jacocoReportContainer.xml.required.set(true); } }, CSV { + /**@inheritDoc */ override fun subscribeTo(jacocoReportContainer: JacocoReportsContainer) { jacocoReportContainer.csv.required.set(true); } }; + /** Subscribes to generate report type. */ abstract fun subscribeTo(jacocoReportContainer: JacocoReportsContainer) } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyConfiguration.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyConfiguration.kt new file mode 100644 index 0000000..c64cb67 --- /dev/null +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyConfiguration.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + +package co.raccoons.local.gradle.java + +import org.gradle.api.Plugin +import org.gradle.api.Project + +/** + * The scopes of the dependencies. + */ +internal class DependencyConfiguration : Plugin { + + private val dependencyScopes = mutableMapOf>() + + /** @inheritDoc */ + override fun apply(project: Project) { + for ((configurationScope, dependencies) in dependencyScopes) { + for (dependency in dependencies) { + project.dependencies.add(configurationScope, dependency) + } + } + } + + /** Adds dependency to the corresponding configuration scope. */ + fun add(dependency: Dependency): DependencyConfiguration { + this.dependencyScopes + .getOrPut(dependency.configurationName()) { + mutableListOf() + } + .add(dependency.dependencyNotation().toString()) + + return this + } +} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyNotation.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyNotation.kt index 9840d5e..019fe5d 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyNotation.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyNotation.kt @@ -6,7 +6,7 @@ package co.raccoons.local.gradle.java -class DependencyNotation( +data class DependencyNotation( private val group: String, private val name: String, private val version: String diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyScope.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyScope.kt deleted file mode 100644 index c40e035..0000000 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyScope.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2023, Raccoons. Developing simple way to change. - * - * @license MIT - */ - -package co.raccoons.local.gradle.java - -import org.gradle.api.Plugin -import org.gradle.api.Project - -class DependencyScope : Plugin { - - private val dependencies = mutableMapOf>() - - override fun apply(project: Project) { - for ((configurationName, configurationDependencies) in dependencies) { - for (dependency in configurationDependencies) { - project.dependencies.add(configurationName, dependency) - } - } - } - - fun add(dependency: Dependency): DependencyScope { - this.dependencies.getOrPut(dependency.configurationName()) { - mutableListOf() - }.add(dependency.dependencyNotation().toString()) - - return this - } -} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Implementation.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Implementation.kt index c4d087a..b4d64d1 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Implementation.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Implementation.kt @@ -6,10 +6,16 @@ package co.raccoons.local.gradle.java -private const val CONFIGURATION_NAME = "implementation" +/** + * Implementation dependency. + */ +data class Implementation( + private val group: String, + private val name: String, + private val version: String +) : Dependency(CONFIGURATION_NAME, DependencyNotation(group, name, version)) { -class Implementation( - group: String, - name: String, - version: String -) : Dependency(CONFIGURATION_NAME, DependencyNotation(group, name, version)) + companion object { + private const val CONFIGURATION_NAME = "implementation" + } +} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/JavaConfiguration.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/JavaConfiguration.kt new file mode 100644 index 0000000..d2f05a7 --- /dev/null +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/JavaConfiguration.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + +package co.raccoons.local.gradle.java + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.bundling.Jar + +/** + * The Java plugin configuration. + */ +class JavaConfiguration(private final val manifest: Manifest) : Plugin { + + companion object { + private const val JAVA_PLUGIN_ID = "java" + } + + /** @inheritDoc */ + override fun apply(project: Project) { + this.setupPlugin(project) + this.configureTaskJar(project) + } + + private fun setupPlugin(project: Project) { + project.plugins.apply(JAVA_PLUGIN_ID) + } + + private fun configureTaskJar(project: Project) { + project.tasks + .withType(Jar::class.java) + .configureEach { jar -> + jar.manifest.attributes + .putAll(this.manifest.attributesMap) + } + } +} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/JavaLibraryConfiguration.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/JavaLibraryConfiguration.kt index d3caf9d..39062c1 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/JavaLibraryConfiguration.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/JavaLibraryConfiguration.kt @@ -3,36 +3,39 @@ package co.raccoons.local.gradle.java import org.gradle.api.Plugin import org.gradle.api.Project -private const val JAVA_LIBRARY_PLUGIN_ID = "java-library" - -class JavaLibraryConfiguration private constructor(private val dependencyScope: DependencyScope) : - Plugin { - - override fun apply(project: Project) { - this.setupPlugin(project) - } - - private fun setupPlugin(project: Project) { - project.plugins.apply(JAVA_LIBRARY_PLUGIN_ID) - dependencyScope.apply(project) - } +/** + * The Java Library plugin configuration. + */ +class JavaLibraryConfiguration private constructor( + private val dependencyConfiguration: DependencyConfiguration +) : Plugin { companion object { + private const val JAVA_LIBRARY_PLUGIN_ID = "java-library" - fun default() = this.newBuilder().build() + /** Returns default configuration of the Java Library plugin. */ + fun default(): JavaLibraryConfiguration = newBuilder().build() + /** Returns new plugin configuration builder. */ fun newBuilder() = Builder() + /** The configuration builder */ class Builder { - private val dependencyScope = DependencyScope() + private val dependencyConfiguration = DependencyConfiguration() fun addDependency(dependency: Dependency): Builder { - this.dependencyScope.add(dependency) + dependencyConfiguration.add(dependency) return this } - fun build() = JavaLibraryConfiguration(this.dependencyScope) + fun build() = JavaLibraryConfiguration(this.dependencyConfiguration) } } + + /** @inheritDoc */ + override fun apply(project: Project) { + project.plugins.apply(JAVA_LIBRARY_PLUGIN_ID) + dependencyConfiguration.apply(project) + } } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/TestImplementation.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/TestImplementation.kt index ceb5cc4..ac07b7f 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/TestImplementation.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/TestImplementation.kt @@ -6,10 +6,16 @@ package co.raccoons.local.gradle.java -private const val CONFIGURATION_NAME = "testImplementation" +/** + * Test implementation dependency. + */ +data class TestImplementation( + private val group: String, + private val name: String, + private val version: String +) : Dependency(CONFIGURATION_NAME, DependencyNotation(group, name, version)) { -class TestImplementation( - group: String, - name: String, - version: String -) : Dependency(CONFIGURATION_NAME, DependencyNotation(group, name, version)) + companion object { + private const val CONFIGURATION_NAME = "testImplementation" + } +} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/javacompile/Version.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Version.kt similarity index 84% rename from buildSrc/src/main/kotlin/co/raccoons/local/gradle/javacompile/Version.kt rename to buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Version.kt index ee53a06..8384aae 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/javacompile/Version.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Version.kt @@ -1,4 +1,10 @@ -package co.raccoons.local.gradle.javacompile +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + +package co.raccoons.local.gradle.java import org.gradle.api.Plugin import org.gradle.api.Project diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/javadoc/JavadocConfiguration.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/javadoc/JavadocConfiguration.kt index 5b05410..0201195 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/javadoc/JavadocConfiguration.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/javadoc/JavadocConfiguration.kt @@ -5,34 +5,36 @@ import org.gradle.api.Project import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.external.javadoc.StandardJavadocDocletOptions +/** + * Javadoc plugin configuration. + */ class JavadocConfiguration private constructor(private val tags: List) : Plugin { - override fun apply(project: Project) { - this.setupPlugin(project) - } - - private fun setupPlugin(project: Project) { - project.tasks - .withType(Javadoc::class.java) - .configureEach { javadoc -> - (javadoc.options as StandardJavadocDocletOptions).tags(tags) - } - } - companion object { + /** Returns new plugin configuration builder. */ fun newBuilder() = Builder() + /** The configuration builder */ class Builder { private val tags = mutableListOf() fun addTag(tag: JavadocTag): Builder { - this.tags.add(tag.toString()) + tags.add(tag.toString()) return this } - fun build() = JavadocConfiguration(this.tags.toList()) + fun build() = JavadocConfiguration(tags.toList()) } } + + /** @inheritDoc */ + override fun apply(project: Project) { + project.tasks + .withType(Javadoc::class.java) + .configureEach { javadoc -> + (javadoc.options as StandardJavadocDocletOptions).tags(tags) + } + } } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/repository/Repository.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/repository/Repository.kt index 10460e6..96b10bd 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/repository/Repository.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/repository/Repository.kt @@ -3,15 +3,20 @@ package co.raccoons.local.gradle.repository import org.gradle.api.Plugin import org.gradle.api.Project +/** + * Dependency lookup repository. + */ enum class Repository : Plugin { MAVEN_CENTRAL { + /**@inheritDoc */ override fun apply(project: Project) { project.repositories.mavenCentral() } }, MAVEN_LOCAL { + /**@inheritDoc */ override fun apply(project: Project) { project.repositories.mavenLocal() } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/test/TestNG.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/test/TestNG.kt index dc0a2fe..5c00ad0 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/test/TestNG.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/test/TestNG.kt @@ -1,41 +1,46 @@ package co.raccoons.local.gradle.test import co.raccoons.local.gradle.java.Dependency -import co.raccoons.local.gradle.java.DependencyScope +import co.raccoons.local.gradle.java.DependencyConfiguration import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.testing.Test -class TestNG private constructor(private val dependencyScope: DependencyScope) : Plugin { - - override fun apply(project: Project) { - this.setupPlugin(project) - } - - private fun setupPlugin(project: Project) { - dependencyScope.apply(project) - - project.tasks - .withType(Test::class.java) - .configureEach { test -> - test.useTestNG() - } - } +class TestNG private constructor( + private val dependencyConfiguration: DependencyConfiguration +) : Plugin { companion object { + /** Returns new plugin configuration builder. */ fun newBuilder() = Builder() + /** The configuration builder */ class Builder { - private val dependencyScope = DependencyScope() + private val dependencyConfiguration = DependencyConfiguration() fun addDependency(dependency: Dependency): Builder { - this.dependencyScope.add(dependency) + this.dependencyConfiguration.add(dependency) return this } - fun build() = TestNG(this.dependencyScope) + fun build() = TestNG(this.dependencyConfiguration) } } + + /** @inheritDoc */ + override fun apply(project: Project) { + this.setupPlugin(project) + } + + private fun setupPlugin(project: Project) { + dependencyConfiguration.apply(project) + + project.tasks + .withType(Test::class.java) + .configureEach { test -> + test.useTestNG() + } + } } diff --git a/buildSrc/src/main/proto/co/raccoons/local/gradle/java/Manifest.proto b/buildSrc/src/main/proto/co/raccoons/local/gradle/java/Manifest.proto new file mode 100644 index 0000000..e58f9f3 --- /dev/null +++ b/buildSrc/src/main/proto/co/raccoons/local/gradle/java/Manifest.proto @@ -0,0 +1,16 @@ +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + +syntax = "proto3"; + +package co.raccoons.local.gradle.java; + +option java_outer_classname = "ManifestProto"; +option java_multiple_files = true; + +message Manifest { + map attributes = 1; +} \ No newline at end of file diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 9a47763..6dd0f91 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -9,24 +9,30 @@ import co.raccoons.local.gradle.checkstyle.CheckstyleConfiguration import co.raccoons.local.gradle.checkstyle.CheckstyleReportFormat import co.raccoons.local.gradle.jacoco.JacocoConfiguration import co.raccoons.local.gradle.jacoco.JacocoReportFormat -import co.raccoons.local.gradle.java.JavaLibraryConfiguration +import co.raccoons.local.gradle.java.JavaConfiguration +import co.raccoons.local.gradle.java.Manifest import co.raccoons.local.gradle.java.TestImplementation -import co.raccoons.local.gradle.javacompile.Version +import co.raccoons.local.gradle.java.Version import co.raccoons.local.gradle.javadoc.JavadocConfiguration import co.raccoons.local.gradle.javadoc.JavadocTag import co.raccoons.local.gradle.publish.MavenPublishConfiguration -import co.raccoons.local.gradle.publish.maven.Pom import co.raccoons.local.gradle.publish.maven.License +import co.raccoons.local.gradle.publish.maven.Pom import co.raccoons.local.gradle.publish.maven.Publication import co.raccoons.local.gradle.repository.Repository import co.raccoons.local.gradle.test.TestNG +import java.time.LocalDateTime +/** + * Gradle build entry point. + */ BuildWorkflow.of(project) .setGroup("co.raccoons") .setVersion("1.0") .use(Repository.MAVEN_LOCAL) .use(Repository.MAVEN_CENTRAL) - .use(JavaLibraryConfiguration.default()) + .use(Configuration.java()) +// .use(JavaLibraryConfiguration.default()) .use(Version.JAVA.of(20)) .use(Configuration.testNG()) .use(Configuration.jacoco()) @@ -34,21 +40,38 @@ BuildWorkflow.of(project) .use(Configuration.checkstyle()) .use(Configuration.mavenPublish()) - +/** + * The configuration of the project plugins. + */ internal object Configuration { + /** Returns ready to use Java plugin configuration. */ + fun java(): JavaConfiguration { + val manifest = Manifest.newBuilder() + .putAttributes("Name", "Meeko Library") + .putAttributes("Implementation-Title", "co.raccoons.meeko") + .putAttributes("Implementation-Vendor", "Raccoons") + .putAttributes("Implementation-Build-Date", LocalDateTime.now().toString()) + .build(); + + return JavaConfiguration(manifest) + } + + /** Returns ready to use TestNG plugin configuration. */ fun testNG() = TestNG.newBuilder() .addDependency(TestImplementation("org.testng", "testng", "7.8.0")) .addDependency(TestImplementation("org.slf4j", "slf4j-simple", "2.0.7")) .build() + /** Returns ready to use Jacoco plugin configuration. */ fun jacoco() = JacocoConfiguration.newBuilder() .enable(JacocoReportFormat.HTML) .enable(JacocoReportFormat.XML) .build() + /** Returns ready to use Javadoc plugin configuration. */ fun javadoc() = JavadocConfiguration.newBuilder() .addTag(JavadocTag("apiNote", "API Note")) @@ -56,12 +79,14 @@ internal object Configuration { .addTag(JavadocTag("implNote", "Implementation Note")) .build() + /** Returns ready to use Checkstyle plugin configuration. */ fun checkstyle() = CheckstyleConfiguration.newBuilder() .setVersion("10.12.2") .enable(CheckstyleReportFormat.HTML) .build() + /** Returns ready to use Maven publish plugin configuration. */ fun mavenPublish(): MavenPublishConfiguration { val license = License.newBuilder() diff --git a/lib/src/main/java/co/raccoons/meeko/Optional.java b/lib/src/main/java/co/raccoons/meeko/util/Optional.java similarity index 93% rename from lib/src/main/java/co/raccoons/meeko/Optional.java rename to lib/src/main/java/co/raccoons/meeko/util/Optional.java index 3848ca7..fe6880b 100644 --- a/lib/src/main/java/co/raccoons/meeko/Optional.java +++ b/lib/src/main/java/co/raccoons/meeko/util/Optional.java @@ -1,33 +1,14 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * Copyright 2023, Raccoons. Developing simple way to change. * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. + * @license MIT */ /* * @summary Refactored java.util.Optional * @author Oleksii Kucheruk */ -package co.raccoons.meeko; +package co.raccoons.meeko.util; import java.util.NoSuchElementException; import java.util.Objects; diff --git a/lib/src/main/java/co/raccoons/meeko/OptionalDouble.java b/lib/src/main/java/co/raccoons/meeko/util/OptionalDouble.java similarity index 90% rename from lib/src/main/java/co/raccoons/meeko/OptionalDouble.java rename to lib/src/main/java/co/raccoons/meeko/util/OptionalDouble.java index ab89449..91a956e 100644 --- a/lib/src/main/java/co/raccoons/meeko/OptionalDouble.java +++ b/lib/src/main/java/co/raccoons/meeko/util/OptionalDouble.java @@ -1,33 +1,14 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * Copyright 2023, Raccoons. Developing simple way to change. * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. + * @license MIT */ /* * @summary Refactored java.util.OptionalDouble * @author Oleksii Kucheruk */ -package co.raccoons.meeko; +package co.raccoons.meeko.util; import java.util.NoSuchElementException; import java.util.Objects; diff --git a/lib/src/main/java/co/raccoons/meeko/OptionalInt.java b/lib/src/main/java/co/raccoons/meeko/util/OptionalInt.java similarity index 90% rename from lib/src/main/java/co/raccoons/meeko/OptionalInt.java rename to lib/src/main/java/co/raccoons/meeko/util/OptionalInt.java index dbf998a..1152ef8 100644 --- a/lib/src/main/java/co/raccoons/meeko/OptionalInt.java +++ b/lib/src/main/java/co/raccoons/meeko/util/OptionalInt.java @@ -1,33 +1,14 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * Copyright 2023, Raccoons. Developing simple way to change. * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. + * @license MIT */ /* * @summary Refactored java.util.OptionalInt * @author Oleksii Kucheruk */ -package co.raccoons.meeko; +package co.raccoons.meeko.util; import java.util.NoSuchElementException; import java.util.Objects; diff --git a/lib/src/main/java/co/raccoons/meeko/OptionalLong.java b/lib/src/main/java/co/raccoons/meeko/util/OptionalLong.java similarity index 90% rename from lib/src/main/java/co/raccoons/meeko/OptionalLong.java rename to lib/src/main/java/co/raccoons/meeko/util/OptionalLong.java index 6da37dd..be3014f 100644 --- a/lib/src/main/java/co/raccoons/meeko/OptionalLong.java +++ b/lib/src/main/java/co/raccoons/meeko/util/OptionalLong.java @@ -1,33 +1,14 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * Copyright 2023, Raccoons. Developing simple way to change. * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. + * @license MIT */ /* * @summary Refactored java.util.OptionalLong * @author Oleksii Kucheruk */ -package co.raccoons.meeko; +package co.raccoons.meeko.util; import java.util.NoSuchElementException; import java.util.Objects; diff --git a/lib/src/main/java/co/raccoons/meeko/package-info.java b/lib/src/main/java/co/raccoons/meeko/util/package-info.java similarity index 62% rename from lib/src/main/java/co/raccoons/meeko/package-info.java rename to lib/src/main/java/co/raccoons/meeko/util/package-info.java index 823f92d..4cb9111 100644 --- a/lib/src/main/java/co/raccoons/meeko/package-info.java +++ b/lib/src/main/java/co/raccoons/meeko/util/package-info.java @@ -5,6 +5,6 @@ */ /** - * Meeko package + * Meeko Java utilities. */ -package co.raccoons.meeko; +package co.raccoons.meeko.util; diff --git a/lib/src/main/proto/raccoons/Person.proto b/lib/src/main/proto/raccoons/Person.proto new file mode 100644 index 0000000..bae2c10 --- /dev/null +++ b/lib/src/main/proto/raccoons/Person.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package raccoons; + +message Person { + optional string name = 1; + optional int32 id = 2; + optional string email = 3; +} diff --git a/lib/src/test/java/co/raccoons/meeko/OptionalDoubleTest.java b/lib/src/test/java/co/raccoons/meeko/OptionalDoubleTest.java index 0c221a2..8284933 100644 --- a/lib/src/test/java/co/raccoons/meeko/OptionalDoubleTest.java +++ b/lib/src/test/java/co/raccoons/meeko/OptionalDoubleTest.java @@ -30,6 +30,7 @@ */ package co.raccoons.meeko; +import co.raccoons.meeko.util.OptionalDouble; import org.testng.annotations.Test; import java.util.NoSuchElementException; diff --git a/lib/src/test/java/co/raccoons/meeko/OptionalIntTest.java b/lib/src/test/java/co/raccoons/meeko/OptionalIntTest.java index 0e2c757..619b1e1 100644 --- a/lib/src/test/java/co/raccoons/meeko/OptionalIntTest.java +++ b/lib/src/test/java/co/raccoons/meeko/OptionalIntTest.java @@ -30,6 +30,7 @@ */ package co.raccoons.meeko; +import co.raccoons.meeko.util.OptionalInt; import org.testng.annotations.Test; import java.util.NoSuchElementException; diff --git a/lib/src/test/java/co/raccoons/meeko/OptionalLongTest.java b/lib/src/test/java/co/raccoons/meeko/OptionalLongTest.java index f8f5dda..2da07e1 100644 --- a/lib/src/test/java/co/raccoons/meeko/OptionalLongTest.java +++ b/lib/src/test/java/co/raccoons/meeko/OptionalLongTest.java @@ -30,6 +30,7 @@ */ package co.raccoons.meeko; +import co.raccoons.meeko.util.OptionalLong; import org.testng.annotations.Test; import java.util.NoSuchElementException; diff --git a/lib/src/test/java/co/raccoons/meeko/OptionalTest.java b/lib/src/test/java/co/raccoons/meeko/OptionalTest.java index dc07012..f9e4ad9 100644 --- a/lib/src/test/java/co/raccoons/meeko/OptionalTest.java +++ b/lib/src/test/java/co/raccoons/meeko/OptionalTest.java @@ -30,6 +30,7 @@ */ package co.raccoons.meeko; +import co.raccoons.meeko.util.Optional; import org.testng.annotations.Test; import java.util.List;