@@ -19,7 +19,6 @@ package org.apache.polygene.gradle.structure.distributions
1919
2020import groovy.transform.CompileStatic
2121import groovy.transform.TypeCheckingMode
22- import org.apache.commons.io.FileUtils
2322import org.apache.polygene.gradle.BasePlugin
2423import org.apache.polygene.gradle.TaskGroups
2524import org.apache.polygene.gradle.code.PublishedCodePlugin
@@ -52,6 +51,7 @@ import org.gradle.plugins.ide.internal.IdeDependenciesExtractor
5251import org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency
5352import org.gradle.plugins.signing.Sign
5453import org.gradle.plugins.signing.SigningExtension
54+ import org.gradle.process.ExecSpec
5555
5656import java.nio.file.Files
5757import java.nio.file.Path
@@ -118,6 +118,7 @@ class DistributionsPlugin implements Plugin<Project>
118118 private static void applySourceDistribution ( Project project )
119119 {
120120 def releaseSpec = project. extensions. getByType( ReleaseSpecExtension )
121+ def dependenciesDeclaration = project. rootProject. extensions. getByType( DependenciesDeclarationExtension )
121122 def srcDistFilesCopySpec = project. copySpec { CopySpec spec ->
122123 spec. from project. rootProject. projectDir
123124 spec. include ' *.txt'
@@ -133,8 +134,8 @@ class DistributionsPlugin implements Plugin<Project>
133134 }
134135 spec. include ' distributions/**'
135136 spec. include ' reports/**'
136- spec. include ' release/**'
137137 spec. include ' internals/**'
138+ spec. include ' release/**'
138139 spec. include ' manual/**'
139140 spec. include ' samples/**'
140141 spec. include ' tests/**'
@@ -147,7 +148,8 @@ class DistributionsPlugin implements Plugin<Project>
147148 spec. exclude ' **/.git*' // Git files
148149 spec. exclude ' **/build/**' // Build output
149150 spec. exclude ' gradlew*' // Gradle wrapper scripts
150- spec. exclude ' gradle/wrapper/*.jar' // Gradle wrapper JAR
151+ spec. exclude ' gradle/wrapper/**' // Gradle wrapper
152+ spec. exclude ' tools/generator-polygene/app/templates/buildtool/wrapper' // Project Generator Gradle wrapper
151153 spec. exclude ' **/.gradle/**' // Gradle caches
152154 spec. exclude ' **/.gradletasknamecache' // Gradle shell completion cache
153155 spec. exclude ' **/node_modules/**' // Node's node_module dir
@@ -168,6 +170,7 @@ class DistributionsPlugin implements Plugin<Project>
168170 def srcDistSupplementaryFilesCopySpec = project. copySpec { CopySpec spec ->
169171 spec. from project. file( ' src/src-dist' )
170172 spec. into ' .'
173+ spec. filter { String line -> line. replaceAll( ' %REQUIRED_GRADLE_VERSION%' , dependenciesDeclaration. gradleVersion ) }
171174 }
172175 def srcDistFilteredFilesTask = project. tasks. create ' srcDistFilteredFiles'
173176 srcDistFilteredFilesTask. description = ' Apply release specification to source distribution build scripts'
@@ -248,6 +251,9 @@ class DistributionsPlugin implements Plugin<Project>
248251 task. group = TaskGroups . DISTRIBUTION_VERIFICATION
249252 task. description = ' Checks the source distribution using Apache RAT.'
250253 task. dependsOn TaskNames . STAGE_SOURCE_DIST
254+ task. plainOutput = true
255+ task. htmlOutput = true
256+ task. xmlOutput = false
251257 task. setInputDir unpackedSrcDistDir. absolutePath
252258 task. onlyIf { ! releaseSpec. developmentVersion }
253259 task. excludes = [
@@ -278,15 +284,13 @@ class DistributionsPlugin implements Plugin<Project>
278284 // Graphic Resources
279285 ' **/*.svg' , ' **/*.gif' , ' **/*.png' , ' **/*.jpg' , ' **/*.psd' ,
280286 // Keystores
281- ' **/*.jceks' ,
287+ ' **/*.jceks' , ' **/*.p12 ' ,
282288 // Syntax Highlighter - MIT
283289 ' manual/**/sh*.css' , ' manual/**/sh*.js' ,
284290 // jQuery & plugins - MIT
285291 ' manual/**/jquery*.js' ,
286292 // W3C XML Schemas - W3C Software License
287293 ' samples/rental/src/main/resources/*.xsd' ,
288- // Polygene Generator Heroes Templates - MIT
289- ' tools/generator-polygene/app/templates/Heroes/**' ,
290294 ]
291295 } as Action<RatTask > )
292296 project. tasks. create( TaskNames . INSPECT_SOURCE_DIST ) { Task task ->
@@ -302,26 +306,44 @@ class DistributionsPlugin implements Plugin<Project>
302306 assertFileAbsent ' gradlew'
303307 assertFileAbsent ' gradlew.bat'
304308 assertFileAbsent ' gradle/wrapper/gradle-wrapper.jar'
305- assertFilePresent ' gradle/wrapper/gradle-wrapper.properties'
309+ assertFileAbsent ' gradle/wrapper/gradle-wrapper.properties'
310+ assertFilePresent ' gradle/wrapper-install/build.gradle'
311+
312+ def wrapperFiles = []
313+ unpackedSrcDistDir. traverse { File file ->
314+ if (file. file &&
315+ (file. name. contains( ' gradle-wrapper' ) || file. name. contains(' gradlew' ))) {
316+ wrapperFiles << file
317+ }
318+ }
319+ assert wrapperFiles. empty
306320 }
307321 }
308322 project. tasks. create( TaskNames . BUILD_SOURCE_DIST , ExecLogged , { ExecLogged task ->
309323 task. group = TaskGroups . DISTRIBUTION_VERIFICATION
310- task. description = ' Checks the source distribution by running `gradle build ` inside.'
324+ task. description = ' Checks the source distribution by running `gradle check assemble ` inside.'
311325 task. dependsOn TaskNames . STAGE_SOURCE_DIST
312326 task. mustRunAfter TaskNames . RAT_SOURCE_DIST
313327 task. mustRunAfter TaskNames . INSPECT_SOURCE_DIST
314328 def workDir = project. file( " $project . buildDir /tmp/${ TaskNames.BUILD_SOURCE_DIST } " )
315329 task. inputs. dir unpackedSrcDistDir
316330 task. workingDir = workDir
317- def gradlew = new File ( project . rootDir , ' gradlew' ). absolutePath
331+ def gradlew = new File ( workDir , ' gradlew' ). absolutePath
318332 def settings = new File ( workDir, ' settings.gradle' ). absolutePath
319- task. commandLine = [ gradlew, ' -c' , settings, ' build ' , ' -u' , ' -s' , /* '-g', workDir */ ]
333+ task. commandLine = [ gradlew, ' -c' , settings, ' check ' , ' assemble ' , ' -u' , ' -s' , /* '-g', workDir */ ]
320334 task. doFirst {
321335 project. copy { CopySpec spec ->
322336 spec. from unpackedSrcDistDir
323337 spec. into workDir
324338 }
339+ def logName = " ${ TaskNames.BUILD_SOURCE_DIST } _installWrapper"
340+ def stdout = project. file( " ${ project.buildDir } /log/$logName /$logName -stdout.log" )
341+ def stderr = project. file( " ${ project.buildDir } /log/$logName /$logName -stderr.log" )
342+ def rootGradlew = new File ( project. rootDir, ' gradlew' ). absolutePath
343+ ExecLogged . execLogged( project, stdout, stderr, { ExecSpec spec ->
344+ spec. workingDir = workDir
345+ spec. commandLine = [ rootGradlew, ' -i' , ' -s' , ' -b' , ' gradle/wrapper-install/build.gradle' , ' install' ]
346+ } as Action )
325347 }
326348 task. doLast {
327349 if ( workDir. exists() )
@@ -359,16 +381,8 @@ class DistributionsPlugin implements Plugin<Project>
359381 }
360382 spec. into ' .'
361383 }
362- def extraDistBinCopySpec = project. copySpec { CopySpec spec ->
363- releaseSpec. publishedProjects. collect { p ->
364- spec. from " $p. projectDir /src/dist/"
365- spec. include ' **/*.jar'
366- spec. include ' **/*.jar_'
367- }
368- spec. into ' .'
369- }
370384 def binDistNoticesCopySpec = project. copySpec { CopySpec spec ->
371- spec. from " $project . projectDir /LICENSE.txt"
385+ spec. from " $project . rootProject . projectDir /LICENSE.txt"
372386 spec. from " $project . projectDir /src/bin-dist"
373387 spec. into ' .'
374388 }
@@ -377,7 +391,6 @@ class DistributionsPlugin implements Plugin<Project>
377391 spec. with binDistNoticesCopySpec
378392 spec. with docsCopySpec
379393 spec. with extraDistTextCopySpec
380- spec. with extraDistBinCopySpec
381394 spec. with libsCopySpec
382395 }
383396
@@ -426,6 +439,9 @@ class DistributionsPlugin implements Plugin<Project>
426439 task. description = " Checks the binary distribution using Apache RAT."
427440 task. onlyIf { ! releaseSpec. developmentVersion }
428441 task. dependsOn TaskNames . STAGE_BINARY_DIST
442+ task. plainOutput = true
443+ task. htmlOutput = true
444+ task. xmlOutput = false
429445 task. inputDir = unpackedBinDistDir. absolutePath
430446 task. reportDir = project. file( ' build/reports/rat-bin-dist' )
431447 task. excludes = [
0 commit comments