Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release to maven central #1788

Merged
merged 15 commits into from
Nov 10, 2023
5 changes: 0 additions & 5 deletions .github/workflows/diktat_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ jobs:
with:
gradle-version: wrapper
arguments: |
:diktat-api:publishToMavenLocal
:diktat-common:publishToMavenLocal
:diktat-ktlint-engine:publishToMavenLocal
:diktat-rules:publishToMavenLocal
:diktat-gradle-plugin:publishToMavenLocal
:generateLibsForDiktatSnapshot
-x detekt
-x test
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

![Build and test](https://github.com/saveourtool/diKTat/workflows/Build%20and%20test/badge.svg?branch=master)
![deteKT static analysis](https://github.com/saveourtool/diKTat/workflows/Run%20deteKT/badge.svg)
![diKTat code style](https://github.com/saveourtool/diKTat/workflows/Run%20diKTat%20from%20release%20version/badge.svg?branch=master)
![diKTat code style](https://github.com/saveourtool/diKTat/workflows/Run%20diKTat%20%28release%29/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/saveourtool/diKTat/branch/master/graph/badge.svg)](https://codecov.io/gh/saveourtool/diKTat)

[![Releases](https://img.shields.io/github/v/release/saveourtool/diKTat)](https://github.com/saveourtool/diKTat/releases)
[![Maven Central](https://img.shields.io/maven-central/v/com.saveourtool.diktat/diktat-rules)](https://mvnrepository.com/artifact/com.saveourtool.diktat)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsaveourtool%2FdiKTat.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsaveourtool%2FdiKTat?ref=badge_shield)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsaveourtool%2Fdiktat.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsaveourtool%2Fdiktat?ref=badge_shield)
[![Chat on Telegram](https://img.shields.io/badge/Chat%20on-Telegram-brightgreen.svg)](https://t.me/diktat_help)

[![Hits-of-Code](https://hitsofcode.com/github/saveourtool/diktat)](https://hitsofcode.com/view/github/saveourtool/diktat)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tasks.create("generateLibsForDiktatSnapshot") {
rootProject.project(":diktat-rules"),
rootProject.project(":diktat-gradle-plugin"),
)
mustRunAfter(dependencies.map { "${it.path}:publishToMavenLocal" })
dependsOn(dependencies.map { "${it.path}:publishToMavenLocal" })
val libsFile = rootProject.file("gradle/libs.versions.toml")

inputs.file(libsFile)
Expand Down
2 changes: 2 additions & 0 deletions diktat-cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.saveourtool.diktat.buildutils.configurePublications
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.incremental.createDirectory
Expand Down Expand Up @@ -92,3 +93,4 @@ publishing {
}
}
}
configurePublications()
29 changes: 16 additions & 13 deletions diktat-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import com.saveourtool.diktat.buildutils.configurePom
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.saveourtool.diktat.buildutils.kotlin-jvm-configuration")
id("com.saveourtool.diktat.buildutils.code-quality-convention")
id("com.saveourtool.diktat.buildutils.publishing-default-configuration")
id("com.saveourtool.diktat.buildutils.publishing-configuration")
id("pl.droidsonroids.jacoco.testkit") version "1.0.12"
id("org.gradle.test-retry") version "1.5.6"
id("com.gradle.plugin-publish") version "1.2.1"
Expand Down Expand Up @@ -38,6 +39,8 @@ tasks.withType<KotlinCompile> {
}

gradlePlugin {
website = "https://diktat.saveourtool.com/"
vcsUrl = "https://github.com/saveourtool/diktat"
plugins {
create("diktatPlugin") {
id = "com.saveourtool.diktat.diktat-gradle-plugin"
nulls marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -46,6 +49,18 @@ gradlePlugin {
}
}

afterEvaluate {
publishing {
publications {
withType<MavenPublication> {
pom {
configurePom(project)
}
}
}
}
}

// === testing & code coverage, jacoco is run independent from maven
val functionalTestTask by tasks.register<Test>("functionalTest")
tasks.withType<Test> {
Expand Down Expand Up @@ -103,15 +118,3 @@ tasks.jacocoTestReport {
xml.required.set(true)
}
}

afterEvaluate {
tasks.named("javadocJar") {
enabled = false
}
tasks.named("generateMetadataFileForPluginMavenPublication") {
dependsOn(tasks.named("dokkaJar"))
}
tasks.named("generateMetadataFileForMavenPublication") {
dependsOn(tasks.named("dokkaJar"))
}
}
2 changes: 2 additions & 0 deletions diktat-maven-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.saveourtool.diktat.buildutils.configurePublications
import de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask
import de.benediktritter.maven.plugin.development.task.GenerateMavenPluginDescriptorTask

Expand Down Expand Up @@ -47,3 +48,4 @@ publishing {
}
}
}
configurePublications()
2 changes: 2 additions & 0 deletions diktat-ruleset/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.saveourtool.diktat.buildutils.configurePom
import com.saveourtool.diktat.buildutils.configurePublications
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

Expand Down Expand Up @@ -73,3 +74,4 @@ publishing {
}
}
}
configurePublications()
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import org.jetbrains.dokka.gradle.DokkaPlugin
* Configures all aspects of the publishing process.
*/
fun Project.configurePublishing() {
configurePublications()
apply<MavenPublishPlugin>()
if (this == rootProject) {
configureNexusPublishing()
Expand Down Expand Up @@ -161,10 +160,11 @@ private fun Project.configureGitHubPublishing() {
* Configures all publications. The publications must already exist.
*/
@Suppress("TOO_LONG_FUNCTION")
private fun Project.configurePublications() {
fun Project.configurePublications() {
if (this == rootProject) {
return
}
val sourcesJar = tasks.named(SOURCES_JAR)
apply<DokkaPlugin>()
@Suppress("GENERIC_VARIABLE_WRONG_DECLARATION")
val dokkaJarProvider = tasks.register<Jar>("dokkaJar") {
Expand All @@ -177,6 +177,7 @@ private fun Project.configurePublications() {
mavenLocal()
}
publications.withType<MavenPublication>().configureEach {
artifact(sourcesJar)
artifact(dokkaJarProvider)
pom {
configurePom(project)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Names for common tasks
*/

package com.saveourtool.diktat.buildutils

/**
* Tasks with sources
*/
const val SOURCES_JAR = "sourcesJar"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package com.saveourtool.diktat.buildutils

import org.ajoberstar.reckon.core.Scope
import org.ajoberstar.reckon.core.VersionTagParser
import org.ajoberstar.reckon.gradle.ReckonExtension
import org.ajoberstar.reckon.gradle.ReckonPlugin
import org.eclipse.jgit.api.Git
Expand All @@ -23,7 +24,7 @@ fun Project.configureVersioning() {
// should be provided in the gradle.properties
configure<ReckonExtension> {
setDefaultInferredScope(Scope.MINOR.name)
snapshots()
stages("rc", "final")
nulls marked this conversation as resolved.
Show resolved Hide resolved
setScopeCalc(calcScopeFromProp())
setStageCalc(calcStageFromProp())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ kotlin {
}
}

tasks.register<Jar>(SOURCES_JAR) {
archiveClassifier.set("sources")
from(kotlin.sourceSets.main.map { it.kotlin })
nulls marked this conversation as resolved.
Show resolved Hide resolved
}

configureJacoco()
tasks.withType<Test> {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ publishing {
}
}

configurePublications()
configurePublishing()
Loading