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

toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git


The following commit(s) were added to refs/heads/master by this push:
     new f51e26c  Fix duplicate files in distributions
f51e26c is described below

commit f51e26cb835db51a20ee02b15dbf1cb332ffd2dd
Author: Antoine Toulme <[email protected]>
AuthorDate: Wed May 6 01:27:11 2020 -0700

    Fix duplicate files in distributions
---
 dist/build.gradle                                  | 29 ++++++++-
 .../org/apache/tuweni/dist/DistributionTest.java   | 76 ++++++++++++++++++++++
 2 files changed, 102 insertions(+), 3 deletions(-)

diff --git a/dist/build.gradle b/dist/build.gradle
index 62277d4..c3e5ea9 100644
--- a/dist/build.gradle
+++ b/dist/build.gradle
@@ -83,9 +83,15 @@ distributions {
         include 'gradle/*'
         include 'gradle.properties'
       }
-      rootProject.subprojects.each {
-        include it.projectDir.name + '/src/**'
-        include it.projectDir.name + '/build.gradle'
+      rootProject.subprojects.each { s ->
+        into(s.name) {
+          if (project != s) {
+            from s.sourcesJar.outputs.files.collect {
+              zipTree(it)
+            }
+          }
+          from s.projectDir.toPath().resolve("build.gradle")
+        }
       }
     }
   }
@@ -131,6 +137,15 @@ distributions {
   }
 }
 
+rootProject.subprojects.each {
+  if (it != project) {
+    project.distZip.dependsOn it.assemble
+    project.distTar.dependsOn it.assemble
+    project.sourcesDistZip.dependsOn it.sourcesJar
+    project.sourcesDistTar.dependsOn it.sourcesJar
+  }
+}
+
 sourcesDistZip { zip64 = true }
 
 distTar{ compression = Compression.GZIP }
@@ -186,3 +201,11 @@ task buildRelayerImage(type: DockerBuildImage) {
   dockerFile = file("docker/relayer.Dockerfile")
   tag = "apache-tuweni/relayer:$project.version"
 }
+integrationTest.dependsOn build
+
+dependencies {
+  integrationTestCompile 'org.junit.jupiter:junit-jupiter-api'
+  integrationTestCompile 'org.junit.jupiter:junit-jupiter-params'
+
+  integrationTestRuntime 'org.junit.jupiter:junit-jupiter-engine'
+}
\ No newline at end of file
diff --git 
a/dist/src/integrationTest/java/org/apache/tuweni/dist/DistributionTest.java 
b/dist/src/integrationTest/java/org/apache/tuweni/dist/DistributionTest.java
new file mode 100644
index 0000000..6184508
--- /dev/null
+++ b/dist/src/integrationTest/java/org/apache/tuweni/dist/DistributionTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+package org.apache.tuweni.dist;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests no duplicate entries are present in the distribution zip file.
+ */
+class DistributionTest {
+
+  private static Path distributionsFolder() {
+    File currentFile = new 
File(DistributionTest.class.getProtectionDomain().getCodeSource().getLocation().getPath());
+    // dist/build/classes/java/org/apache/tuweni/dist
+    Path parentFolder = currentFile.toPath();
+    while (!"dist".equals(parentFolder.getFileName().toString()) && 
parentFolder.getParent() != null) {
+      parentFolder = parentFolder.getParent();
+    }
+    return parentFolder.resolve("build/distributions");
+  }
+
+  @Test
+  void testZipFileContents() throws IOException {
+    Map<String, Set<String>> dupes = new HashMap<>();
+    boolean foundOneZipFile = false;
+    for (File archive : distributionsFolder().toFile().listFiles()) {
+      if (archive.getName().endsWith(".zip")) {
+        foundOneZipFile = true;
+        Set<String> duplicates = new HashSet<>();
+        Set<String> files = new HashSet<>();
+        try (ZipFile zip = new ZipFile(archive)) {
+          Enumeration<? extends ZipEntry> entries = zip.entries();
+          while (entries.hasMoreElements()) {
+            ZipEntry entry = entries.nextElement();
+            if (!files.add(entry.getName())) {
+              duplicates.add(entry.getName());
+              dupes.putIfAbsent(archive.getName(), duplicates);
+            }
+          }
+        }
+
+      }
+    }
+    assertTrue(foundOneZipFile);
+    for (Map.Entry<String, Set<String>> entry : dupes.entrySet()) {
+      System.out.println("Archive :" + entry.getKey());
+      for (String file : entry.getValue()) {
+        System.out.println("\t-" + file);
+      }
+    }
+    assertTrue(dupes.isEmpty());
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to