You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by qu...@apache.org on 2015/06/01 00:19:02 UTC
[20/50] [abbrv] git commit: [flex-utilities]
[refs/heads/as3httpclient-work] - - Switched from VelocityTemplates to
Freemarker to avoid some anoying classloader problems in combination with
Maven. - Created a FlexEventSpy Maven core extension which liste
- Switched from VelocityTemplates to Freemarker to avoid some anoying classloader problems in combination with Maven.
- Created a FlexEventSpy Maven core extension which listens for resolution requests for Flex related resources and which kicks the converter in for missing 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/a1ac19f3
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/a1ac19f3
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/a1ac19f3
Branch: refs/heads/as3httpclient-work
Commit: a1ac19f3dda255e781f7c07b0da785a90dcc2a62
Parents: 1edd30b
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Fri Apr 17 20:24:16 2015 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Fri Apr 17 20:24:16 2015 +0200
----------------------------------------------------------------------
mavenizer/converters/base/pom.xml | 6 +-
.../flex/utilities/converter/BaseConverter.java | 46 ++--
.../src/main/resources/templates/default.ftl | 41 ++++
.../src/main/resources/templates/default.vm | 41 ----
.../base/src/main/resources/templates/pom.ftl | 55 +++++
.../base/src/main/resources/templates/pom.vm | 55 -----
.../base/src/main/resources/velocity.properties | 29 ---
.../converter/mavenextension/FlexEventSpy.java | 225 ++++++++++++++++++
.../mavenextension/FlexSdkInitializer.java | 231 -------------------
9 files changed, 342 insertions(+), 387 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/converters/base/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/pom.xml b/mavenizer/converters/base/pom.xml
index e43226e..5a1b89c 100644
--- a/mavenizer/converters/base/pom.xml
+++ b/mavenizer/converters/base/pom.xml
@@ -42,9 +42,9 @@
<version>1.3.1</version>
</dependency>
<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.7</version>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.22</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/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 3e1dbf7..5d904dd 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
@@ -19,10 +19,11 @@ package org.apache.flex.utilities.converter;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateExceptionHandler;
import org.apache.flex.utilities.converter.exceptions.ConverterException;
import org.apache.flex.utilities.converter.model.MavenArtifact;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
@@ -30,12 +31,12 @@ import org.codehaus.jettison.json.JSONTokener;
import java.io.*;
import java.math.BigInteger;
+import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -53,7 +54,7 @@ public abstract class BaseConverter {
protected File rootSourceDirectory;
protected File rootTargetDirectory;
- private VelocityEngine velocityEngine;
+ protected Configuration freemarkerConfig;
protected BaseConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException {
if(rootSourceDirectory == null) {
@@ -66,20 +67,10 @@ public abstract class BaseConverter {
this.rootSourceDirectory = rootSourceDirectory;
this.rootTargetDirectory = rootTargetDirectory;
- try {
- // Load some initial properties from the classpath.
- final Properties properties = new Properties();
- final InputStream propertyInputStream =
- getClass().getClassLoader().getResourceAsStream("velocity.properties");
- if(propertyInputStream != null) {
- properties.load(propertyInputStream);
- }
-
- // Instantiate the engine that will be used for every generation.
- velocityEngine = new VelocityEngine(properties);
- } catch (Exception e) {
- throw new ConverterException("Error initializing the velocity template engine.", e);
- }
+ this.freemarkerConfig = new Configuration(Configuration.VERSION_2_3_22);
+ this.freemarkerConfig.setDefaultEncoding("UTF-8");
+ this.freemarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
+ this.freemarkerConfig.setClassForTemplateLoading(this.getClass(), "/");
}
public void convert() throws ConverterException {
@@ -242,17 +233,16 @@ public abstract class BaseConverter {
protected void createPomDocument(final MavenArtifact metadata, File outputFile) throws ConverterException {
try {
// Build a context to hold the model
- final VelocityContext velocityContext = new VelocityContext();
- velocityContext.put("artifact", metadata);
+ Map freemarkerContext = new HashMap();
+ freemarkerContext.put("artifact", metadata);
// Try to get a template "templates/{type}.vm".
- final String templateName;
- if(velocityEngine.resourceExists("templates/" + metadata.getPackaging() + ".vm")) {
- templateName = "templates/" + metadata.getPackaging() + ".vm";
- } else if(velocityEngine.resourceExists("templates/default.vm")) {
- templateName = "templates/default.vm";
+ Template template;
+ URL check = this.getClass().getClassLoader().getResource("templates/" + metadata.getPackaging() + ".ftl");
+ if(check != null) {
+ template = freemarkerConfig.getTemplate("templates/" + metadata.getPackaging() + ".ftl");
} else {
- throw new ConverterException("No template found for generating pom output.");
+ template = freemarkerConfig.getTemplate("templates/default.ftl");
}
// Prepare an output stream to which the output can be generated.
@@ -266,8 +256,8 @@ public abstract class BaseConverter {
writer = new FileWriter(outputFile);
- // Have velocity generate the output for the template.
- velocityEngine.mergeTemplate(templateName, "utf-8", velocityContext, writer);
+ // Have Freemarker generate the output for the template.
+ template.process(freemarkerContext, writer);
} finally {
if(writer != null) {
writer.close();
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/converters/base/src/main/resources/templates/default.ftl
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/default.ftl b/mavenizer/converters/base/src/main/resources/templates/default.ftl
new file mode 100644
index 0000000..e4a200b
--- /dev/null
+++ b/mavenizer/converters/base/src/main/resources/templates/default.ftl
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>${artifact.groupId}</groupId>
+ <artifactId>${artifact.artifactId}</artifactId>
+ <version>${artifact.version}</version>
+ <packaging>${artifact.packaging}</packaging>
+
+<#if artifact.hasDependencies()>
+ <dependencies>
+<#list artifact.dependencies as dependency>
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+ <type>${dependency.packaging}</type>
+ </dependency>
+</#list>
+ </dependencies>
+</#if>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/converters/base/src/main/resources/templates/default.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/default.vm b/mavenizer/converters/base/src/main/resources/templates/default.vm
deleted file mode 100644
index 21b453f..0000000
--- a/mavenizer/converters/base/src/main/resources/templates/default.vm
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>${artifact.groupId}</groupId>
- <artifactId>${artifact.artifactId}</artifactId>
- <version>${artifact.version}</version>
- <packaging>${artifact.packaging}</packaging>
-
-#if ( $artifact.hasDependencies() )
- <dependencies>
-#foreach( $dependency in $artifact.dependencies )
- <dependency>
- <groupId>${dependency.groupId}</groupId>
- <artifactId>${dependency.artifactId}</artifactId>
- <version>${dependency.version}</version>
- <type>${dependency.packaging}</type>
- </dependency>
-#end
- </dependencies>
-#end
-
-</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/converters/base/src/main/resources/templates/pom.ftl
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/pom.ftl b/mavenizer/converters/base/src/main/resources/templates/pom.ftl
new file mode 100644
index 0000000..1242fb7
--- /dev/null
+++ b/mavenizer/converters/base/src/main/resources/templates/pom.ftl
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>${artifact.groupId}</groupId>
+ <artifactId>${artifact.artifactId}</artifactId>
+ <version>${artifact.version}</version>
+ <packaging>${artifact.packaging}</packaging>
+
+<#if artifact.hasDependencies()>
+ <dependencies>
+<#list artifact.dependencies as dependency>
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+<#if dependency.packaging != "jar">
+ <type>${dependency.packaging}</type>
+</#if>
+ </dependency>
+</#list>
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+<#list artifact.dependencies as dependency>
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+ </dependency>
+</#list>
+ </dependencies>
+ </dependencyManagement>
+</#if>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/converters/base/src/main/resources/templates/pom.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/pom.vm b/mavenizer/converters/base/src/main/resources/templates/pom.vm
deleted file mode 100644
index fc0016b..0000000
--- a/mavenizer/converters/base/src/main/resources/templates/pom.vm
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>${artifact.groupId}</groupId>
- <artifactId>${artifact.artifactId}</artifactId>
- <version>${artifact.version}</version>
- <packaging>${artifact.packaging}</packaging>
-
-#if ( $artifact.hasDependencies() )
- <dependencies>
-#foreach( $dependency in $artifact.dependencies )
- <dependency>
- <groupId>${dependency.groupId}</groupId>
- <artifactId>${dependency.artifactId}</artifactId>
- <version>${dependency.version}</version>
-#if ($dependency.packaging != "jar")
- <type>${dependency.packaging}</type>
-#end
- </dependency>
-#end
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
-#foreach( $dependency in $artifact.dependencies )
- <dependency>
- <groupId>${dependency.groupId}</groupId>
- <artifactId>${dependency.artifactId}</artifactId>
- <version>${dependency.version}</version>
- </dependency>
-#end
- </dependencies>
- </dependencyManagement>
-#end
-
-</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/converters/base/src/main/resources/velocity.properties
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/velocity.properties b/mavenizer/converters/base/src/main/resources/velocity.properties
deleted file mode 100644
index 905ad59..0000000
--- a/mavenizer/converters/base/src/main/resources/velocity.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-################################################################################
-##
-## 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.
-##
-################################################################################
-
-#
-# specify three resource loaders to use
-#
-resource.loader = class
-
-#
-# for the loader we call 'class', use the ClasspathResourceLoader
-#
-class.resource.loader.description = Velocity Classpath Resource Loader
-class.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
----------------------------------------------------------------------
diff --git a/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java b/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
new file mode 100644
index 0000000..b817beb
--- /dev/null
+++ b/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
@@ -0,0 +1,225 @@
+package org.apache.flex.utilities.converter.mavenextension;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.flex.utilities.converter.air.AirConverter;
+import org.apache.flex.utilities.converter.flash.FlashConverter;
+import org.apache.flex.utilities.converter.flex.FlexConverter;
+import org.apache.flex.utilities.converter.fontkit.FontkitConverter;
+import org.apache.flex.utilities.converter.retrievers.download.DownloadRetriever;
+import org.apache.flex.utilities.converter.retrievers.types.SdkType;
+import org.apache.maven.MavenExecutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.eventspy.AbstractEventSpy;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.repository.RepositorySystem;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.logging.Logger;
+import org.eclipse.aether.RepositoryEvent;
+import org.eclipse.aether.artifact.Artifact;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+
+/**
+ * Created by christoferdutz on 17.04.15.
+ */
+@Named
+@Singleton
+public class FlexEventSpy extends AbstractEventSpy {
+
+ protected Context context;
+ protected PlexusContainer plexusContainer;
+ protected RepositorySystem repositorySystem;
+ protected Logger logger;
+
+ protected boolean internalLookup = false;
+ protected boolean flexSplashScreenShown = false;
+
+ @Override
+ public void init(Context context) throws Exception {
+ this.context = context;
+ plexusContainer = (PlexusContainer) context.getData().get("plexus");
+ repositorySystem = plexusContainer.lookup(RepositorySystem.class);
+ logger = plexusContainer.lookup(Logger.class);
+ }
+
+ @Override
+ public void onEvent(Object o) throws Exception {
+ if(o instanceof RepositoryEvent) {
+ RepositoryEvent repositoryEvent = (RepositoryEvent) o;
+ if(repositoryEvent.getType() == RepositoryEvent.EventType.ARTIFACT_RESOLVING) {
+ if(!internalLookup) {
+ try {
+ internalLookup = true;
+ Artifact artifact = repositoryEvent.getArtifact();
+ MavenSession session = plexusContainer.lookup(MavenSession.class);
+ if (artifact.getGroupId().startsWith("org.apache.flex")) {
+ if(!flexSplashScreenShown) {
+ showFlexSplashScreen();
+ }
+ if(resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+ artifact.getExtension(), artifact.getClassifier(), session) == null) {
+ initFlex(artifact.getVersion());
+ }
+ } else if (artifact.getGroupId().startsWith("com.adobe.flash")) {
+ if(resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+ artifact.getExtension(), artifact.getClassifier(), session) == null) {
+ initFlash(artifact.getVersion());
+ }
+ } else if (artifact.getGroupId().startsWith("com.adobe.air")) {
+ if(resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+ artifact.getExtension(), artifact.getClassifier(), session) == null) {
+ initAir(artifact.getVersion());
+ }
+ } else if (artifact.getGroupId().equals("com.adobe") && artifact.getArtifactId().equals("fontkit")) {
+ if(resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+ artifact.getExtension(), artifact.getClassifier(), session) == null) {
+ initFontkit();
+ }
+ }
+ } finally {
+ internalLookup = false;
+ }
+ }
+ }
+ }
+ }
+
+ protected org.apache.maven.artifact.Artifact resolve(String groupId, String artifactId, String version,
+ String type, String classifier, MavenSession session) {
+ org.apache.maven.artifact.Artifact artifact;
+ if((classifier == null) || (classifier.length() == 0)) {
+ artifact = repositorySystem.createArtifact(groupId, artifactId, version, type);
+ } else {
+ artifact = repositorySystem.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
+ }
+ if (!artifact.isResolved()) {
+
+ ArtifactResolutionRequest req = new ArtifactResolutionRequest();
+ req.setArtifact(artifact);
+ req.setLocalRepository(session.getLocalRepository());
+ req.setRemoteRepositories(session.getRequest().getRemoteRepositories());
+ ArtifactResolutionResult res = repositorySystem.resolve(req);
+ if (!res.isSuccess()) {
+ return null;
+ }
+ }
+ return artifact;
+ }
+
+ protected void initFlex(String version) throws MavenExecutionException {
+ logger.info("===========================================================");
+ logger.info(" - Installing Apache Flex SDK " + version);
+ try {
+ MavenSession session = plexusContainer.lookup(MavenSession.class);
+ File localRepoBaseDir = new File(session.getLocalRepository().getBasedir());
+ DownloadRetriever downloadRetriever = new DownloadRetriever();
+ File sdkRoot = downloadRetriever.retrieve(SdkType.FLEX, version);
+
+ // In order to compile some of the themes, we need to download a
+ // playerglobal version.
+ logger.info("In order to convert the Apache Flex SDK, a Flash SDK has to be downloaded.");
+ File flashSdkRoot = downloadRetriever.retrieve(SdkType.FLASH, "10.2");
+ FileUtils.copyDirectory(flashSdkRoot, sdkRoot);
+
+ FlexConverter converter = new FlexConverter(sdkRoot, localRepoBaseDir);
+ converter.convert();
+ } catch (Exception ce) {
+ logger.error("Error", ce);
+ ce.printStackTrace();
+ throw new MavenExecutionException(
+ "Caught exception while downloading and converting artifact.", ce);
+ }
+ logger.info(" - Finished installing Apache Flex SDK " + version);
+ }
+
+ protected void initFlash(String version) throws MavenExecutionException {
+ logger.info("===========================================================");
+ logger.info(" - Installing Adobe Flash SDK " + version);
+ try {
+ MavenSession session = plexusContainer.lookup(MavenSession.class);
+ File localRepoBaseDir = new File(session.getLocalRepository().getBasedir());
+ DownloadRetriever downloadRetriever = new DownloadRetriever();
+ File sdkRoot = downloadRetriever.retrieve(SdkType.FLASH, version);
+ FlashConverter converter = new FlashConverter(sdkRoot, localRepoBaseDir);
+ converter.convert();
+ } catch (Exception ce) {
+ throw new MavenExecutionException(
+ "Caught exception while downloading and converting artifact.", ce);
+ }
+ logger.info(" - Finished installing Adobe Flash SDK " + version);
+ }
+
+ protected void initAir(String version) throws MavenExecutionException {
+ logger.info("===========================================================");
+ logger.info(" - Installing Adobe AIR SDK " + version);
+ try {
+ MavenSession session = plexusContainer.lookup(MavenSession.class);
+ File localRepoBaseDir = new File(session.getLocalRepository().getBasedir());
+ DownloadRetriever downloadRetriever = new DownloadRetriever();
+ File sdkRoot = downloadRetriever.retrieve(SdkType.AIR, version);
+ AirConverter converter = new AirConverter(sdkRoot, localRepoBaseDir);
+ converter.convert();
+ } catch (Exception ce) {
+ throw new MavenExecutionException(
+ "Caught exception while downloading and converting artifact.", ce);
+ }
+ logger.info(" - Finished installing Adobe AIR SDK " + version);
+ }
+
+ protected void initFontkit() throws MavenExecutionException {
+ logger.info("===========================================================");
+ logger.info(" - Installing Adobe Fontkit libraries");
+ try {
+ MavenSession session = plexusContainer.lookup(MavenSession.class);
+ File localRepoBaseDir = new File(session.getLocalRepository().getBasedir());
+ DownloadRetriever downloadRetriever = new DownloadRetriever();
+ File sdkRoot = downloadRetriever.retrieve(SdkType.FONTKIT);
+ FontkitConverter converter = new FontkitConverter(sdkRoot, localRepoBaseDir);
+ converter.convert();
+ } catch (Exception ce) {
+ throw new MavenExecutionException(
+ "Caught exception while downloading and converting artifact.", ce);
+ }
+ logger.info(" - Finished installing Adobe Fontkit libraries");
+ }
+
+
+ protected void showFlexSplashScreen() {
+ logger.info(" \n" +
+ " `,;':, :';;; \n" +
+ " `:;''';' `++'';;, \n" +
+ " :;'''++;' .+'+''';;;\n" +
+ " : ;'''++++'' ,';+++''';'\n" +
+ " ,. `, ,. ..: , `, `'''+++##;'', ;;'+#+++''''\n" +
+ " ; ; ; ;; ;`: :,: ; ; ;'+++; #;;;;;:::;;;;+ +++'':\n" +
+ " ; ; : ;; ;., : : ;. ;;++# ';;;;;;;;;;+ .+++; \n" +
+ " `;: :; `;: :;: , :;` +;+# ,;;;:::::;: ;#+', \n" +
+ " ;++++:'++ : ;+,; ++;# +;::::::; ,+;;: \n" +
+ " ++++++,'++ `++' +'''` ;::::::, +:;;: \n" +
+ " `+++. '++ ++++++ +++ +++ ''''' ;::::: :;;;; \n" +
+ " +++` '++ ++++++++ +++` `++: :'';;; ;::` ::::: \n" +
+ " +++ '++ +++' :++: +++ +++ ;;;;;' :::::: \n" +
+ " +++ '++ +++ ++' `+++++` ;;;;;;: .:::::` \n" +
+ " +++++++ '++ +++:::+++. +++++ ;;;;;;; ,::::: \n" +
+ " +++++++ '++ +++++++++ :+++' ;;;;;;; ,::::: \n" +
+ " +++''' '++ +++;;;:` +++++ ;;;;;;` ::::::. \n" +
+ " +++ '++ +++ +++ +++ ;;;;;: :::::: \n" +
+ " +++ :++. ++++ ` :++, ,++; ''';;. `..: ::::;` \n" +
+ " +++ ++' +++++++ +++ +++ :'''; ,,,,,: ;;;;; \n" +
+ " ;++` +++ ++++++ +++ +++ .+';+ :,,,,,,: `';;; \n" +
+ " ++' `+''' ::,,,,,::: ';;' \n" +
+ " :++ #;'' +:::,,,:::: .'':; \n" +
+ " ';;'' ::::::::::::' ,';;:.\n" +
+ " ;;;;''`;+;;::` .::;;'.,';;;;:\n" +
+ " `::;;;''':;; `;;;'';;;;;;\n" +
+ " :::;;;'';: ;;';;;;;:;\n" +
+ " ,:::;;;', ',;;;;::`\n" +
+ " .:::;:. ;:;;::: \n" +
+ " ::;, `,;;` \n");
+ flexSplashScreenShown = true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a1ac19f3/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexSdkInitializer.java
----------------------------------------------------------------------
diff --git a/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexSdkInitializer.java b/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexSdkInitializer.java
deleted file mode 100644
index fecac35..0000000
--- a/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexSdkInitializer.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * 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.mavenextension;
-
-import org.apache.flex.utilities.converter.air.AirConverter;
-import org.apache.flex.utilities.converter.flash.FlashConverter;
-import org.apache.flex.utilities.converter.flex.FlexConverter;
-import org.apache.flex.utilities.converter.fontkit.FontkitConverter;
-import org.apache.flex.utilities.converter.retrievers.download.DownloadRetriever;
-import org.apache.flex.utilities.converter.retrievers.types.SdkType;
-import org.apache.maven.AbstractMavenLifecycleParticipant;
-import org.apache.maven.MavenExecutionException;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.repository.RepositorySystem;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.logging.Logger;
-
-import java.io.File;
-
-/**
- * Created by christoferdutz on 16.04.15.
- */
-@Component(role = AbstractMavenLifecycleParticipant.class, hint = "flex-sdk-initializer")
-public class FlexSdkInitializer extends AbstractMavenLifecycleParticipant {
-
- public static final String AIR_GROUP_ID = "com.adobe.air";
- public static final String FLASH_GROUP_ID = "com.adobe.flash";
- public static final String FLEX_GROUP_ID = "org.apache.flex";
- public static final String FONTKIT_GROUP_ID = "com.adobe";
-
- public static final String FRAMEWORK = "framework";
- public static final String COMPILER = "compiler";
- public static final String FONTKIT = "fontkit";
-
- public static final String POM = "pom";
- public static final String JAR = "jar";
-
- @Requirement
- protected Logger logger;
-
- @Requirement
- private RepositorySystem repositorySystem;
-
- @Override
- public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
- super.afterProjectsRead(session);
-
- // Get the maven local repo directory.
- File mavenLocalRepoDir = new File(session.getLocalRepository().getBasedir());
-
- logger.info(" \n" +
- " `,;':, :';;; \n" +
- " `:;''';' `++'';;, \n" +
- " :;'''++;' .+'+''';;;\n" +
- " : ;'''++++'' ,';+++''';'\n" +
- " ,. `, ,. ..: , `, `'''+++##;'', ;;'+#+++''''\n" +
- " ; ; ; ;; ;`: :,: ; ; ;'+++; #;;;;;:::;;;;+ +++'':\n" +
- " ; ; : ;; ;., : : ;. ;;++# ';;;;;;;;;;+ .+++; \n" +
- " `;: :; `;: :;: , :;` +;+# ,;;;:::::;: ;#+', \n" +
- " ;++++:'++ : ;+,; ++;# +;::::::; ,+;;: \n" +
- " ++++++,'++ `++' +'''` ;::::::, +:;;: \n" +
- "`+++. '++ ++++++ +++ +++ ''''' ;::::: :;;;; \n" +
- "+++` '++ ++++++++ +++` `++: :'';;; ;::` ::::: \n" +
- "+++ '++ +++' :++: +++ +++ ;;;;;' :::::: \n" +
- "+++ '++ +++ ++' `+++++` ;;;;;;: .:::::` \n" +
- "+++++++ '++ +++:::+++. +++++ ;;;;;;; ,::::: \n" +
- "+++++++ '++ +++++++++ :+++' ;;;;;;; ,::::: \n" +
- "+++''' '++ +++;;;:` +++++ ;;;;;;` ::::::. \n" +
- "+++ '++ +++ +++ +++ ;;;;;: :::::: \n" +
- "+++ :++. ++++ ` :++, ,++; ''';;. `..: ::::;` \n" +
- "+++ ++' +++++++ +++ +++ :'''; ,,,,,: ;;;;; \n" +
- ";++` +++ ++++++ +++ +++ .+';+ :,,,,,,: `';;; \n" +
- " ++' `+''' ::,,,,,::: ';;' \n" +
- " :++ #;'' +:::,,,:::: .'':; \n" +
- " ';;'' ::::::::::::' ,';;:.\n" +
- " ;;;;''`;+;;::` .::;;'.,';;;;:\n" +
- " `::;;;''':;; `;;;'';;;;;;\n" +
- " :::;;;'';: ;;';;;;;:;\n" +
- " ,:::;;;', ',;;;;::`\n" +
- " .:::;:. ;:;;::: \n" +
- " ::;, `,;;` \n");
-
- logger.info("-------------------------------------------------------------------");
- logger.info("- Intializing Apache Flex related resources");
- logger.info("-------------------------------------------------------------------");
- String flexVersion = session.getCurrentProject().getProperties().getProperty("flex.sdk.version", null);
- String flashVersion = session.getCurrentProject().getProperties().getProperty("flash.sdk.version", null);
- String airVersion = session.getCurrentProject().getProperties().getProperty("air.sdk.version", null);
- boolean useFontkit = Boolean.valueOf(
- session.getCurrentProject().getProperties().getProperty("flex.fontkit", "false"));
-
- if (flexVersion != null) {
- logger.info("flex.sdk.version = " + flexVersion);
- Artifact flexFramework = resolve(FLEX_GROUP_ID, FRAMEWORK, flexVersion, POM, session);;
- Artifact flexCompiler = resolve(FLEX_GROUP_ID, COMPILER, flexVersion, POM, session);
-
- if (flexFramework == null || flexCompiler == null) {
- logger.info(" - Installing");
- // Use the Mavenizer to download and install the fex artifacts.
- try {
- DownloadRetriever downloadRetriever = new DownloadRetriever();
- File flexSdkRoot = downloadRetriever.retrieve(SdkType.FLEX, flexVersion);
- FlexConverter flexConverter = new FlexConverter(flexSdkRoot, mavenLocalRepoDir);
- flexConverter.convert();
- } catch (Exception ce) {
- throw new MavenExecutionException(
- "Caught exception while downloading and converting artifact.", ce);
- }
- } else {
- logger.info(" - OK");
- }
- } else {
- logger.info("flex.sdk.version = not set");
- }
-
- logger.info("-------------------------------------------------------------------");
-
- if (flashVersion != null) {
- logger.info("flash.sdk.version = " + flashVersion);
- Artifact flashFramework = resolve(FLASH_GROUP_ID, FRAMEWORK, flashVersion, POM, session);
-
- if (flashFramework == null) {
- logger.info(" - Installing");
- // Use the Mavenizer to download and install the playerglobal artifact.
- try {
- DownloadRetriever downloadRetriever = new DownloadRetriever();
- File flashSdkRoot = downloadRetriever.retrieve(SdkType.FLASH, flashVersion);
- FlashConverter flashConverter = new FlashConverter(flashSdkRoot, mavenLocalRepoDir);
- flashConverter.convert();
- } catch (Exception ce) {
- throw new MavenExecutionException(
- "Caught exception while downloading and converting artifact.", ce);
- }
- } else {
- logger.info(" - OK");
- }
- } else {
- logger.info("flash.sdk.version = not set");
- }
-
- logger.info("-------------------------------------------------------------------");
-
- if (airVersion != null) {
- logger.info("air.sdk.version = " + airVersion);
- Artifact airFramework = resolve(AIR_GROUP_ID, FRAMEWORK, flexVersion, POM, session);
- Artifact airCompiler = resolve(AIR_GROUP_ID, COMPILER, flexVersion, POM, session);
-
- if (airFramework == null || airCompiler == null) {
- logger.info(" - Installing");
- // Use the Mavenizer to download and install the airglobal artifact.
- try {
- DownloadRetriever downloadRetriever = new DownloadRetriever();
- File airSdkRoot = downloadRetriever.retrieve(SdkType.AIR, airVersion);
- AirConverter airConverter = new AirConverter(airSdkRoot, mavenLocalRepoDir);
- airConverter.convert();
- } catch (Exception ce) {
- throw new MavenExecutionException(
- "Caught exception while downloading and converting artifact.", ce);
- }
- } else {
- logger.info(" - OK");
- }
- } else {
- logger.info("air.sdk.version = not set");
- }
-
- logger.info("-------------------------------------------------------------------");
-
- if (useFontkit) {
- logger.info("flex.fontkit = true");
- Artifact fontkit = resolve(FONTKIT_GROUP_ID, FONTKIT, "1.0", JAR, session);
-
- if (fontkit == null) {
- logger.info(" - Installing");
- // Use the Mavenizer to download and install the airglobal artifact.
- try {
- DownloadRetriever downloadRetriever = new DownloadRetriever();
- File fontkitRoot = downloadRetriever.retrieve(SdkType.FONTKIT);
- FontkitConverter fontkitConverter = new FontkitConverter(fontkitRoot, mavenLocalRepoDir);
- fontkitConverter.convert();
- } catch (Exception ce) {
- throw new MavenExecutionException(
- "Caught exception while downloading and converting artifact.", ce);
- }
- } else {
- logger.info(" - OK");
- }
- } else {
- logger.info("flex.fontkit = not set or set to 'false'");
- }
-
- logger.info("-------------------------------------------------------------------");
- logger.info("- Finished initializing Apache Flex related resources");
- logger.info("-------------------------------------------------------------------");
- }
-
- public Artifact resolve(String groupId, String artifactId, String version, String type, MavenSession session) {
- Artifact artifact =
- repositorySystem.createArtifact(groupId, artifactId, version, type);
- if (!artifact.isResolved()) {
- ArtifactResolutionRequest req = new ArtifactResolutionRequest();
- req.setArtifact(artifact);
- req.setLocalRepository(session.getLocalRepository());
- req.setRemoteRepositories(session.getRequest().getRemoteRepositories());
- ArtifactResolutionResult res = repositorySystem.resolve(req);
- if (!res.isSuccess()) {
- return null;
- }
- }
- return artifact;
- }
-
-}