You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2019/05/23 19:50:46 UTC

[lucene-solr] 02/02: SOLR-13452: Get the basics of jarChecksum working.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch jira/SOLR-13452_gradle
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit f02148287d688825b4d09465deee990d8fdfca09
Author: markrmiller <ma...@apache.org>
AuthorDate: Thu May 23 14:49:43 2019 -0500

    SOLR-13452: Get the basics of jarChecksum working.
---
 .../org/apache/lucene/gradle/JarChecksum.groovy    | 72 ++++++++++++++++++++++
 lucene/build.gradle                                |  8 +++
 solr/build.gradle                                  |  9 ++-
 3 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/buildSrc/src/main/groovy/org/apache/lucene/gradle/JarChecksum.groovy b/buildSrc/src/main/groovy/org/apache/lucene/gradle/JarChecksum.groovy
new file mode 100644
index 0000000..3a32b30
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/apache/lucene/gradle/JarChecksum.groovy
@@ -0,0 +1,72 @@
+package org.apache.lucene.gradle
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+import org.gradle.api.DefaultTask
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.file.RelativePath
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.Optional
+import org.gradle.api.tasks.InputDirectory
+import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.TaskAction
+
+import java.nio.file.Files
+
+class JarChecksum extends DefaultTask {
+  
+  @InputDirectory
+  File inputDir
+  
+  @OutputDirectory
+  File target
+  
+  @TaskAction
+  void checksums() {
+    def skip = ['testRuntimeClasspath', 'testCompileClasspath']
+    
+    project.delete project.fileTree(dir: target.getAbsolutePath(), include: '**/*.jar.sha1')
+    
+    File tmpDir = File.createTempDir()
+    tmpDir.deleteOnExit()
+    tmpDir.mkdirs()
+    
+    project.allprojects.each { p ->
+      p.configurations.each { Configuration config ->
+        if (skip.contains(config.name)) {  
+          config.files.each {
+            File destFile = new File(tmpDir, it.name)
+            if (it.name.endsWith(".jar") && it.exists() && !destFile.exists()) {
+              Files.copy(it.toPath(), destFile.toPath());
+            }
+          }
+        }
+        
+      }
+    }
+    
+    ant.checksum(algorithm: "SHA1", fileext: ".sha1", todir: target.getAbsolutePath()) {
+      ant.fileset(dir: tmpDir.getAbsolutePath())
+    }
+    
+    project.delete(tmpDir)
+    
+    ant.fixcrlf(srcdir: target.getAbsolutePath(), includes: "**/*.jar.sha1", eol: "lf", fixlast: "true", encoding: "US-ASCII")
+  }
+}
+
+
diff --git a/lucene/build.gradle b/lucene/build.gradle
index da6c0c8..b8ccb65 100644
--- a/lucene/build.gradle
+++ b/lucene/build.gradle
@@ -23,3 +23,11 @@ subprojects {
 
 tasks.create("checkLicenses", LicenseCheckTask, new File(projectDir.getAbsolutePath()
     + System.properties['file.separator'] + "licenses"))
+
+
+task jarChecksum(type: org.apache.lucene.gradle.JarChecksum) {
+  group = 'Build'
+  description = "Generates checksums for Lucene dependency jars."
+  inputDir = new File(project.rootProject.projectDir, "/lucene")
+  target = new File(project.rootProject.projectDir, "/lucene/licenses")
+}
diff --git a/solr/build.gradle b/solr/build.gradle
index 20bf23c..a9d501c 100644
--- a/solr/build.gradle
+++ b/solr/build.gradle
@@ -22,4 +22,11 @@ subprojects {
 }
 
 tasks.create("checkLicenses", LicenseCheckTask, new File(projectDir.getAbsolutePath()
-    + System.properties['file.separator'] + "licenses"))
\ No newline at end of file
+    + System.properties['file.separator'] + "licenses"))
+
+task jarChecksum(type: org.apache.lucene.gradle.JarChecksum) {
+  group = 'Build'
+  description = "Generates checksums for dependency Solr jars."
+  inputDir = new File(project.rootProject.projectDir, "/solr")
+  target = new File(project.rootProject.projectDir, "/solr/licenses")
+}