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 gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
org.gradle.jvmargs=-Xmx2g

org.gradle.configuration-cache.parallel=true
org.gradle.unsafe.isolated-projects=true
org.gradle.configuration-cache=true
ksp.project.isolation.enabled=true
1 change: 1 addition & 0 deletions nmcp/api/nmcp.api
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public abstract class nmcp/LocalRepositoryOptions {
public abstract interface class nmcp/NmcpAggregationExtension {
public abstract fun centralPortal (Lorg/gradle/api/Action;)V
public abstract fun getAllFiles ()Lorg/gradle/api/file/FileCollection;
public abstract fun getAllowDuplicateProjectNames ()Lorg/gradle/api/provider/Property;
public abstract fun getAllowEmptyAggregation ()Lorg/gradle/api/provider/Property;
public abstract fun localRepository (Lorg/gradle/api/Action;)V
public abstract fun publishAllProjectsProbablyBreakingProjectIsolation ()V
Expand Down
11 changes: 11 additions & 0 deletions nmcp/src/main/kotlin/nmcp/NmcpAggregationExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,15 @@ interface NmcpAggregationExtension {
* Set this to true to allow empty aggregations.
*/
val allowEmptyAggregation: Property<Boolean>

/**
* By default, Nmcp errors if there are duplicate project names because
* it confuses the dependency resolution algorithm.
*
* If you have duplicate project names that do not contribute publishing,
* set this to true to allow them.
*
* See https://github.com/gradle/gradle/issues/36167 for more details.
*/
val allowDuplicateProjectNames: Property<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,18 @@ internal abstract class DefaultNmcpAggregationExtension(private val project: Pro

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"
if(!allowDuplicateProjectNames.orElse(false).get()) {
project.allprojects {
check(!allNames.contains(it.name.lowercase())) {
"""
Nmcp: some projects have the same name: '${'$'}{it.name}'. This creates issues when resolving the aggregation.
You can usually resolve this error by renaming your projects (including possibly your root project).
Or you can disable this check by calling `allowDuplicateProjectNames.set(true)`.
See https://github.com/gradle/gradle/issues/36167 for more details.
""".trimIndent()
}
allNames.add(it.name.lowercase())
}
allNames.add(it.name.lowercase())
}

if (!allowEmptyAggregation.orElse(false).get()) {
Expand Down Expand Up @@ -99,6 +105,8 @@ internal abstract class DefaultNmcpAggregationExtension(private val project: Pro
}

abstract override val allowEmptyAggregation: Property<Boolean>

abstract override val allowDuplicateProjectNames: Property<Boolean>
}

private fun isCompatible(artifactResult: ArtifactResult): Boolean {
Expand Down
2 changes: 1 addition & 1 deletion nmcp/src/test/kotlin/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MainTest {
.withArguments("nmcpZipAggregation")
.buildAndFail()

assert(result.output.contains("duplicate project name"))
assert(result.output.contains("some projects have the same name"))
}

@Test
Expand Down