kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [3/3] kudu git commit: [java] Ensure a license is added to the wrapper
Date Thu, 08 Mar 2018 23:52:24 GMT
[java] Ensure a license is added to the wrapper

When generating a new/updated Gradle wrapper file
this ensures the expected license is always added
automatically.

Change-Id: I590b20a963e1bb374fd9d7e290911f8fa44d4a4a
Reviewed-on: http://gerrit.cloudera.org:8080/8333
Reviewed-by: Adar Dembo <adar@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/5d016e1a
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/5d016e1a
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/5d016e1a

Branch: refs/heads/master
Commit: 5d016e1a775caae6b11a7d8b74fbbc547de7feae
Parents: 0c39ed7
Author: Grant Henke <granthenke@gmail.com>
Authored: Thu Oct 19 11:58:22 2017 -0500
Committer: Grant Henke <granthenke@gmail.com>
Committed: Thu Mar 8 19:48:36 2018 +0000

----------------------------------------------------------------------
 java/gradle/wrapper.gradle | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/5d016e1a/java/gradle/wrapper.gradle
----------------------------------------------------------------------
diff --git a/java/gradle/wrapper.gradle b/java/gradle/wrapper.gradle
index eb6de64..aaa059c 100644
--- a/java/gradle/wrapper.gradle
+++ b/java/gradle/wrapper.gradle
@@ -26,6 +26,7 @@ task wrapper(type: Wrapper) {
 
 // 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.
+// Additionally adds a license header to the wrapper while editing the file contents.
 task bootstrapWrapper() {
   // In the doLast block so this runs when the task is called and not during project configuration.
   doLast {
@@ -50,9 +51,26 @@ task bootstrapWrapper() {
       fi
       """.stripIndent()
 
+    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.""".stripIndent()
+
     def wrapperScript = file("$rootDir/gradlew")
     def wrapperLines = wrapperScript.readLines()
     wrapperScript.withPrintWriter { out ->
+      def licenseWritten = false
       def bootstrapWritten = false
       wrapperLines.each { line ->
         // Print the wrapper bootstrap before the first usage of the wrapper jar.
@@ -60,7 +78,13 @@ task bootstrapWrapper() {
           out.println(bootstrapString)
           bootstrapWritten = true
         }
-        out.println(line)
+        out.print(line)
+        // Print the licence after the shebang.
+        if(!licenseWritten && line.contains("#!/usr/bin/env sh")) {
+          out.print(licenseString)
+          licenseWritten = true
+        }
+        out.println() // New Line
       }
     }
   }


Mime
View raw message