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
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.gradleup.librarian.gradle.Librarian
import nmcp.NmcpAggregationExtension

plugins {
alias(libs.plugins.kgp).apply(false)
Expand Down Expand Up @@ -37,3 +38,7 @@ tasks.named("librarianStaticContent").configure {
}
}

extensions.getByType(NmcpAggregationExtension::class.java).localRepository {
this.name = "test"
this.path = "build/m2"
}
9 changes: 5 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ kgp = "2.3.0"
ksp = "2.3.4"
gratatouille-runtime = "0.2.1"
gratatouille-plugin = "0.2.1"
gradle-api = "8.8"

[libraries]
json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0"
okio = "com.squareup.okio:okio:3.16.4"
okhttp = "com.squareup.okhttp3:okhttp:5.3.2"
mockwebserver = "com.squareup.okhttp3:mockwebserver:5.3.2"
#noinspection NewerVersionAvailable
gradle-min = "dev.gradleplugins:gradle-api:8.8"
gradle-min = { module = "dev.gradleplugins:gradle-api", version.ref = "gradle-api" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
xmlutil = "io.github.pdvrieze.xmlutil:serialization:1.0.0-rc1"
kgp = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kgp" }
Expand All @@ -23,6 +24,6 @@ kgp = { id = "org.jetbrains.kotlin.jvm", version.ref = "kgp" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kgp" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
gratatouille = { id = "com.gradleup.gratatouille", version.ref = "gratatouille-plugin" }
librarian = { id = "com.gradleup.librarian", version = "0.2.2-SNAPSHOT-6898196f1f9759091ae6fa9bbe84154ec28a9331" }
nmcp = { id = "com.gradleup.nmcp", version = "1.3.0" }
compat = { id = "com.gradleup.tapmoc", version = "0.3.3-SNAPSHOT-a7d9d3fed6e48f1a88966d81e753259dadfa9a9a" }
librarian = { id = "com.gradleup.librarian", version = "0.2.2-SNAPSHOT-f89d61cb6d4bd03bb9f48d1c8220262c0d02094c" }
nmcp = { id = "com.gradleup.nmcp", version = "1.4.2-SNAPSHOT-9cc65e0d486a8b82f8b2e3039455eeb24a4bfd6d" }
compat = { id = "com.gradleup.tapmoc", version = "0.4.1-SNAPSHOT-86d664ab69b813963b91060ecce036be943088ed" }
3 changes: 2 additions & 1 deletion librarian.root.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
java.compatibility=17
kotlin.compatibility=1.9.0
# overridden for the Gradle plugin
kotlin.compatibility=2.2.0

kdoc.olderVersions=
kdoc.artifactId=kdoc
Expand Down
1 change: 1 addition & 0 deletions nmcp-tasks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.gradleup.librarian.gradle.Librarian
import tapmoc.TapmocExtension

plugins {
alias(libs.plugins.kgp)
Expand Down
13 changes: 13 additions & 0 deletions nmcp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import com.gradleup.librarian.gradle.Librarian
import kotlin.jvm.java
import tapmoc.TapmocExtension

plugins {
alias(libs.plugins.kgp)
Expand All @@ -7,6 +9,11 @@ plugins {
}

Librarian.module(project)
extensions.getByType(TapmocExtension::class.java).apply {
// Override the default Kotlin version to work with older Gradle
kotlin("2.1.0")
//kotlin(kotlinVersionForGradle(libs.versions.gradle.api.get().toString()))
}

gratatouille {
addDependencies = false
Expand All @@ -17,5 +24,11 @@ dependencies {
gratatouille(project(":nmcp-tasks"))
compileOnly(libs.gradle.min)
implementation(libs.gratatouille.runtime)

testImplementation(libs.kotlin.test)
testImplementation(gradleTestKit())
}

tasks.withType(Test::class.java).configureEach {
dependsOn(":nmcpPublishAggregationToTestRepository")
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ internal abstract class DefaultNmcpAggregationExtension(private val project: Pro
inputFiles = allFiles,
spec = spec,
)

project.afterEvaluate {
val allNames = mutableSetOf<String>()
project.allprojects {
check (!allNames.contains(it.name.lowercase())) {
"Nmcp: duplicate project name: '${it.name}'. This is usually resolved by setting your root project name in your settings.gradle[.kts] file: `rootProject.name = \"\${someUniqueName}\". " +
"See https://github.com/gradle/gradle/issues/36167 for more details"
}
allNames.add(it.name.lowercase())
}
}
}

override fun centralPortal(action: Action<CentralPortalOptions>) {
Expand Down
24 changes: 24 additions & 0 deletions nmcp/src/test/kotlin/DuplicateNameTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.io.File
import kotlin.test.Test
import org.gradle.testkit.runner.GradleRunner

class DuplicateNameTest {
@Test
fun duplicateName() {
val dst = File("build/testProject")
val src = File("testProjects/duplicate-name")

dst.deleteRecursively()
dst.mkdirs()

src.copyRecursively(dst, overwrite = true)

val result = GradleRunner.create()
.withProjectDir(dst)
.withArguments("nmcpZipAggregation")
.forwardOutput()
.buildAndFail()

assert(result.output.contains("duplicate project name"))
}
}
11 changes: 11 additions & 0 deletions nmcp/testProjects/duplicate-name/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
id("org.jetbrains.kotlin.jvm").version("2.3.0").apply(false)
id("com.gradleup.nmcp.aggregation").version("1.4.2-SNAPSHOT")
}

group = "com.example"
version = "1.0.0"

dependencies {
nmcpAggregation(project(":duplicate-name"))
}
14 changes: 14 additions & 0 deletions nmcp/testProjects/duplicate-name/duplicate-name/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id("org.jetbrains.kotlin.jvm")
id("maven-publish")
id("com.gradleup.nmcp")
id("signing")
}

group = rootProject.group

publishing {
publications.create("default", MavenPublication::class.java) {
from(components.getByName("java"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val hello = "world"
10 changes: 10 additions & 0 deletions nmcp/testProjects/duplicate-name/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Change this to fix the build
rootProject.name = "duplicate-name"
pluginManagement {
listOf(repositories, dependencyResolutionManagement.repositories).forEach {
it.mavenCentral()
it.maven("../../../build/m2")
}
}

include(":duplicate-name")
34 changes: 21 additions & 13 deletions scripts/update-repo.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@
@file:Repository("https://storage.googleapis.com/gradleup/m2")
@file:Repository("https://jitpack.io")
//@file:Repository("file://~/.m2/repository")
@file:DependsOn("com.gradleup.librarian:librarian-cli:0.2.2-SNAPSHOT-0cbca80f60a15a0f851a9cd468bfc352db316dd4")
@file:DependsOn("com.gradleup.librarian:librarian-cli:0.2.2-SNAPSHOT-f89d61cb6d4bd03bb9f48d1c8220262c0d02094c")

import com.gradleup.librarian.cli.updateRepo

updateRepo(args) {
file("docs/src/content/docs/index.mdx") {
replacePluginVersion("com.gradleup.nmcp.settings")
replacePluginVersion("com.gradleup.nmcp.aggregation")
replacePluginVersion("com.gradleup.nmcp")
}
file("docs/src/content/docs/manual-configuration.mdx") {
replacePluginVersion("com.gradleup.nmcp.settings")
replacePluginVersion("com.gradleup.nmcp.aggregation")
replacePluginVersion("com.gradleup.nmcp")
}
}
updateRepo(
args,
setVersion = {
file("nmcp/testProjec/duplicate-name/build.gradle.kts") {
replacePluginVersion("com.gradleup.nmcp.aggregation")
}
},
setDocsVersion = {
file("docs/src/content/docs/index.mdx") {
replacePluginVersion("com.gradleup.nmcp.settings")
replacePluginVersion("com.gradleup.nmcp.aggregation")
replacePluginVersion("com.gradleup.nmcp")
}
file("docs/src/content/docs/manual-configuration.mdx") {
replacePluginVersion("com.gradleup.nmcp.settings")
replacePluginVersion("com.gradleup.nmcp.aggregation")
replacePluginVersion("com.gradleup.nmcp")
}
},
)
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ pluginManagement {
mavenCentral()
maven("https://storage.googleapis.com/gradleup/m2") {
content {
// gratatouille-processor is only used at build time and is safe to fetch as a snapshot
// those dependencies are only used at build time and is safe to fetch as a snapshot
includeModule("com.gradleup.gratatouille", "gratatouille-processor")
includeModule("com.gradleup.tapmoc", "tapmoc-tasks")
includeModule("com.gradleup.nmcp", "nmcp-tasks")
}
}
}
Expand Down