You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2017/04/18 12:15:18 UTC
[12/15] git commit: [flex-utilities]
[refs/heads/feature/flash-downloader] - - Switched from System.out.println to
logback - Fixed a problem in the AirConverter,
not packaging all the required parts
- Switched from System.out.println to logback
- Fixed a problem in the AirConverter, not packaging all the required parts
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/9b38938c
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/9b38938c
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/9b38938c
Branch: refs/heads/feature/flash-downloader
Commit: 9b38938c03d454415258226ae10e7d3aa464493e
Parents: 30ef5fb
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Fri Feb 3 15:31:03 2017 +0100
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Fri Feb 3 15:31:26 2017 +0100
----------------------------------------------------------------------
.../utilities/converter/air/AirConverter.java | 40 ++++++++++++++++----
.../flex-sdk-converter/converters/base/pom.xml | 16 ++++++++
.../flex/utilities/converter/BaseConverter.java | 10 +++--
.../base/src/main/resources/logback.xml | 16 ++++++++
.../deployer/aether/AetherDeployer.java | 26 +++++++------
5 files changed, 86 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/9b38938c/flex-maven-tools/flex-sdk-converter/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java b/flex-maven-tools/flex-sdk-converter/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
index 46373c4..205daaa 100644
--- a/flex-maven-tools/flex-sdk-converter/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
+++ b/flex-maven-tools/flex-sdk-converter/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
@@ -20,6 +20,8 @@ import org.apache.flex.utilities.converter.BaseConverter;
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 @@ import java.util.zip.ZipOutputStream;
*/
public class AirConverter extends BaseConverter implements Converter {
+ private static final Logger LOG = LoggerFactory.getLogger(AirConverter.class);
+
private String airSdkVersion;
/**
@@ -53,7 +57,7 @@ public class AirConverter extends BaseConverter implements Converter {
@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 @@ public class AirConverter extends BaseConverter implements Converter {
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 @@ public class AirConverter extends BaseConverter implements Converter {
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 @@ public class AirConverter extends BaseConverter implements Converter {
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 @@ public class AirConverter extends BaseConverter implements Converter {
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 @@ public class AirConverter extends BaseConverter implements Converter {
//
///////////////////////////////////////////////////////////////////////////////////////////////////
- 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 class AirConverter extends BaseConverter implements Converter {
result = !(pathname.getName().endsWith(".swc") || pathname.getName().endsWith(".swf"));
}
- System.out.println(relativePath + " = " + result);
+ LOG.debug(relativePath + " = " + result);
return result;
}
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/9b38938c/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml b/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
index 71d9a92..fcc4881 100644
--- a/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
+++ b/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
@@ -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>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/9b38938c/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index d80cf8f..f74257e 100644
--- a/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -26,6 +26,8 @@ import org.codehaus.jettison.json.JSONArray;
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 @@ import java.util.zip.ZipOutputStream;
*/
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 @@ public abstract class BaseConverter {
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 @@ public abstract class BaseConverter {
// 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 @@ public abstract class BaseConverter {
// 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.
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/9b38938c/flex-maven-tools/flex-sdk-converter/converters/base/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/base/src/main/resources/logback.xml b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/resources/logback.xml
new file mode 100644
index 0000000..f58d967
--- /dev/null
+++ b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/resources/logback.xml
@@ -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>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/9b38938c/flex-maven-tools/flex-sdk-converter/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java b/flex-maven-tools/flex-sdk-converter/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java
index 89b991b..68b7cfc 100644
--- a/flex-maven-tools/flex-sdk-converter/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java
+++ b/flex-maven-tools/flex-sdk-converter/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java
@@ -45,6 +45,8 @@ import org.eclipse.aether.transport.file.FileTransporterFactory;
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 @@ import java.io.Reader;
*/
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 class AetherDeployer {
}
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 class AetherDeployer {
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 class AetherDeployer {
processDir(rootDir, repositorySystem, session, remoteRepository);
}
} catch (Throwable e) {
- e.printStackTrace();
+ LOG.error("Error deploying artifacts in directory: " + directory.getAbsolutePath(), e);
}
}
@@ -214,10 +218,10 @@ public class AetherDeployer {
}
// 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() : ""));
}