Skip to content
Permalink
Browse files
- Switched from System.out.println to logback
- Fixed a problem in the AirConverter, not packaging all the required parts
  • Loading branch information
chrisdutz committed Feb 3, 2017
1 parent 30ef5fb commit 9b38938c03d454415258226ae10e7d3aa464493e
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 22 deletions.
@@ -20,6 +20,8 @@
import org.apache.flex.utilities.converter.Converter;
import org.apache.flex.utilities.converter.exceptions.ConverterException;
import org.apache.flex.utilities.converter.model.MavenArtifact;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.*;
@@ -31,6 +33,8 @@
*/
public class AirConverter extends BaseConverter implements Converter {

private static final Logger LOG = LoggerFactory.getLogger(AirConverter.class);

private String airSdkVersion;

/**
@@ -53,7 +57,7 @@ public AirConverter(File rootSourceDirectory, File rootTargetDirectory) throws C
@Override
protected void processDirectory() throws ConverterException {
if ((airSdkVersion == null) || !rootSourceDirectory.exists() || !rootSourceDirectory.isDirectory()) {
System.out.println("Skipping AIR SDK generation.");
LOG.info("Skipping AIR SDK generation.");
return;
}

@@ -94,13 +98,28 @@ private void generateCompilerArtifacts() throws ConverterException {
compiler.addDependency(artifact);
}

// Generate the common package (files from the bin directory)
File binDir = new File(rootSourceDirectory, "bin");
if (binDir.exists() && binDir.isDirectory()) {
final File commonZip = new File(rootTargetDirectory,
"com.adobe.air.compiler.adt.".replace(".", File.separator) + airSdkVersion +
File.separator + "adt-" + airSdkVersion + "-common.zip");
generateZip(binDir, commonZip, new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return "adt".equals(name) || "adt.bat".equals(name) ||
"adl".equals(name) || "adl.exe".equals(name);
}
});
}

// Generate the android package (android directory)
File androidDir = new File(directory, "android");
if (androidDir.exists() && androidDir.isDirectory()) {
final File androidZip = new File(rootTargetDirectory,
"com.adobe.air.compiler.adt.".replace(".", File.separator) + airSdkVersion +
File.separator + "adt-" + airSdkVersion + "-android.zip");
generateCompilerPlatformArtifact(androidDir, androidZip);
generateZip(androidDir, androidZip);
}

// Generate the ios package (aot directory)
@@ -109,7 +128,7 @@ private void generateCompilerArtifacts() throws ConverterException {
final File iosZip = new File(rootTargetDirectory,
"com.adobe.air.compiler.adt.".replace(".", File.separator) + airSdkVersion +
File.separator + "adt-" + airSdkVersion + "-ios.zip");
generateCompilerPlatformArtifact(iosDir, iosZip);
generateZip(iosDir, iosZip);
}

// Generate the exe, dmg, deb, rpm packages (nai directory)
@@ -118,7 +137,7 @@ private void generateCompilerArtifacts() throws ConverterException {
final File desktopZip = new File(rootTargetDirectory,
"com.adobe.air.compiler.adt.".replace(".", File.separator) + airSdkVersion +
File.separator + "adt-" + airSdkVersion + "-desktop.zip");
generateCompilerPlatformArtifact(desktopDir, desktopZip);
generateZip(desktopDir, desktopZip);
}

// Generate the windows packages (win directory)
@@ -127,7 +146,7 @@ private void generateCompilerArtifacts() throws ConverterException {
final File windowsZip = new File(rootTargetDirectory,
"com.adobe.air.compiler.adt.".replace(".", File.separator) + airSdkVersion +
File.separator + "adt-" + airSdkVersion + "-win.zip");
generateCompilerPlatformArtifact(windowsDir, windowsZip);
generateZip(windowsDir, windowsZip);
}

// Write this artifact to file.
@@ -279,12 +298,17 @@ private void generateMiscArtifact() throws ConverterException {
//
///////////////////////////////////////////////////////////////////////////////////////////////////

private void generateCompilerPlatformArtifact(File inputDir, File outputFile) throws ConverterException {
private void generateZip(File inputDir, File outputFile) throws ConverterException {
generateZip(inputDir, outputFile, null);
}

private void generateZip(File inputDir, File outputFile, FilenameFilter filter)
throws ConverterException {
try {
// Add all the content to a zip-file.
final ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(outputFile));
// Package all the compiler parts.
File[] zipfiles = inputDir.listFiles();
File[] zipfiles = (filter != null) ? inputDir.listFiles(filter) : inputDir.listFiles();
if(zipfiles != null) {
for (final File file : zipfiles) {
addFileToZip(zipOutputStream, file, rootSourceDirectory);
@@ -436,7 +460,7 @@ public boolean accept(File pathname) {
result = !(pathname.getName().endsWith(".swc") || pathname.getName().endsWith(".swf"));
}

System.out.println(relativePath + " = " + result);
LOG.debug(relativePath + " = " + result);
return result;
}
}
@@ -47,6 +47,22 @@
<artifactId>freemarker</artifactId>
<version>2.3.22</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.7</version>
</dependency>
</dependencies>

</project>
@@ -26,6 +26,8 @@
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.codehaus.jettison.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
@@ -50,6 +52,8 @@
*/
public abstract class BaseConverter {

private static final Logger LOG = LoggerFactory.getLogger(BaseConverter.class);

protected final Map<String, MavenArtifact> checksums = new HashMap<String, MavenArtifact>();

protected static final String MAVEN_CENTRAL_SHA_1_QUERY_URL = "http://search.maven.org/solrsearch/select?rows=20&wt=json&q=1:";
@@ -210,7 +214,7 @@ protected MavenArtifact lookupMetadataForChecksum(String checksum) throws Conver

return artifactMetadata;
} else {
System.out.println("For jar-file with checksum: " + checksum +
LOG.warn("For jar-file with checksum: " + checksum +
" more than one result was returned by query: " +
MAVEN_CENTRAL_SHA_1_QUERY_URL + checksum);
}
@@ -319,7 +323,7 @@ protected MavenArtifact resolveArtifact(File sourceFile, String defaultGroupId,

// Reusing artifact from other sdk version.
if(artifact != null) {
System.out.println("Reusing artifact (" + checksum + ") : " + artifact.getGroupId() + ":" +
LOG.info("Reusing artifact (" + checksum + ") : " + artifact.getGroupId() + ":" +
artifact.getArtifactId() + ":" + artifact.getVersion());
return artifact;
}
@@ -330,7 +334,7 @@ protected MavenArtifact resolveArtifact(File sourceFile, String defaultGroupId,

// The file was available on maven central, so use that version instead of the one coming with the sdk.
if(artifact != null) {
System.out.println("Using artifact from Maven Central (" + checksum + ") : " +
LOG.info("Using artifact from Maven Central (" + checksum + ") : " +
artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion());
}
// The file was not available on maven central, so we have to add it manually.
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>

<root level="info">
<appender-ref ref="STDOUT" />
</root>

</configuration>
@@ -45,6 +45,8 @@
import org.eclipse.aether.transport.http.HttpTransporterFactory;
import org.eclipse.aether.transport.wagon.WagonTransporterFactory;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileReader;
@@ -62,6 +64,8 @@
*/
public class AetherDeployer {

private static final Logger LOG = LoggerFactory.getLogger(AetherDeployer.class);

private File directory;
private String url;
private String username;
@@ -94,13 +98,13 @@ public static void main(String[] args) {
}

private static void printUsage() {
System.out.println("\nUsage: java -cp flex-sdk-converter-1.0.jar SDKInVMDeployer \"directory\" \"url\" [\"username\", \"password\"]\n");
System.out.println("The SDKDeployer needs at least 2 ordered parameters separated by spaces:");
System.out.println("\t1- directory: The path to the directory containing the artifacts that should be deployed.");
System.out.println("\t2- url: URL where the artifacts will be deployed.");
System.out.println("If the targeted repository requires authentication two more parameters have to be provided:");
System.out.println("\t3- username: The username used to authenticate on the target repository.");
System.out.println("\t4- password: The password used to authenticate on the target repository.");
LOG.error("\nUsage: java -cp flex-sdk-converter-1.0.jar SDKInVMDeployer \"directory\" \"url\" [\"username\", \"password\"]\n" +
"The SDKDeployer needs at least 2 ordered parameters separated by spaces:\n" +
"\t1- directory: The path to the directory containing the artifacts that should be deployed.\b" +
"\t2- url: URL where the artifacts will be deployed.\n" +
"If the targeted repository requires authentication two more parameters have to be provided:\n" +
"\t3- username: The username used to authenticate on the target repository.\n" +
"\t4- password: The password used to authenticate on the target repository.");
}

public void deploy() {
@@ -120,7 +124,7 @@ public void deploy() {
final RepositorySystem repositorySystem = locator.getService(RepositorySystem.class);

if (repositorySystem == null) {
System.out.println("Couldn't initialize local maven repository system.");
LOG.error("Couldn't initialize local maven repository system.");
System.exit(0);
} else {
// Setup the repository system session based upon the current maven settings.xml.
@@ -141,7 +145,7 @@ public void deploy() {
processDir(rootDir, repositorySystem, session, remoteRepository);
}
} catch (Throwable e) {
e.printStackTrace();
LOG.error("Error deploying artifacts in directory: " + directory.getAbsolutePath(), e);
}
}

@@ -214,10 +218,10 @@ private void processArtifact(File pomFile, RepositorySystem repositorySystem, Re
}

// Actually install the artifact.
System.out.println("Installing Artifact: " + pomArtifact.getGroupId() + ":" +
LOG.info("Installing Artifact: " + pomArtifact.getGroupId() + ":" +
pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion());
for (final Artifact artifact : artifactInstallRequest.getArtifacts()) {
System.out.println(" - File with extension " + artifact.getExtension() +
LOG.info(" - File with extension " + artifact.getExtension() +
((artifact.getClassifier().length() > 0) ? " and classifier " + artifact.getClassifier() : ""));
}

0 comments on commit 9b38938

Please sign in to comment.