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 2014/06/05 19:23:55 UTC
git commit: [flex-utilities] [refs/heads/mavenizer-refactoring] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Removed the dependency management section and
added the version to the artifacts thems
Repository: flex-utilities
Updated Branches:
refs/heads/mavenizer-refactoring 2e4279bb6 -> fac7e6fb3
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Removed the dependency management section and added the version to the artifacts themselves
- Made the mavenizer generate the mx artifact to the main framework
- Added the generation of the asdoc template.zip
- Added a first version of a batch converter to convert a set of fdks
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/fac7e6fb
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/fac7e6fb
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/fac7e6fb
Branch: refs/heads/mavenizer-refactoring
Commit: fac7e6fb3cf937a3c69b91d2efc588e0eef936a5
Parents: 2e4279b
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Thu Jun 5 19:23:41 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Thu Jun 5 19:23:41 2014 +0200
----------------------------------------------------------------------
.../flex/utilities/converter/BaseConverter.java | 15 ++--
.../utilities/converter/flex/FlexConverter.java | 61 ++++++++++++--
.../converter/core/BatchConverter.java | 88 ++++++++++++++++++++
3 files changed, 152 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fac7e6fb/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index 6f67c6d..47466d1 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -51,7 +51,7 @@ import java.util.zip.ZipOutputStream;
*/
public abstract class BaseConverter {
- protected static final Map<String, MavenArtifact> checksums = new HashMap<String, MavenArtifact>();
+ protected final Map<String, MavenArtifact> checksums = new HashMap<String, MavenArtifact>();
protected static final String MAVEN_SCHEMA_URI = "http://maven.apache.org/POM/4.0.0";
protected static final String MAVEN_CENTRAL_SHA_1_QUERY_URL = "http://search.maven.org/solrsearch/select?rows=20&wt=json&q=1:";
@@ -306,10 +306,10 @@ public abstract class BaseConverter {
if((metadata.getDependencies() != null) && !metadata.getDependencies().isEmpty()) {
final Element dependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
root.appendChild(dependencies);
- final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
+ /*final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
final Element dependencyManagementDependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
dependencyManagement.appendChild(dependencyManagementDependencies);
- root.appendChild(dependencyManagement);
+ root.appendChild(dependencyManagement);*/
final Map<String, MavenArtifact> dependencyIndex = new HashMap<String, MavenArtifact>();
for(final MavenArtifact dependencyMetadata : metadata.getDependencies()) {
@@ -323,6 +323,9 @@ public abstract class BaseConverter {
Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
dependency.appendChild(dependencyArtifactId);
+ Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ dependencyVersion.setTextContent(dependencyMetadata.getVersion());
+ dependency.appendChild(dependencyVersion);
Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
dependency.appendChild(dependencyPackaging);
@@ -333,20 +336,20 @@ public abstract class BaseConverter {
}
// Configure the dependency including version in the dependency management section of the pom.
- dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
+ /*dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
dependency.appendChild(dependencyGroupId);
dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
dependency.appendChild(dependencyArtifactId);
- Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
dependencyVersion.setTextContent(dependencyMetadata.getVersion());
dependency.appendChild(dependencyVersion);
dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
dependency.appendChild(dependencyPackaging);
- dependencyManagementDependencies.appendChild(dependency);
+ dependencyManagementDependencies.appendChild(dependency);*/
dependencyIndex.put(dependencyMetadata.getArtifactId(), dependencyMetadata);
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fac7e6fb/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java b/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
index 1d0709a..7d1c671 100644
--- a/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
+++ b/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
@@ -149,6 +149,14 @@ public class FlexConverter extends BaseConverter implements Converter {
framework.addDependency(artifact);
}
}
+
+ // Forcefully add the mx library to the rest of the framework.
+ if("libs".equals(directory.getName())) {
+ final File mxSwc = new File(directory, "mx/mx.swc");
+ final MavenArtifact artifact = resolveArtifact(mxSwc, artifactGroupId, flexSdkVersion);
+ framework.addDependency(artifact);
+ }
+
// If we are in the "mobile" directory and the paren contains an "experimental_mobile.swc" file,
// add this to the mobile package.
if("mobile".equals(directory.getName())) {
@@ -166,7 +174,8 @@ public class FlexConverter extends BaseConverter implements Converter {
children.addAll(Arrays.asList(directory.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
- return pathname.isDirectory() && !"player".equals(pathname.getName());
+ return pathname.isDirectory() && !"player".equals(pathname.getName()) &&
+ !"mx".equals(pathname.getName());
}
})));
for(final File childDirectory : children) {
@@ -200,7 +209,7 @@ public class FlexConverter extends BaseConverter implements Converter {
@Override
protected void writeArtifact(MavenArtifact artifact) throws ConverterException {
if(!"pom".equals(artifact.getPackaging())) {
- // Copy the rsls too.
+ // Copy the rsls.
final File rslSourceFile = getRsl(artifact.getArtifactId());
if(rslSourceFile != null) {
final File rslTargetFile = new File(
@@ -209,7 +218,7 @@ public class FlexConverter extends BaseConverter implements Converter {
copyFile(rslSourceFile, rslTargetFile);
}
- // Copy the swzc too.
+ // Copy the swzc.
final File signedRslSourceFile = getSignedRsl(artifact.getArtifactId());
if(signedRslSourceFile != null) {
final File signedRslTargetFile = new File(
@@ -218,7 +227,7 @@ public class FlexConverter extends BaseConverter implements Converter {
copyFile(signedRslSourceFile, signedRslTargetFile);
}
- // Copy the language resources too.
+ // Copy the language resources.
final Map<String, File> resourceBundles = getResourceBundles(artifact.getArtifactId());
if(!resourceBundles.isEmpty() &&
artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER) != null) {
@@ -248,7 +257,7 @@ public class FlexConverter extends BaseConverter implements Converter {
}
}
- // Add source zips ...
+ // Add source zips.
final File sourceArtifactSourceFile = generateSourceArtifact(artifact.getArtifactId());
if(sourceArtifactSourceFile != null) {
final File sourceArtifactTargetFile = new File(
@@ -256,6 +265,18 @@ public class FlexConverter extends BaseConverter implements Converter {
artifact.getArtifactId() + "-" + artifact.getVersion() + "-sources.jar");
copyFile(sourceArtifactSourceFile, sourceArtifactTargetFile);
}
+
+ // If this is the asdoc artifact, create the templates.zip for that.
+ if("asdoc".equals(artifact.getArtifactId())) {
+ final File asdocTemplatesZipSourceFile = generateAsdocTemplatesZip();
+ if (asdocTemplatesZipSourceFile != null) {
+ final File asdocTemplatesZipTargetFile = new File(
+ artifact.getBinaryTargetFile(
+ rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
+ artifact.getArtifactId() + "-" + artifact.getVersion() + "-template.zip");
+ copyFile(asdocTemplatesZipSourceFile, asdocTemplatesZipTargetFile);
+ }
+ }
}
super.writeArtifact(artifact);
@@ -291,6 +312,34 @@ public class FlexConverter extends BaseConverter implements Converter {
return null;
}
+ protected File generateAsdocTemplatesZip() throws ConverterException {
+ final File templatesDirectory = new File(rootSourceDirectory, "asdoc/templates");
+
+ if (templatesDirectory.listFiles() != null) {
+ final File sourceFiles[] = templatesDirectory.listFiles();
+ if (sourceFiles != null) {
+ final File zipInputFiles[] = new File[sourceFiles.length + 1];
+ System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
+
+ try {
+ // Create a temp file.
+ final File targetFile = File.createTempFile("temp-asdoc-templates", "zip");
+
+ JarOutputStream jar = new JarOutputStream(new FileOutputStream(targetFile));
+ for (final File file : zipInputFiles) {
+ addFileToZip(jar, file, templatesDirectory);
+ }
+ jar.close();
+
+ return targetFile;
+ } catch(IOException e) {
+ throw new ConverterException("Error creating asdoc-templates archive.", e);
+ }
+ }
+ }
+ return null;
+ }
+
protected void generateFrameworkConfigurationArtifact() throws ConverterException {
// ZIP up every file (not directory) in the framework directory and the entire themes directory.
final File frameworksDirectory = new File(rootSourceDirectory, "frameworks");
@@ -326,7 +375,7 @@ public class FlexConverter extends BaseConverter implements Converter {
final String themeName = themeDirectory.getName().toLowerCase();
final File themeFile = new File(themeDirectory, themeName + ".swc");
- File targetSwcFile = null;
+ final File targetSwcFile;
if(themeFile.exists()) {
targetSwcFile = themeFile;
} else {
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fac7e6fb/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java
new file mode 100644
index 0000000..e1ed2b1
--- /dev/null
+++ b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flex.utilities.converter.core;
+
+import org.apache.flex.utilities.converter.air.AirConverter;
+import org.apache.flex.utilities.converter.exceptions.ConverterException;
+import org.apache.flex.utilities.converter.flash.FlashConverter;
+import org.apache.flex.utilities.converter.flex.FlexConverter;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * Created by cdutz on 30.05.2014.
+ */
+public class BatchConverter {
+
+ public static void main(String[] args) throws Exception {
+ if(args.length != 2) {
+ System.out.println("Usage: SDKConverter {source-directory} {target-directory}");
+ return;
+ }
+
+ final File sourceDirectory = new File(args[0]);
+ final File targetDirectory = new File(args[1]);
+
+ if(!sourceDirectory.exists()) {
+ throw new Exception("'source-directory' does not exist: " + sourceDirectory.getAbsolutePath());
+ }
+
+ if(!targetDirectory.exists()) {
+ if(!targetDirectory.mkdirs()) {
+ throw new Exception("Could not create 'target-directory': " + targetDirectory.getAbsolutePath());
+ }
+ }
+
+ for(final File batchDirectory : sourceDirectory.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ return pathname.isDirectory();
+ }
+ })) {
+ System.out.println("-------------------------------------------------------------------------------------");
+ System.out.println("Processing directory: " + batchDirectory.getAbsolutePath());
+
+ try {
+ System.out.println("Generating FLEX SDK");
+ final FlexConverter flexConverter = new FlexConverter(batchDirectory, targetDirectory);
+ flexConverter.convert();
+ } catch(Exception e) {
+ System.out.println("Skipping generation of FLEX SDK");
+ }
+
+ try {
+ System.out.println("Generating AIR SDK");
+ final AirConverter airConverter = new AirConverter(batchDirectory, targetDirectory);
+ airConverter.convert();
+ } catch(Exception e) {
+ System.out.println("Skipping generation of AIR SDK");
+ }
+
+ try {
+ System.out.println("Generating Flash SDK");
+ final FlashConverter flashConverter = new FlashConverter(batchDirectory, targetDirectory);
+ flashConverter.convert();
+ } catch(Exception e) {
+ System.out.println("Skipping generation of Flash SDK");
+ }
+
+ System.out.println("Finished.");
+ }
+ }
+
+}