Skip to content

Commit 110554c

Browse files
committed
Add explicit task
1 parent c186dce commit 110554c

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

build.gradle

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,41 @@ task run(type: Run) {
408408
impliesSubProjects = true
409409
}
410410

411+
task wrapper(type: Wrapper)
412+
413+
gradle.projectsEvaluated {
414+
415+
def wrapperClosure = { Wrapper wrapper ->
416+
wrapper.distributionType = DistributionType.ALL
417+
418+
wrapper.doLast {
419+
final DistributionLocator locator = new DistributionLocator()
420+
def version = GradleVersion.version(wrapper.gradleVersion)
421+
final URI uri =
422+
locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
423+
uri.toURL().withInputStream { i ->
424+
final byte[] buffer = new byte[1 << 20]
425+
final MessageDigest sha256 = MessageDigest.getInstance("SHA-256")
426+
int bytesRead
427+
while ((bytesRead = i.read(buffer)) >= 0) {
428+
if (bytesRead > 0) {
429+
sha256.update(buffer, 0, bytesRead)
430+
}
431+
}
432+
433+
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256.digest().encodeHex()}\n"
434+
}
435+
}
436+
}
437+
438+
tasks.withType(Wrapper).each(wrapperClosure)
439+
440+
subprojects {
441+
tasks.withType(Wrapper).each(wrapperClosure)
442+
}
443+
444+
}
445+
411446
/* Remove assemble on all qa projects because we don't need to publish
412447
* artifacts for them. */
413448
gradle.projectsEvaluated {
@@ -419,28 +454,5 @@ gradle.projectsEvaluated {
419454
project.build.dependsOn.remove('assemble')
420455
}
421456
}
422-
423-
tasks.withType(Wrapper) { Wrapper wrapper ->
424-
wrapper.distributionType = DistributionType.ALL
425-
426-
wrapper.doLast {
427-
final DistributionLocator locator = new DistributionLocator()
428-
def version = GradleVersion.version(wrapper.gradleVersion)
429-
final URI uri =
430-
locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
431-
uri.toURL().withInputStream { i ->
432-
final byte[] buffer = new byte[2 << 20]
433-
final MessageDigest sha256 = MessageDigest.getInstance("SHA-256")
434-
int bytesRead
435-
while ((bytesRead = i.read(buffer)) >= 0) {
436-
if (bytesRead > 0) {
437-
sha256.update(buffer, 0, bytesRead)
438-
}
439-
}
440-
441-
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256.digest().encodeHex()}\n"
442-
}
443-
}
444-
}
445457
}
446458
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
6-
distributionSha256Sum=8dcbf44eef92575b475dcb1ce12b5f19d38dc79e84c662670248dc8b8247654c
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
6+
distributionSha256Sum=b3afcc2d5aaf4d23eeab2409d64c54046147322d05acc7fb5a63f84d8a2b8bd7

0 commit comments

Comments
 (0)