- Added a "framework" artifact to the flash converter - Made the Flex converter generate 3-digit versions - Added a "maven-extension" module that buids a maven extension that handles mavenization before maven starts to build.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/1edd30bd Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/1edd30bd Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/1edd30bd Branch: refs/heads/as3httpclient-work Commit: 1edd30bd04f1d693b9f5a9d0d8ce255fd57495e8 Parents: 6f2441d Author: Christofer Dutz <christofer.d...@codecentric.de> Authored: Fri Apr 17 11:32:00 2015 +0200 Committer: Christofer Dutz <christofer.d...@codecentric.de> Committed: Fri Apr 17 11:32:00 2015 +0200 ---------------------------------------------------------------------- .../converter/flash/FlashConverter.java | 11 + .../utilities/converter/flex/FlexConverter.java | 2 +- .../mavenextension/FlexSdkInitializer.java | 231 +++++++++++++++++++ mavenizer/pom.xml | 1 + .../converter/retrievers/types/SdkType.java | 2 +- 5 files changed, 245 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1edd30bd/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java ---------------------------------------------------------------------- diff --git a/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java b/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java index a2c1831..776e0c6 100644 --- a/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java +++ b/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java @@ -244,6 +244,17 @@ public class FlashConverter extends BaseConverter implements Converter { playerglobal.setPackaging("swc"); playerglobal.addDefaultBinaryArtifact(playerglobalSwc); writeArtifact(playerglobal); + + // Create a dummy pom artifact that references the playerglobal + // in order to consequently have a framework artifact for every + // part of flex. + final MavenArtifact framework = new MavenArtifact(); + framework.setGroupId("com.adobe.flash"); + framework.setArtifactId("framework"); + framework.setVersion(version); + framework.setPackaging("pom"); + framework.addDependency(playerglobal); + writePomArtifact(framework); } } } http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1edd30bd/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 be8c000..4600b76 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 @@ -582,7 +582,7 @@ public class FlexConverter extends BaseConverter implements Converter { final String build = root.getElementsByTagName("build").item(0).getTextContent(); // In general the version consists of the content of the version element with an appended build-number. - return (build.equals("0")) ? version + "-SNAPSHOT" : version + "." + build; + return (build.equals("0")) ? version + "-SNAPSHOT" : version; } catch (ParserConfigurationException pce) { throw new RuntimeException(pce); } catch (SAXException se) { http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1edd30bd/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 new file mode 100644 index 0000000..fecac35 --- /dev/null +++ b/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexSdkInitializer.java @@ -0,0 +1,231 @@ +/* + * 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; + } + +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1edd30bd/mavenizer/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml index e781a91..285bb78 100644 --- a/mavenizer/pom.xml +++ b/mavenizer/pom.xml @@ -61,6 +61,7 @@ <module>converters</module> <module>deployers</module> <module>cli</module> + <module>maven-extension</module> </modules> <build> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1edd30bd/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java ---------------------------------------------------------------------- diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java index c6c1986..5ea0ba8 100644 --- a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java +++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java @@ -21,9 +21,9 @@ package org.apache.flex.utilities.converter.retrievers.types; */ public enum SdkType { + FLEX, FLASH, AIR, - FLEX, FONTKIT }