MINOR: Remove unnecessary license generation code in wrapper.gradle (#7742)

Newer versions of Gradle handle this automatically. Tested with Gradle 5.6.

Credit to @granthenke for the tip.

Reviewers: Manikumar Reddy <manikumar.reddy@gmail.com>
This commit is contained in:
Ismael Juma 2019-11-24 10:51:49 -08:00 committed by GitHub
parent e057d61050
commit 45842a3962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 61 deletions

View File

@ -130,6 +130,7 @@ if (file('.git').exists()) {
'PULL_REQUEST_TEMPLATE.md', 'PULL_REQUEST_TEMPLATE.md',
'gradlew', 'gradlew',
'gradlew.bat', 'gradlew.bat',
'gradle/wrapper/gradle-wrapper.properties',
'TROGDOR.md', 'TROGDOR.md',
'**/README.md', '**/README.md',
'**/id_rsa', '**/id_rsa',

View File

@ -1,19 +1,5 @@
#
# Copyright 2017 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

14
gradlew vendored
View File

@ -1,18 +1,20 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# #
# Copyright 2017 the original author or authors. # Copyright 2015 the original author or authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#
############################################################################## ##############################################################################
## ##
@ -42,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@ -82,7 +84,7 @@ esac
# Loop in case we encounter an error. # Loop in case we encounter an error.
for attempt in 1 2 3; do for attempt in 1 2 3; do
if [ ! -e $APP_HOME/gradle/wrapper/gradle-wrapper.jar ]; then if [ ! -e $APP_HOME/gradle/wrapper/gradle-wrapper.jar ]; then
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v5.0.0/gradle/wrapper/gradle-wrapper.jar"; then if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v5.6.2/gradle/wrapper/gradle-wrapper.jar"; then
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
# Pause for a bit before looping in case the server throttled us. # Pause for a bit before looping in case the server throttled us.
sleep 5 sleep 5
@ -136,8 +138,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`

View File

@ -27,21 +27,6 @@ wrapper {
distributionType = Wrapper.DistributionType.ALL distributionType = Wrapper.DistributionType.ALL
} }
def licenseString = """#
# Copyright 2017 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License."""
// Custom task to inject support for downloading the gradle wrapper jar if it doesn't exist. // Custom task to inject support for downloading the gradle wrapper jar if it doesn't exist.
// This allows us to avoid checking in the jar to our repository. // This allows us to avoid checking in the jar to our repository.
// Additionally adds a license header to the wrapper while editing the file contents. // Additionally adds a license header to the wrapper while editing the file contents.
@ -78,7 +63,6 @@ task bootstrapWrapper() {
def wrapperScript = wrapper.scriptFile def wrapperScript = wrapper.scriptFile
def wrapperLines = wrapperScript.readLines() def wrapperLines = wrapperScript.readLines()
wrapperScript.withPrintWriter { out -> wrapperScript.withPrintWriter { out ->
def licenseWritten = false
def bootstrapWritten = false def bootstrapWritten = false
wrapperLines.each { line -> wrapperLines.each { line ->
// Print the wrapper bootstrap before the first usage of the wrapper jar. // Print the wrapper bootstrap before the first usage of the wrapper jar.
@ -87,36 +71,13 @@ task bootstrapWrapper() {
bootstrapWritten = true bootstrapWritten = true
} }
out.print(line) out.print(line)
// Print the licence after the shebang.
if(!licenseWritten && line.contains("#!/usr/bin/env sh")) {
out.println() out.println()
out.print(licenseString)
licenseWritten = true
}
out.println() // New Line
} }
} }
} }
} }
wrapper.finalizedBy bootstrapWrapper wrapper.finalizedBy bootstrapWrapper
// Custom task to add a license header to the gradle-wrapper.properties file.
task bootstrapWrapperProperties() {
// In the doLast block so this runs when the task is called and not during project configuration.
doLast {
def wrapperProperties = wrapper.propertiesFile
def wrapperLines = wrapperProperties.readLines()
wrapperProperties.withPrintWriter { out ->
// Print the license
out.println(licenseString)
wrapperLines.each { line ->
out.println(line)
}
}
}
}
wrapper.finalizedBy bootstrapWrapperProperties
// Remove the generated batch file since we don't test building in the Windows environment. // Remove the generated batch file since we don't test building in the Windows environment.
task removeWindowsScript(type: Delete) { task removeWindowsScript(type: Delete) {
delete "$rootDir/gradlew.bat" delete "$rootDir/gradlew.bat"