final NumberFormat doubleFormat = NumberFormat.getInstance(Locale.US);
doubleFormat.setMinimumFractionDigits(1);
doubleFormat.setMaximumFractionDigits(1);
final String version = doubleFormat.format(playerVersion);
final MavenArtifact playerArtifact = new MavenArtifact();
playerArtifact.setGroupId("com.adobe.flash");
playerArtifact.setArtifactId("runtime");
playerArtifact.setVersion(version);
playerArtifact.setPackaging("exe");
// Deploy Windows binaries.
final File windowsDirectory = new File(versionDir, "win");
if(windowsDirectory.exists()) {
// Find out if a flash-player binary exists.
File flashPlayerBinary = null;
if(new File(windowsDirectory, "FlashPlayerDebugger.exe").exists()) {
flashPlayerBinary = new File(windowsDirectory, "FlashPlayerDebugger.exe");
} else if(new File(windowsDirectory, "FlashPlayer.exe").exists()) {
flashPlayerBinary = new File(windowsDirectory, "FlashPlayer.exe");
}
// If a binary exists, copy it to the target and create a pom for it.
if (flashPlayerBinary != null) {
playerArtifact.addBinaryArtifact("win", flashPlayerBinary);
}
}
// Deploy Mac binaries.
final File macDirectory = new File(versionDir, "mac");
if(macDirectory.exists()) {
// Find out if a flash-player binary exists.
File flashPlayerBinary = null;
if(new File(macDirectory, "Flash Player.app.zip").exists()) {
flashPlayerBinary = new File(macDirectory, "Flash Player.app.zip");
} else if(new File(macDirectory, "Flash Player Debugger.app.zip").exists()) {
flashPlayerBinary = new File(macDirectory, "Flash Player Debugger.app.zip");
}
// If a binary exists, copy it to the target and create a pom for it.
if (flashPlayerBinary != null) {
playerArtifact.addBinaryArtifact("mac", flashPlayerBinary);
}
}
// Deploy Linux binaries.
final File lnxDirectory = new File(versionDir, "lnx");
if(lnxDirectory.exists()) {
// Find out if a flash-player binary exists.
File flashPlayerBinary;
if(new File(lnxDirectory, "flashplayer.tar.gz").exists()) {
flashPlayerBinary = new File(lnxDirectory, "flashplayer.tar.gz");
} else if(new File(lnxDirectory, "flashplayerdebugger.tar.gz").exists()) {
flashPlayerBinary = new File(lnxDirectory, "flashplayerdebugger.tar.gz");
} else {
throw new ConverterException("Couldn't find player archive.");
}
// Decompress the archive.
// First unzip it.
final FileInputStream fin;
try {
fin = new FileInputStream(flashPlayerBinary);
final BufferedInputStream in = new BufferedInputStream(fin);
final File tempTarFile = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".tar");
final FileOutputStream out = new FileOutputStream(tempTarFile);
final GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
final byte[] buffer = new byte[1024];
int n;
while (-1 != (n = gzIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
gzIn.close();
// Then untar it.
File uncompressedBinary = null;
final FileInputStream tarFileInputStream = new FileInputStream(tempTarFile);
final TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(tarFileInputStream);
ArchiveEntry entry;
while((entry = tarArchiveInputStream.getNextEntry()) != null) {
if("flashplayer".equals(entry.getName())) {
uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
while(-1 != (n = tarArchiveInputStream.read(buffer))) {
uncompressedBinaryOutputStream.write(buffer, 0, n);
}
uncompressedBinaryOutputStream.close();
} else if("flashplayerdebugger".equals(entry.getName())) {
uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
while(-1 != (n = tarArchiveInputStream.read(buffer))) {
uncompressedBinaryOutputStream.write(buffer, 0, n);
}
uncompressedBinaryOutputStream.close();
}
}
tarFileInputStream.close();
// If a binary exists, copy it to the target and create a pom for it.
if (uncompressedBinary != null) {
playerArtifact.addBinaryArtifact("linux", flashPlayerBinary);
}
} catch (FileNotFoundException e) {
throw new ConverterException("Error processing the linux player tar file", e);
} catch (IOException e) {
throw new ConverterException("Error processing the linux player tar file", e);