in src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java [161:279]
public void execute() throws BuildException {
if (splash != null) {
splash.setVisible(false);
getProject().removeBuildListener(splash);
splash.dispose();
splash = null; //NOSONAR
}
log("Creating new SplashScreen", Project.MSG_VERBOSE);
InputStream in = null;
if (imgurl != null) {
try {
URLConnection conn = null;
SetProxy sp = new SetProxy();
sp.setProxyHost(proxy);
if (port != null) {
sp.setProxyPort(Integer.parseInt(port));
}
sp.setProxyUser(user);
sp.setProxyPassword(password);
sp.applyWebProxySettings();
if (useProxy && (proxy != null && !proxy.isEmpty())
&& (port != null && !port.isEmpty())) {
log("Using proxied Connection", Project.MSG_DEBUG);
System.getProperties().put("http.proxySet", "true");
URL url = new URL(imgurl);
conn = url.openConnection();
if (user != null && !user.isEmpty()) {
// converted from sun internal classes to
// new Base64Converter
// utility class extracted from Get task
String encodedcreds =
new Base64Converter().encode(user + ":" + password);
conn.setRequestProperty("Proxy-Authorization",
encodedcreds);
}
} else {
System.getProperties().put("http.proxySet", "false");
log("Using Direction HTTP Connection", Project.MSG_DEBUG);
URL url = new URL(imgurl);
conn = url.openConnection();
}
conn.setDoInput(true);
conn.setDoOutput(false);
in = conn.getInputStream();
// Catch everything - some of the above return nulls,
// throw exceptions or generally misbehave
// in the event of a problem etc
} catch (Throwable ioe) {
log("Unable to download image, trying default Ant Logo",
Project.MSG_DEBUG);
log("(Exception was \"" + ioe.getMessage() + "\"",
Project.MSG_DEBUG);
}
}
if (in == null) {
ClassLoader cl = SplashTask.class.getClassLoader();
if (cl != null) {
in = cl.getResourceAsStream("images/ant_logo_large.gif");
} else {
in = ClassLoader
.getSystemResourceAsStream("images/ant_logo_large.gif");
}
}
boolean success = false;
if (in != null) {
try (DataInputStream din = new DataInputStream(in);
ByteArrayOutputStream bout = new ByteArrayOutputStream()) {
int data;
while ((data = din.read()) != -1) {
bout.write((byte) data);
}
log("Got ByteArray, creating splash", Project.MSG_DEBUG);
try {
ImageIcon img = new ImageIcon(bout.toByteArray());
splash = new SplashScreen(img, progressRegExp, displayText); //NOSONAR
success = true;
} catch (Throwable e) {
logHeadless(e);
}
} catch (Exception e) {
throw new BuildException(e);
} finally {
}
} else {
try {
splash = new SplashScreen("Image Unavailable.", progressRegExp, //NOSONAR
displayText);
success = true;
} catch (Throwable e) {
logHeadless(e);
}
}
if (success) {
splash.setVisible(true);
splash.toFront();
getProject().addBuildListener(splash);
try {
Thread.sleep(showDuration);
} catch (InterruptedException e) {
// Ignore Exception
}
}
}