File tree Expand file tree Collapse file tree 6 files changed +45
-2
lines changed
testProjects/empty-aggregation Expand file tree Collapse file tree 6 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public abstract class nmcp/LocalRepositoryOptions {
1919public abstract interface class nmcp/NmcpAggregationExtension {
2020 public abstract fun centralPortal (Lorg/gradle/api/Action;)V
2121 public abstract fun getAllFiles ()Lorg/gradle/api/file/FileCollection;
22+ public abstract fun getAllowEmptyAggregation ()Lorg/gradle/api/provider/Property;
2223 public abstract fun localRepository (Lorg/gradle/api/Action;)V
2324 public abstract fun publishAllProjectsProbablyBreakingProjectIsolation ()V
2425}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package nmcp
22
33import org.gradle.api.Action
44import org.gradle.api.file.FileCollection
5+ import org.gradle.api.provider.Property
56
67interface NmcpAggregationExtension {
78 /* *
@@ -37,4 +38,10 @@ interface NmcpAggregationExtension {
3738 * Storage and or AWS S3.
3839 */
3940 val allFiles: FileCollection
41+
42+ /* *
43+ * By default, Nmcp errors if the aggregation is empty.
44+ * Set this to true to allow empty aggregations.
45+ */
46+ val allowEmptyAggregation: Property <Boolean >
4047}
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import org.gradle.api.artifacts.result.ArtifactResult
1414import org.gradle.api.artifacts.result.ResolvedArtifactResult
1515import org.gradle.api.attributes.Usage
1616import org.gradle.api.file.ConfigurableFileCollection
17+ import org.gradle.api.provider.Property
1718
1819@GExtension(
1920 pluginId = " com.gradleup.nmcp.aggregation" ,
@@ -58,6 +59,12 @@ internal abstract class DefaultNmcpAggregationExtension(private val project: Pro
5859 }
5960 allNames.add(it.name.lowercase())
6061 }
62+
63+ if (! allowEmptyAggregation.orElse(false ).get()) {
64+ check(consumerConfiguration.dependencies.isNotEmpty()) {
65+ " Nmcp: the aggregation is empty. This is usually a misconfiguration. If this is intentional, set `allowEmptyAggregation` to true."
66+ }
67+ }
6168 }
6269 }
6370
@@ -90,6 +97,8 @@ internal abstract class DefaultNmcpAggregationExtension(private val project: Pro
9097 }
9198 }
9299 }
100+
101+ abstract override val allowEmptyAggregation: Property <Boolean >
93102}
94103
95104private fun isCompatible (artifactResult : ArtifactResult ): Boolean {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import java.io.File
22import kotlin.test.Test
33import org.gradle.testkit.runner.GradleRunner
44
5- class DuplicateNameTest {
5+ class MainTest {
66 @Test
77 fun duplicateName () {
88 val dst = File (" build/testProject" )
@@ -16,9 +16,26 @@ class DuplicateNameTest {
1616 val result = GradleRunner .create()
1717 .withProjectDir(dst)
1818 .withArguments(" nmcpZipAggregation" )
19- .forwardOutput()
2019 .buildAndFail()
2120
2221 assert (result.output.contains(" duplicate project name" ))
2322 }
23+
24+ @Test
25+ fun emptyAggregation () {
26+ val dst = File (" build/testProject" )
27+ val src = File (" testProjects/empty-aggregation" )
28+
29+ dst.deleteRecursively()
30+ dst.mkdirs()
31+
32+ src.copyRecursively(dst, overwrite = true )
33+
34+ val result = GradleRunner .create()
35+ .withProjectDir(dst)
36+ .withArguments(" help" )
37+ .buildAndFail()
38+
39+ assert (result.output.contains(" Nmcp: the aggregation is empty" ))
40+ }
2441}
Original file line number Diff line number Diff line change 1+ plugins {
2+ id(" com.gradleup.nmcp.aggregation" ).version(" 1.4.2-SNAPSHOT" )
3+ }
Original file line number Diff line number Diff line change 1+ pluginManagement {
2+ listOf (repositories, dependencyResolutionManagement.repositories).forEach {
3+ it.mavenCentral()
4+ it.maven(" ../../../build/m2" )
5+ }
6+ }
You can’t perform that action at this time.
0 commit comments