File tree 2 files changed +16
-6
lines changed
main/kotlin/tech/harmonysoft/oss/gradle/dist
test/kotlin/tech/harmonysoft/oss/gradle/dist
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -371,11 +371,21 @@ abstract class BuildCustomGradleDistributionTask @Inject constructor(
371
371
)
372
372
.use { zipFileSystem ->
373
373
config.initScriptsSourceDir.get().asFile.let { initScriptsSourceDir ->
374
+ val includeRootDir = distribution?.let {
375
+ File (initScriptsSourceDir, it)
376
+ } ? : initScriptsSourceDir
377
+ val initScripts = includeRootDir.listFiles()?.filter {
378
+ it.name.endsWith(" .gradle" ) || it.name.endsWith(" .gradle.kts" )
379
+ } ? : emptyList()
380
+ if (initScripts.isEmpty()) {
381
+ throw IllegalStateException (
382
+ " can not generate custom distribution ${zip.name} - there must be at least one file to "
383
+ + " include into its init.d, but directory ${initScriptsSourceDir.canonicalPath} is empty"
384
+ )
385
+ }
374
386
addToZip(
375
387
zip = zipFileSystem,
376
- includeRootDir = distribution?.let {
377
- File (initScriptsSourceDir, it)
378
- } ? : initScriptsSourceDir,
388
+ includeRootDir = includeRootDir,
379
389
gradleVersion = gradleVersion,
380
390
pathsToExcludeFromContentExpansion = pathsToExcludeFromContentExpansion,
381
391
replacements = replacements
Original file line number Diff line number Diff line change @@ -446,8 +446,8 @@ class CustomGradleDistributionPluginTest {
446
446
private fun prepareGradleDistributionZip (projectRootDir : File ) {
447
447
val downloadDir = File (projectRootDir, " build/gradle-download" )
448
448
Files .createDirectories(downloadDir.toPath())
449
- listOf ( " bin " , " all " ).forEach {
450
- val zip = File (downloadDir, " gradle-${GRADLE_VERSION } -${it } .zip" )
449
+ for (type in DISTRIBUTION_TYPES ) {
450
+ val zip = File (downloadDir, " gradle-${GRADLE_VERSION } -${type } .zip" )
451
451
createGradleDistributionZip(zip)
452
452
}
453
453
}
@@ -593,8 +593,8 @@ class CustomGradleDistributionPluginTest {
593
593
const val GRADLE_VERSION = " 8.3"
594
594
const val PROJECT_NAME = " my-project"
595
595
const val PROJECT_VERSION = " 1.0"
596
- const val DEFAULT_DISTRIBUTION_TYPE = " bin"
597
596
const val BUILT_DISTS_DIR = " build/gradle-dist"
597
+ val DISTRIBUTION_TYPES = setOf (" bin" , " all" )
598
598
599
599
@field:TempDir(cleanup = CleanupMode .ON_SUCCESS )
600
600
lateinit var TESTS_ARTIFACTS_ROOT_DIR : Path
You can’t perform that action at this time.
0 commit comments