Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 23 additions & 97 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,108 +1,25 @@
import buildsrc.settings.MavenPublishingSettings
import buildsrc.utils.excludeProjectConfigurationDirs
import buildsrc.utils.skipTestFixturesPublications
import org.gradle.plugin.compatibility.compatibility
import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
buildsrc.conventions.`kotlin-gradle-plugin`
`java-test-fixtures`
buildsrc.conventions.base
idea
id("com.gradleup.nmcp.aggregation")
}

project.version = "1.2.0-SNAPSHOT"
project.group = "dev.adamko.gradle"
group = "root" // differentiate between this project and the nested modules/dev-publish-plugin

dependencies {
testFixturesApi(gradleTestKit())
testFixturesApi(platform(libs.kotest.bom))
testFixturesApi(libs.kotest.runnerJUnit5)
testFixturesApi(libs.kotest.assertionsCore)
}

kotlin {
jvmToolchain(17)
@OptIn(ExperimentalAbiValidation::class)
abiValidation {
filters {
exclude {
annotatedWith.add("dev.adamko.gradle.dev_publish.internal.DevPublishInternalApi")
}
}
}
}

gradlePlugin {
isAutomatedPublishing = true
website = "https://github.com/adamko-dev/dev-publish-plugin"
vcsUrl = "https://github.com/adamko-dev/dev-publish-plugin.git"

plugins.register("DevPublish") {
id = "dev.adamko.dev-publish"
displayName = "DevPublish"
description = "Publish Gradle Projects to a project-local repository, for functional testing"
implementationClass = "dev.adamko.gradle.dev_publish.DevPublishPlugin"
tags.addAll(
"maven",
"publishing",
"maven-publish",
"test",
"verify",
"check",
"functional-test",
"integration-test",
"publication",
)
compatibility {
features {
isolatedProjects = true
configurationCache = true
}
}
}
}

val testMavenRepoDir: Provider<Directory> = layout.buildDirectory.dir("test-maven-repo")
val projectTestTempDir: Provider<Directory> = layout.buildDirectory.dir("project-tests")

publishing {
repositories {
maven(testMavenRepoDir) {
name = "TestMavenRepo"
}
}
}

skipTestFixturesPublications()

tasks.withType<Test>().configureEach {
dependsOn("publishAllPublicationsToTestMavenRepoRepository")
systemProperty("testMavenRepoDir", testMavenRepoDir.get().asFile.invariantSeparatorsPath)
systemProperty("projectTestTempDir", projectTestTempDir.get().asFile.invariantSeparatorsPath)
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
optIn.addAll(
"dev.adamko.gradle.dev_publish.internal.DevPublishInternalApi",
)
}
}
//region publishing
// The root is not published, but the Central Portal credentials for the aggregation live here.
val mavenPublishing =
extensions.create<MavenPublishingSettings>(MavenPublishingSettings.EXTENSION_NAME, project)

idea {
module {
excludeProjectConfigurationDirs(layout, providers)
excludeDirs.addAll(
layout.files(
".idea",
"gradle/wrapper",
)
)
}
dependencies {
nmcpAggregation(projects.modules.devPublishPlugin)
}

nmcpAggregation {
allowDuplicateProjectNames.set(true)
centralPortal {
username = mavenPublishing.mavenCentralUsername
password = mavenPublishing.mavenCentralPassword
Expand All @@ -112,10 +29,6 @@ nmcpAggregation {
}
}

dependencies {
nmcpAggregation(project)
}

tasks.nmcpPublishAggregationToCentralPortal {
val isReleaseVersion = mavenPublishing.isReleaseVersion
onlyIf("is release version") { _ -> isReleaseVersion.get() }
Expand All @@ -131,3 +44,16 @@ val nmcpPublish by tasks.registering {
dependsOn(tasks.nmcpPublishAggregationToCentralPortal)
dependsOn(tasks.nmcpPublishAggregationToCentralPortalSnapshots)
}
//endregion

idea {
module {
excludeProjectConfigurationDirs(layout, providers)
excludeDirs.addAll(
layout.files(
".idea",
"gradle/wrapper",
)
)
}
}
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {

dependencies {
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion")
implementation(embeddedKotlin("gradle-plugin"))

implementation(libs.gradlePlugin.pluginPublishPlugin)
implementation(libs.gradlePlugin.nmcp)
Expand Down
1 change: 1 addition & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ dependencyResolutionManagement {
}

enableFeaturePreview("STABLE_CONFIGURATION_CACHE")

10 changes: 0 additions & 10 deletions buildSrc/src/main/kotlin/buildsrc/conventions/base.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ plugins {
base
}

// common config for all projects

if (project != rootProject) {
project.version = rootProject.version
project.group = rootProject.group
}

tasks.withType<AbstractTestTask>().configureEach {
timeout.set(Duration.ofMinutes(60))

Expand All @@ -26,9 +19,6 @@ tasks.withType<AbstractTestTask>().configureEach {
PASSED,
FAILED,
SKIPPED,
STARTED,
STANDARD_ERROR,
STANDARD_OUT,
)
}
}
Expand Down
18 changes: 18 additions & 0 deletions buildSrc/src/main/kotlin/buildsrc/conventions/java-base.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ extensions.getByType<JavaPluginExtension>().apply {
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

val createJavadocJarReadme by tasks.registering(Sync::class) {
description = "generate a readme.txt for the Javadoc JAR"
from(
resources.text.fromString(
"""
|This Javadoc JAR is intentionally empty.
|
|For documentation, see:
|* https://github.com/adamko-dev/dev-publish-plugin
|* Or the sources JAR.
|""".trimMargin()
)
) {
rename { "readme.txt" }
}
into(temporaryDir)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package buildsrc.conventions

import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation

plugins {
id("buildsrc.conventions.base")
id("buildsrc.conventions.java-base")
Expand All @@ -9,6 +11,17 @@ plugins {
id("com.gradle.plugin-publish")
}

kotlin {
jvmToolchain(17)
@OptIn(ExperimentalAbiValidation::class)
abiValidation {}
compilerOptions {
optIn.addAll(
"kotlin.io.path.ExperimentalPathApi",
)
}
}

tasks.validatePlugins {
enableStricterValidation = true
}
Expand All @@ -18,3 +31,10 @@ sourceSets {
java.setSrcDirs(emptyList<File>())
}
}

// The Gradle Publish Plugin enables the Javadoc JAR in afterEvaluate, so find it lazily
tasks.withType<Jar>()
.matching { it.name == "javadocJar" }
.configureEach {
from(tasks.named("createJavadocJarReadme"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ plugins {
id("com.gradleup.nmcp")
}

group = "dev.adamko.gradle"
version = "1.2.0-SNAPSHOT"

val mavenPublishing =
extensions.create<MavenPublishingSettings>(MavenPublishingSettings.EXTENSION_NAME, project)

Expand Down
82 changes: 82 additions & 0 deletions modules/dev-publish-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@file:Suppress("UnstableApiUsage")

import buildsrc.utils.skipTestFixturesPublications
import org.gradle.plugin.compatibility.compatibility
import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation

plugins {
buildsrc.conventions.`kotlin-gradle-plugin`
`java-test-fixtures`
}

dependencies {
testFixturesApi(gradleTestKit())
testFixturesApi(platform(libs.kotest.bom))
testFixturesApi(libs.kotest.runnerJUnit5)
testFixturesApi(libs.kotest.assertionsCore)
}

kotlin {
compilerOptions {
optIn.addAll(
"kotlin.io.path.ExperimentalPathApi",
"dev.adamko.gradle.dev_publish.internal.DevPublishInternalApi",
)
}
@OptIn(ExperimentalAbiValidation::class)
abiValidation {
filters {
exclude {
annotatedWith.add("dev.adamko.gradle.dev_publish.internal.DevPublishInternalApi")
}
}
}
}

gradlePlugin {
website = "https://github.com/adamko-dev/dev-publish-plugin"
vcsUrl = "https://github.com/adamko-dev/dev-publish-plugin.git"

plugins.register("DevPublish") {
id = "dev.adamko.dev-publish"
displayName = "DevPublish"
description = "Publish Gradle Projects to a project-local repository, for functional testing"
implementationClass = "dev.adamko.gradle.dev_publish.DevPublishPlugin"
tags.addAll(
"maven",
"publishing",
"maven-publish",
"test",
"verify",
"check",
"functional-test",
"integration-test",
"publication",
)
compatibility {
features {
isolatedProjects = true
configurationCache = true
}
}
}
}

val testMavenRepoDir: Provider<Directory> = layout.buildDirectory.dir("test-maven-repo")
val projectTestTempDir: Provider<Directory> = layout.buildDirectory.dir("project-tests")

publishing {
repositories {
maven(testMavenRepoDir) {
name = "TestMavenRepo"
}
}
}

skipTestFixturesPublications()

tasks.withType<Test>().configureEach {
dependsOn("publishAllPublicationsToTestMavenRepoRepository")
systemProperty("testMavenRepoDir", testMavenRepoDir.get().asFile.invariantSeparatorsPath)
systemProperty("projectTestTempDir", projectTestTempDir.get().asFile.invariantSeparatorsPath)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ constructor(
/**
* [publicationsStore] is marked as [Internal] as a workaround for 'input directory does not exist' problem.
*
* https://docs.gradle.org/current/userguide/validation_problems.html#input_file_does_not_exist
* https://docs.gradle.org/9.8.0/userguide/validation_problems.html#input_file_does_not_exist
*
* This property exists so Gradle will still be able to detect the inputs using [InputFiles].
*/
Expand Down
6 changes: 5 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginManagement {

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositoriesMode = RepositoriesMode.PREFER_SETTINGS

repositories {
mavenCentral()
Expand All @@ -18,3 +18,7 @@ dependencyResolutionManagement {

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
enableFeaturePreview("STABLE_CONFIGURATION_CACHE")

include(
":modules:dev-publish-plugin",
)
Loading