From 0fa0e9e4c03ceecdaa508b82e1798d3320c85091 Mon Sep 17 00:00:00 2001 From: Oleksii Kucheruk <50623030+iselo@users.noreply.github.com> Date: Thu, 24 Aug 2023 12:27:03 +0300 Subject: [PATCH] Implement MavenPublishConfiguration (#12) --- README.md | 86 +++++++++++------- buildSrc/build.gradle.kts | 8 ++ .../co/raccoons/local/gradle/BuildWorkflow.kt | 59 ++++++++++++ .../co/raccoons/local/gradle/GradleBuild.kt | 33 ------- .../co/raccoons/local/gradle/Presets.kt | 8 +- .../checkstyle/CheckstyleConfiguration.kt | 34 ++++--- .../gradle/jacoco/JacocoConfiguration.kt | 24 +++-- .../local/gradle/java/DependencyScope.kt | 4 +- .../local/gradle/java/Implementation.kt | 15 ++++ .../gradle/java/JavaLibraryConfiguration.kt | 31 ++++--- .../gradle/javadoc/JavadocConfiguration.kt | 21 +++-- .../publish/MavenPublishConfiguration.kt | 67 ++++++++++++++ .../co/raccoons/local/gradle/test/TestNG.kt | 28 ++++-- .../gradle/publish/maven/Publication.proto | 32 +++++++ lib/build.gradle.kts | 89 ++++++++++++------- .../java/co/raccoons/meeko/package-info.java | 3 + .../java/co/raccoons/meeko/package-info.java | 1 - 17 files changed, 395 insertions(+), 148 deletions(-) create mode 100644 buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt delete mode 100644 buildSrc/src/main/kotlin/co/raccoons/local/gradle/GradleBuild.kt create mode 100644 buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Implementation.kt create mode 100644 buildSrc/src/main/kotlin/co/raccoons/local/gradle/publish/MavenPublishConfiguration.kt create mode 100644 buildSrc/src/main/proto/co/raccoons/local/gradle/publish/maven/Publication.proto diff --git a/README.md b/README.md index 7c80f62..4308ffc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ build.gradle.kts --- ~~~Kotlin -import co.raccoons.local.gradle.GradleBuild +import co.raccoons.local.gradle.BuildWorkflow import co.raccoons.local.gradle.checkstyle.CheckstyleConfiguration import co.raccoons.local.gradle.checkstyle.CheckstyleReportFormat import co.raccoons.local.gradle.jacoco.JacocoConfiguration @@ -24,49 +24,75 @@ import co.raccoons.local.gradle.java.TestImplementation import co.raccoons.local.gradle.javacompile.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.Publication import co.raccoons.local.gradle.repository.Repository import co.raccoons.local.gradle.test.TestNG -GradleBuild.of(project) - .use(Repository.MAVEN_CENTRAL) +BuildWorkflow.of(project) + .setGroup("co.raccoons") + .setVersion("1.0") .use(Repository.MAVEN_LOCAL) - .use(Configuration.javaLibrary) + .use(Repository.MAVEN_CENTRAL) + .use(JavaLibraryConfiguration.default()) .use(Version.JAVA.of(20)) - .use(Configuration.testNG) - .use(Configuration.jacoco) - .use(Configuration.javadoc) - .use(Configuration.checkstyle) + .use(Configuration.testNG()) + .use(Configuration.jacoco()) + .use(Configuration.javadoc()) + .use(Configuration.checkstyle()) + .use(Configuration.mavenPublish()) -internal class Configuration { - companion object { +internal object Configuration { - val javaLibrary = - JavaLibraryConfiguration.default() + fun testNG() = + TestNG.newBuilder() + .addDependency(TestImplementation("org.testng", "testng", "7.8.0")) + .addDependency(TestImplementation("org.slf4j", "slf4j-simple", "2.0.7")) + .build() - val testNG = - TestNG.Builder() - .addDependency(TestImplementation("org.testng", "testng", "7.8.0")) - .addDependency(TestImplementation("org.slf4j", "slf4j-simple", "2.0.7")) - .build() + fun jacoco() = + JacocoConfiguration.newBuilder() + .enable(JacocoReportFormat.HTML) + .enable(JacocoReportFormat.XML) + .build() - val jacoco = - JacocoConfiguration.Builder() - .enable(JacocoReportFormat.HTML) - .enable(JacocoReportFormat.XML) + fun javadoc() = + JavadocConfiguration.newBuilder() + .addTag(JavadocTag("apiNote", "API Note")) + .addTag(JavadocTag("implSpec", "Implementation Specification")) + .addTag(JavadocTag("implNote", "Implementation Note")) + .build() + + fun checkstyle() = + CheckstyleConfiguration.newBuilder() + .setVersion("10.12.2") + .enable(CheckstyleReportFormat.HTML) + .build() + + fun mavenPublish(): MavenPublishConfiguration { + val license = + License.newBuilder() + .setName("Meeko") + .setUrl("https://opensource.org/license/mit") .build() - val javadoc = - JavadocConfiguration.Builder() - .addTag(JavadocTag("apiNote", "API Note")) - .addTag(JavadocTag("implSpec", "Implementation Specification")) - .addTag(JavadocTag("implNote", "Implementation Note")) + val pom = + Pom.newBuilder() + .setName("Meeko") + .setDescription("Java Base Util") + .setUrl("https://bus.raccoons.co/artefacts/meeko") + .setLicense(license) .build() - val checkstyle = - CheckstyleConfiguration.Builder() - .setVersion("10.12.2") - .enable(CheckstyleReportFormat.HTML) + val publication = + Publication.newBuilder() + .setArtifactId("meeko") + .setPom(pom) .build() + + return MavenPublishConfiguration(publication) } } ~~~ diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c665bef..26ca9a0 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") version "1.9.0" id("org.jlleitschuh.gradle.ktlint") version "11.5.1" + id("com.google.protobuf") version "0.9.4" } repositories { @@ -11,8 +12,15 @@ repositories { dependencies { implementation(kotlin("stdlib")) implementation(gradleApi()) + implementation("com.google.protobuf:protobuf-java:3.24.1") } kotlin { jvmToolchain(JavaLanguageVersion.of(20).asInt()) } + +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:3.24.1" + } +} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt new file mode 100644 index 0000000..63052ed --- /dev/null +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/BuildWorkflow.kt @@ -0,0 +1,59 @@ +package co.raccoons.local.gradle + +import org.gradle.api.Plugin +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 { + /** inheritDoc */ + override fun use(plugin: Plugin): ConfigurationHandler { + plugin.apply(this.project) + return this + } + + /** inheritDoc */ + override fun setGroup(group: String): ConfigurationHandler { + this.project.group = group + return this + } + + /** inheritDoc */ + override fun setVersion(version: String): ConfigurationHandler { + this.project.version = version + return this + } + } + return BuildConfigurationHandler(project) + } + + interface ConfigurationHandler { + /** + * Puts plugin into operation + */ + fun use(plugin: Plugin): ConfigurationHandler + + /** + * Sets the group of this project. + * + * @param group The group of this project. + */ + fun setGroup(group: String): ConfigurationHandler + + /** + * Sets the version of this project. + * + * @param version The version of this project. + */ + fun setVersion(version: String): ConfigurationHandler + } +} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/GradleBuild.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/GradleBuild.kt deleted file mode 100644 index daf2e59..0000000 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/GradleBuild.kt +++ /dev/null @@ -1,33 +0,0 @@ -package co.raccoons.local.gradle - -import org.gradle.api.Plugin -import org.gradle.api.Project - -/** - * Gradle build configurator. - */ -class GradleBuild private constructor() { - - companion object { - - /** - * 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 { - override fun use(plugin: Plugin): ConfigurationHandler { - plugin.apply(this.project) - return this - } - } - return BuildConfigurationHandler(project) - } - } - - fun interface ConfigurationHandler { - fun use(plugin: Plugin): ConfigurationHandler - } -} diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/Presets.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/Presets.kt index 17d0211..374054e 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/Presets.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/Presets.kt @@ -1,7 +1,13 @@ +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + package co.raccoons.local.gradle /** - * Plugins version + * Presets for plugins versions. */ enum class Presets(private val version: String) { CHECKSTYLE("10.12.2"); 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 76343c3..adb8bf9 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 @@ -20,8 +20,9 @@ class CheckstyleConfiguration( private fun setupPlugin(project: Project) { project.plugins.apply(CHECKSTYLE_PLUGIN_ID) - val checkstyleExtension = project.extensions.getByType(CheckstyleExtension::class.java) - checkstyleExtension.toolVersion = this.toolVersion + project.extensions + .getByType(CheckstyleExtension::class.java) + .toolVersion = this.toolVersion } private fun enableReports(project: Project) { @@ -34,21 +35,26 @@ class CheckstyleConfiguration( } } - class Builder { + companion object { - private var toolVersion = Presets.CHECKSTYLE.version() - private val enabledFormats = mutableListOf() + fun newBuilder() = Builder() - fun setVersion(version: String): Builder { - this.toolVersion = version - return this - } + class Builder { - fun enable(reportFormat: CheckstyleReportFormat): Builder { - this.enabledFormats.add(reportFormat) - return this - } + private var toolVersion = Presets.CHECKSTYLE.version() + private val enabledFormats = mutableListOf() + + fun setVersion(version: String): Builder { + this.toolVersion = version + return this + } - fun build() = CheckstyleConfiguration(this.toolVersion, this.enabledFormats) + fun enable(reportFormat: CheckstyleReportFormat): Builder { + this.enabledFormats.add(reportFormat) + return this + } + + fun build() = CheckstyleConfiguration(this.toolVersion, this.enabledFormats) + } } } 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 a2b82d8..b7049d2 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 @@ -6,7 +6,8 @@ import org.gradle.testing.jacoco.tasks.JacocoReport private const val JACOCO_PLUGIN_ID = "jacoco" -class JacocoConfiguration(private val reportFormats: List) : Plugin { +class JacocoConfiguration private constructor(private val reportFormats: List) : + Plugin { override fun apply(project: Project) { this.setupPlugin(project) @@ -29,15 +30,22 @@ class JacocoConfiguration(private val reportFormats: List) : } } - class Builder { + companion object { + /** + * Returns new JacocoConfigurationBuilder instance. + */ + fun newBuilder() = Builder() - private val enabledFormats = mutableListOf() + class Builder { - fun enable(reportFormat: JacocoReportFormat): Builder { - this.enabledFormats.add(reportFormat) - return this - } + private val enabledFormats = mutableListOf() + + fun enable(reportFormat: JacocoReportFormat): Builder { + this.enabledFormats.add(reportFormat) + return this + } - fun build() = JacocoConfiguration(this.enabledFormats) + fun build() = JacocoConfiguration(this.enabledFormats) + } } } 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 index 04e3c50..c40e035 100644 --- a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyScope.kt +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/DependencyScope.kt @@ -21,9 +21,11 @@ class DependencyScope : Plugin { } } - fun add(dependency: 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 new file mode 100644 index 0000000..c4d087a --- /dev/null +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/java/Implementation.kt @@ -0,0 +1,15 @@ +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + +package co.raccoons.local.gradle.java + +private const val CONFIGURATION_NAME = "implementation" + +class Implementation( + group: String, + name: String, + version: String +) : Dependency(CONFIGURATION_NAME, DependencyNotation(group, name, version)) 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 0f57cbb..d3caf9d 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,33 +3,36 @@ package co.raccoons.local.gradle.java import org.gradle.api.Plugin import org.gradle.api.Project -private const val JAVA_LIBRARY = "java-library" +private const val JAVA_LIBRARY_PLUGIN_ID = "java-library" -class JavaLibraryConfiguration(private val dependencyScope: DependencyScope) : +class JavaLibraryConfiguration private constructor(private val dependencyScope: DependencyScope) : Plugin { - companion object { - fun default() = Builder().build() - } - override fun apply(project: Project) { this.setupPlugin(project) } private fun setupPlugin(project: Project) { - project.plugins.apply(JAVA_LIBRARY) + project.plugins.apply(JAVA_LIBRARY_PLUGIN_ID) dependencyScope.apply(project) } - class Builder { + companion object { - private val dependencyScope = DependencyScope() + fun default() = this.newBuilder().build() - fun addDependency(dependency: Dependency): Builder { - this.dependencyScope.add(dependency) - return this - } + fun newBuilder() = Builder() - public fun build() = JavaLibraryConfiguration(this.dependencyScope) + class Builder { + + private val dependencyScope = DependencyScope() + + fun addDependency(dependency: Dependency): Builder { + this.dependencyScope.add(dependency) + return this + } + + fun build() = JavaLibraryConfiguration(this.dependencyScope) + } } } 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 0fd01b5..5b05410 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,7 +5,7 @@ import org.gradle.api.Project import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.external.javadoc.StandardJavadocDocletOptions -class JavadocConfiguration(private val tags: List) : Plugin { +class JavadocConfiguration private constructor(private val tags: List) : Plugin { override fun apply(project: Project) { this.setupPlugin(project) @@ -19,15 +19,20 @@ class JavadocConfiguration(private val tags: List) : Plugin { } } - class Builder { + companion object { - private val tags = mutableListOf() + fun newBuilder() = Builder() - fun addTag(tag: JavadocTag): Builder { - this.tags.add(tag.toString()) - return this - } + class Builder { + + private val tags = mutableListOf() - fun build() = JavadocConfiguration(this.tags.toList()) + fun addTag(tag: JavadocTag): Builder { + this.tags.add(tag.toString()) + return this + } + + fun build() = JavadocConfiguration(this.tags.toList()) + } } } diff --git a/buildSrc/src/main/kotlin/co/raccoons/local/gradle/publish/MavenPublishConfiguration.kt b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/publish/MavenPublishConfiguration.kt new file mode 100644 index 0000000..9ba0619 --- /dev/null +++ b/buildSrc/src/main/kotlin/co/raccoons/local/gradle/publish/MavenPublishConfiguration.kt @@ -0,0 +1,67 @@ +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + +package co.raccoons.local.gradle.publish + +import co.raccoons.local.gradle.publish.maven.Publication +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication + +private const val MAVEN_PUBLISH_PLUGIN_ID = "maven-publish" + +class MavenPublishConfiguration(private val publication: Publication) : Plugin { + + override fun apply(project: Project) { + this.setupPlugin(project) + this.addTaskPackageJavaSources(project) + this.addTaskPackageJavadoc(project) + this.createMavenPublication(project) + } + + private fun setupPlugin(project: Project) { + project.plugins.apply(MAVEN_PUBLISH_PLUGIN_ID) + } + + private fun addTaskPackageJavadoc(project: Project) { + project.extensions + .getByType(JavaPluginExtension::class.java) + .withJavadocJar() + } + + private fun addTaskPackageJavaSources(project: Project) { + project.extensions + .getByType(JavaPluginExtension::class.java) + .withSourcesJar() + } + + private fun createMavenPublication(project: Project) { + project.extensions + .getByType(PublishingExtension::class.java) + .publications { container -> + container.create("mavenJava", MavenPublication::class.java) { publication -> + publication.artifactId = this.publication.artifactId + + publication.from(project.components.getByName("java")) + + publication.pom { pom -> + pom.name.set(this.publication.pom.name) + pom.description.set(this.publication.pom.description) + pom.url.set(this.publication.pom.url) + + pom.licenses { spec -> + spec.license { pomLicense -> + pomLicense.name.set(this.publication.pom.license.name) + pomLicense.url.set(this.publication.pom.license.url) + } + } + } + } + } + } +} \ No newline at end of file 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 3bf9213..d842955 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 @@ -6,7 +6,7 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.testing.Test -class TestNG(private val dependencyScope: DependencyScope) : Plugin { +class TestNG private constructor(private val dependencyScope: DependencyScope) : Plugin { override fun apply(project: Project) { this.setupPlugin(project) @@ -22,15 +22,29 @@ class TestNG(private val dependencyScope: DependencyScope) : Plugin { } } - class Builder { + companion object { + fun newBuilder(): TestNgBuilder { + class Builder : TestNgBuilder { - private val dependencyScope = DependencyScope() + private val dependencyScope = DependencyScope() - fun addDependency(dependency: Dependency): Builder { - this.dependencyScope.add(dependency) - return this + override fun addDependency(dependency: Dependency): Builder { + this.dependencyScope.add(dependency) + return this + } + + override fun build() = TestNG(this.dependencyScope) + } + return Builder() + } + + interface TestNgBuilder { + + fun addDependency(dependency: Dependency): TestNgBuilder + + fun build(): TestNG } - fun build() = TestNG(this.dependencyScope) } + } diff --git a/buildSrc/src/main/proto/co/raccoons/local/gradle/publish/maven/Publication.proto b/buildSrc/src/main/proto/co/raccoons/local/gradle/publish/maven/Publication.proto new file mode 100644 index 0000000..d219d57 --- /dev/null +++ b/buildSrc/src/main/proto/co/raccoons/local/gradle/publish/maven/Publication.proto @@ -0,0 +1,32 @@ +/* + * Copyright 2023, Raccoons. Developing simple way to change. + * + * @license MIT + */ + +syntax = "proto3"; + +package co.raccoons.local.gradle.publish.maven; + +option java_outer_classname = "PublicationProto"; +option java_multiple_files = true; + +// A Maven publication. +message Publication { + string artifactId = 1 ; + Pom pom = 2; +} + +// A POM of a Maven publication. +message Pom { + string name = 1 ; + string description = 2; + string url = 3; + License license = 4; +} + +// A license of a Maven publication. +message License { + string name = 1; + string url = 2; +} diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 028c295..9a47763 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -4,7 +4,7 @@ * @license MIT */ -import co.raccoons.local.gradle.GradleBuild +import co.raccoons.local.gradle.BuildWorkflow import co.raccoons.local.gradle.checkstyle.CheckstyleConfiguration import co.raccoons.local.gradle.checkstyle.CheckstyleReportFormat import co.raccoons.local.gradle.jacoco.JacocoConfiguration @@ -14,48 +14,75 @@ import co.raccoons.local.gradle.java.TestImplementation import co.raccoons.local.gradle.javacompile.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.Publication import co.raccoons.local.gradle.repository.Repository import co.raccoons.local.gradle.test.TestNG -GradleBuild.of(project) - .use(Repository.MAVEN_CENTRAL) +BuildWorkflow.of(project) + .setGroup("co.raccoons") + .setVersion("1.0") .use(Repository.MAVEN_LOCAL) - .use(Configuration.javaLibrary) + .use(Repository.MAVEN_CENTRAL) + .use(JavaLibraryConfiguration.default()) .use(Version.JAVA.of(20)) - .use(Configuration.testNG) - .use(Configuration.jacoco) - .use(Configuration.javadoc) - .use(Configuration.checkstyle) + .use(Configuration.testNG()) + .use(Configuration.jacoco()) + .use(Configuration.javadoc()) + .use(Configuration.checkstyle()) + .use(Configuration.mavenPublish()) -internal class Configuration { - companion object { - val javaLibrary = - JavaLibraryConfiguration.default() +internal object Configuration { - val testNG = - TestNG.Builder() - .addDependency(TestImplementation("org.testng", "testng", "7.8.0")) - .addDependency(TestImplementation("org.slf4j", "slf4j-simple", "2.0.7")) - .build() + fun testNG() = + TestNG.newBuilder() + .addDependency(TestImplementation("org.testng", "testng", "7.8.0")) + .addDependency(TestImplementation("org.slf4j", "slf4j-simple", "2.0.7")) + .build() + + fun jacoco() = + JacocoConfiguration.newBuilder() + .enable(JacocoReportFormat.HTML) + .enable(JacocoReportFormat.XML) + .build() - val jacoco = - JacocoConfiguration.Builder() - .enable(JacocoReportFormat.HTML) - .enable(JacocoReportFormat.XML) + fun javadoc() = + JavadocConfiguration.newBuilder() + .addTag(JavadocTag("apiNote", "API Note")) + .addTag(JavadocTag("implSpec", "Implementation Specification")) + .addTag(JavadocTag("implNote", "Implementation Note")) + .build() + + fun checkstyle() = + CheckstyleConfiguration.newBuilder() + .setVersion("10.12.2") + .enable(CheckstyleReportFormat.HTML) + .build() + + fun mavenPublish(): MavenPublishConfiguration { + val license = + License.newBuilder() + .setName("Meeko") + .setUrl("https://opensource.org/license/mit") .build() - val javadoc = - JavadocConfiguration.Builder() - .addTag(JavadocTag("apiNote", "API Note")) - .addTag(JavadocTag("implSpec", "Implementation Specification")) - .addTag(JavadocTag("implNote", "Implementation Note")) + val pom = + Pom.newBuilder() + .setName("Meeko") + .setDescription("Java Base Util") + .setUrl("https://bus.raccoons.co/artefacts/meeko") + .setLicense(license) .build() - val checkstyle = - CheckstyleConfiguration.Builder() - .setVersion("10.12.2") - .enable(CheckstyleReportFormat.HTML) + val publication = + Publication.newBuilder() + .setArtifactId("meeko") + .setPom(pom) .build() + + return MavenPublishConfiguration(publication) } -} \ No newline at end of file +} diff --git a/lib/src/main/java/co/raccoons/meeko/package-info.java b/lib/src/main/java/co/raccoons/meeko/package-info.java index 7ed1a1a..823f92d 100644 --- a/lib/src/main/java/co/raccoons/meeko/package-info.java +++ b/lib/src/main/java/co/raccoons/meeko/package-info.java @@ -4,4 +4,7 @@ * @license MIT */ +/** + * Meeko package + */ package co.raccoons.meeko; diff --git a/lib/src/test/java/co/raccoons/meeko/package-info.java b/lib/src/test/java/co/raccoons/meeko/package-info.java index 7ed1a1a..83ec2e5 100644 --- a/lib/src/test/java/co/raccoons/meeko/package-info.java +++ b/lib/src/test/java/co/raccoons/meeko/package-info.java @@ -3,5 +3,4 @@ * * @license MIT */ - package co.raccoons.meeko;