]> source.dussan.org Git - gitblit.git/commitdiff
Automatically delete obsolete artifacts from ext
authorJames Moger <james.moger@gitblit.com>
Fri, 28 Sep 2012 01:04:42 +0000 (21:04 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 28 Sep 2012 01:04:42 +0000 (21:04 -0400)
.classpath
src/com/gitblit/build/Build.java

index 1c589d2b1cde56080b6a307549e8864c26a27c35..d4bfd91a2fea1802ff5973dd5c44b587f07d7fd6 100644 (file)
@@ -1,39 +1,39 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="src" path="resources"/>
-       <classpathentry kind="src" path="tests"/>
-       <classpathentry kind="lib" path="ext/jcommander-1.17.jar" sourcepath="ext/src/jcommander-1.17-sources.jar" />
-       <classpathentry kind="lib" path="ext/log4j-1.2.17.jar" sourcepath="ext/src/log4j-1.2.17-sources.jar" />
-       <classpathentry kind="lib" path="ext/slf4j-api-1.6.6.jar" sourcepath="ext/src/slf4j-api-1.6.6-sources.jar" />
-       <classpathentry kind="lib" path="ext/slf4j-log4j12-1.6.6.jar" sourcepath="ext/src/slf4j-log4j12-1.6.6-sources.jar" />
-       <classpathentry kind="lib" path="ext/mail-1.4.3.jar" sourcepath="ext/src/mail-1.4.3-sources.jar" />
-       <classpathentry kind="lib" path="ext/javax.servlet-api-3.0.1.jar" sourcepath="ext/src/javax.servlet-api-3.0.1-sources.jar" />
-       <classpathentry kind="lib" path="ext/jetty-webapp-7.6.5.v20120716.jar" sourcepath="ext/src/jetty-webapp-7.6.5.v20120716-sources.jar" />
-       <classpathentry kind="lib" path="ext/jetty-ajp-7.6.5.v20120716.jar" sourcepath="ext/src/jetty-ajp-7.6.5.v20120716-sources.jar" />
-       <classpathentry kind="lib" path="ext/wicket-1.4.21.jar" sourcepath="ext/src/wicket-1.4.21-sources.jar" />
-       <classpathentry kind="lib" path="ext/wicket-auth-roles-1.4.21.jar" sourcepath="ext/src/wicket-auth-roles-1.4.21-sources.jar" />
-       <classpathentry kind="lib" path="ext/wicket-extensions-1.4.21.jar" sourcepath="ext/src/wicket-extensions-1.4.21-sources.jar" />
-       <classpathentry kind="lib" path="ext/googlecharts-1.4.21.jar" sourcepath="ext/src/googlecharts-1.4.21-sources.jar" />
-       <classpathentry kind="lib" path="ext/lucene-core-3.6.1.jar" sourcepath="ext/src/lucene-core-3.6.1-sources.jar" />
-       <classpathentry kind="lib" path="ext/lucene-highlighter-3.6.1.jar" sourcepath="ext/src/lucene-highlighter-3.6.1-sources.jar" />
-       <classpathentry kind="lib" path="ext/lucene-memory-3.6.1.jar" sourcepath="ext/src/lucene-memory-3.6.1-sources.jar" />
-       <classpathentry kind="lib" path="ext/lucene-queries-3.6.1.jar" sourcepath="ext/src/lucene-queries-3.6.1-sources.jar" />
-       <classpathentry kind="lib" path="ext/jakarta-regexp-1.4.jar" />
-       <classpathentry kind="lib" path="ext/markdownpapers-core-1.2.7.jar" sourcepath="ext/src/markdownpapers-core-1.2.7-sources.jar" />
-       <classpathentry kind="lib" path="ext/org.eclipse.jgit-2.1.0.201209190230-r.jar" sourcepath="ext/src/org.eclipse.jgit-2.1.0.201209190230-r-sources.jar" />
-       <classpathentry kind="lib" path="ext/jsch-0.1.44-1.jar" sourcepath="ext/src/jsch-0.1.44-1-sources.jar" />
-       <classpathentry kind="lib" path="ext/org.eclipse.jgit.http.server-2.1.0.201209190230-r.jar" sourcepath="ext/src/org.eclipse.jgit.http.server-2.1.0.201209190230-r-sources.jar" />
-       <classpathentry kind="lib" path="ext/bcprov-jdk16-1.46.jar" sourcepath="ext/src/bcprov-jdk16-1.46-sources.jar" />
-       <classpathentry kind="lib" path="ext/bcmail-jdk16-1.46.jar" sourcepath="ext/src/bcmail-jdk16-1.46-sources.jar" />
-       <classpathentry kind="lib" path="ext/rome-0.9.jar" sourcepath="ext/src/rome-0.9-sources.jar" />
-       <classpathentry kind="lib" path="ext/jdom-1.0.jar" sourcepath="ext/src/jdom-1.0-sources.jar" />
-       <classpathentry kind="lib" path="ext/gson-1.7.2.jar" sourcepath="ext/src/gson-1.7.2-sources.jar" />
-       <classpathentry kind="lib" path="ext/groovy-all-1.8.8.jar" sourcepath="ext/src/groovy-all-1.8.8-sources.jar" />
-       <classpathentry kind="lib" path="ext/unboundid-ldapsdk-2.3.0.jar" sourcepath="ext/src/unboundid-ldapsdk-2.3.0-sources.jar" />
-       <classpathentry kind="lib" path="ext/ivy-2.2.0.jar" sourcepath="ext/src/ivy-2.2.0-sources.jar" />
-       <classpathentry kind="lib" path="ext/junit-4.10.jar" sourcepath="ext/src/junit-4.10-sources.jar" />
-       <classpathentry kind="lib" path="ext/hamcrest-core-1.1.jar" />
-       <classpathentry kind="output" path="bin"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+    <classpathentry kind="src" path="src"/>
+    <classpathentry kind="src" path="resources"/>
+    <classpathentry kind="src" path="tests"/>
+    <classpathentry kind="lib" path="ext/jcommander-1.17.jar" sourcepath="ext/src/jcommander-1.17-sources.jar" />
+    <classpathentry kind="lib" path="ext/log4j-1.2.17.jar" sourcepath="ext/src/log4j-1.2.17-sources.jar" />
+    <classpathentry kind="lib" path="ext/slf4j-api-1.6.6.jar" sourcepath="ext/src/slf4j-api-1.6.6-sources.jar" />
+    <classpathentry kind="lib" path="ext/slf4j-log4j12-1.6.6.jar" sourcepath="ext/src/slf4j-log4j12-1.6.6-sources.jar" />
+    <classpathentry kind="lib" path="ext/mail-1.4.3.jar" sourcepath="ext/src/mail-1.4.3-sources.jar" />
+    <classpathentry kind="lib" path="ext/javax.servlet-api-3.0.1.jar" sourcepath="ext/src/javax.servlet-api-3.0.1-sources.jar" />
+    <classpathentry kind="lib" path="ext/jetty-webapp-7.6.5.v20120716.jar" sourcepath="ext/src/jetty-webapp-7.6.5.v20120716-sources.jar" />
+    <classpathentry kind="lib" path="ext/jetty-ajp-7.6.5.v20120716.jar" sourcepath="ext/src/jetty-ajp-7.6.5.v20120716-sources.jar" />
+    <classpathentry kind="lib" path="ext/wicket-1.4.21.jar" sourcepath="ext/src/wicket-1.4.21-sources.jar" />
+    <classpathentry kind="lib" path="ext/wicket-auth-roles-1.4.21.jar" sourcepath="ext/src/wicket-auth-roles-1.4.21-sources.jar" />
+    <classpathentry kind="lib" path="ext/wicket-extensions-1.4.21.jar" sourcepath="ext/src/wicket-extensions-1.4.21-sources.jar" />
+    <classpathentry kind="lib" path="ext/googlecharts-1.4.21.jar" sourcepath="ext/src/googlecharts-1.4.21-sources.jar" />
+    <classpathentry kind="lib" path="ext/lucene-core-3.6.1.jar" sourcepath="ext/src/lucene-core-3.6.1-sources.jar" />
+    <classpathentry kind="lib" path="ext/lucene-highlighter-3.6.1.jar" sourcepath="ext/src/lucene-highlighter-3.6.1-sources.jar" />
+    <classpathentry kind="lib" path="ext/lucene-memory-3.6.1.jar" sourcepath="ext/src/lucene-memory-3.6.1-sources.jar" />
+    <classpathentry kind="lib" path="ext/lucene-queries-3.6.1.jar" sourcepath="ext/src/lucene-queries-3.6.1-sources.jar" />
+    <classpathentry kind="lib" path="ext/jakarta-regexp-1.4.jar" />
+    <classpathentry kind="lib" path="ext/markdownpapers-core-1.2.7.jar" sourcepath="ext/src/markdownpapers-core-1.2.7-sources.jar" />
+    <classpathentry kind="lib" path="ext/org.eclipse.jgit-2.1.0.201209190230-r.jar" sourcepath="ext/src/org.eclipse.jgit-2.1.0.201209190230-r-sources.jar" />
+    <classpathentry kind="lib" path="ext/jsch-0.1.44-1.jar" sourcepath="ext/src/jsch-0.1.44-1-sources.jar" />
+    <classpathentry kind="lib" path="ext/org.eclipse.jgit.http.server-2.1.0.201209190230-r.jar" sourcepath="ext/src/org.eclipse.jgit.http.server-2.1.0.201209190230-r-sources.jar" />
+    <classpathentry kind="lib" path="ext/bcprov-jdk16-1.46.jar" sourcepath="ext/src/bcprov-jdk16-1.46-sources.jar" />
+    <classpathentry kind="lib" path="ext/bcmail-jdk16-1.46.jar" sourcepath="ext/src/bcmail-jdk16-1.46-sources.jar" />
+    <classpathentry kind="lib" path="ext/rome-0.9.jar" sourcepath="ext/src/rome-0.9-sources.jar" />
+    <classpathentry kind="lib" path="ext/jdom-1.0.jar" sourcepath="ext/src/jdom-1.0-sources.jar" />
+    <classpathentry kind="lib" path="ext/gson-1.7.2.jar" sourcepath="ext/src/gson-1.7.2-sources.jar" />
+    <classpathentry kind="lib" path="ext/groovy-all-1.8.8.jar" sourcepath="ext/src/groovy-all-1.8.8-sources.jar" />
+    <classpathentry kind="lib" path="ext/unboundid-ldapsdk-2.3.0.jar" sourcepath="ext/src/unboundid-ldapsdk-2.3.0-sources.jar" />
+    <classpathentry kind="lib" path="ext/ivy-2.2.0.jar" sourcepath="ext/src/ivy-2.2.0-sources.jar" />
+    <classpathentry kind="lib" path="ext/junit-4.10.jar" sourcepath="ext/src/junit-4.10-sources.jar" />
+    <classpathentry kind="lib" path="ext/hamcrest-core-1.1.jar" />
+    <classpathentry kind="output" path="bin"/>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 </classpath>
\ No newline at end of file
index 316b2a6bc9adde747a104ddbf495aafc1c5e92d2..5788b2512811b451c44e787f4544e7d0b9eafbb9 100644 (file)
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;\r
 import java.io.FileInputStream;\r
 import java.io.FileWriter;\r
+import java.io.FilenameFilter;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
 import java.io.RandomAccessFile;\r
@@ -379,6 +380,7 @@ public class Build {
                        \r
                        if (targetFile.exists()) {\r
                                downloads.add(targetFile);\r
+                               removeObsoleteArtifacts(mo, type, targetFile.getParentFile());\r
                                continue;\r
                        }\r
                        String expectedSHA1 = mo.getSHA1(jar);\r
@@ -454,9 +456,41 @@ public class Build {
                                throw new RuntimeException("Error writing to file " + targetFile, e);\r
                        }\r
                        downloads.add(targetFile);\r
+                       \r
+                       removeObsoleteArtifacts(mo, type, targetFile.getParentFile());\r
                }\r
                return downloads;\r
        }\r
+       \r
+       private static void removeObsoleteArtifacts(final MavenObject mo, final BuildType type, File folder) {\r
+               File [] removals = folder.listFiles(new FilenameFilter() {\r
+                       @Override\r
+                       public boolean accept(File dir, String name) {\r
+                               String n = name.toLowerCase();\r
+                               String dep = mo.artifact.toLowerCase();\r
+                               if (n.startsWith(dep)) {\r
+                                       String suffix = "-" + mo.version;\r
+                                       if (type.equals(BuildType.COMPILETIME)) {\r
+                                               suffix += "-sources.jar";\r
+                                       } else {\r
+                                               suffix += ".jar";\r
+                                       }\r
+                                       if (!n.endsWith(suffix)) {\r
+                                               return true;\r
+                                       }\r
+                               }\r
+                               return false;\r
+                       }\r
+               });\r
+               \r
+               // delete any matches\r
+               if (removals != null) {\r
+                       for (File file : removals) {\r
+                               System.out.println("deleting " + file);\r
+                               file.delete();\r
+                       }\r
+               }\r
+       }\r
 \r
        private static void updateDownload(float progress, File file) {\r
                updateProgress(progress, "d/l: " + file.getName());\r