Skip to content

Commit

Permalink
Merge branch 'eclipse-tests-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
rzwitserloot committed Oct 24, 2024
2 parents 87bc91a + 7a9f3a8 commit 03cd61a
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
Expand Down Expand Up @@ -66,17 +67,13 @@ public static void main(String[] args) throws Exception {
String pluginSource = updateSite.getResolvedUrl() + "/plugins/";

for (String artifact : artifacts) {
try {
downloadFile(artifact, pluginSource, pluginTarget);
} catch (Exception e) {
}
// Download artifact
downloadFile(artifact, pluginSource, pluginTarget);

// Download artifact source
int index = artifact.lastIndexOf("_");
String source = artifact.substring(0, index) + ".source" + artifact.substring(index);
try {
downloadFile(source, pluginSource, pluginTarget);
} catch (Exception e) {
}
downloadFile(source, pluginSource, pluginTarget);
}

writeEclipseLibrary(target, eclipseVersion);
Expand All @@ -99,27 +96,29 @@ private static void downloadFile(String filename, String repositoryUrl, String t

copyZipButStripSignatures(in, out);
System.out.println("[done]");
} catch (IOException e) {
System.out.println("[error]");
} finally {
if (in != null) try {
in.close();
} catch (Exception ignore) {
try {
if (in != null) in.close();
} finally {
if (out != null) out.close();
}
if (out != null) out.close();
}
}

private static void copyZipButStripSignatures(InputStream rawIn, OutputStream rawOut) throws IOException {
ZipInputStream in = new ZipInputStream(rawIn);
ZipOutputStream out = new ZipOutputStream(rawOut);
ZipInputStream in = null;
ZipOutputStream out = null;

in = new ZipInputStream(rawIn);
out = new ZipOutputStream(rawOut);

ZipEntry zipEntry;
while ((zipEntry = in.getNextEntry()) != null) {
if (zipEntry.getName().matches("META-INF/.*\\.(SF|RSA)")) continue;
out.putNextEntry(zipEntry);
copy(in, out);
}
out.close(); // zip streams buffer.
}

private static void copy(InputStream from, OutputStream to) throws IOException {
Expand All @@ -135,8 +134,7 @@ private static InputStream getStreamForUrl(String url) throws IOException, Malfo
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestProperty("User-Agent", "lombok");
connection.setRequestProperty("Accept", "*/*");
InputStream in = new BufferedInputStream(connection.getInputStream());
return in;
return new BufferedInputStream(connection.getInputStream());
}

private static void writeEclipseLibrary(String target, String eclipseVersion) throws IOException {
Expand Down

0 comments on commit 03cd61a

Please sign in to comment.