Flex Maven project compilation error: Global artifact is not available. Make sure to add 'playerglobal' or 'airglobal' to this project

Flex Maven project compilation error: Global artifact is not available. Make sure to add 'playerglobal' or 'airglobal' to this project

我正在使用 IntelliJ IDEA 将现有的 flex 项目转换为 Maven 项目。根据 google 上的研发,我添加了 pom.xml 文件,并通过添加所需的依赖项解决了多个问题。但是,我现在停留在一个点上,尽管在 pom 文件中添加了所需的依赖项,但 'compile' 目标仍然会抛出错误。

错误:

Failed to execute goal net.flexmojos.oss:flexmojos-maven-plugin:7.1.0:compile-swf (default-compile-swf) on project TA_UI_Test1: java.lang.reflect.InvocationTargetException: Global artifact is not available. Make sure to add 'playerglobal' or 'airglobal' to this project. -> [Help 1]

pom.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.test</groupId>
  <artifactId>TA_UI_Test1</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swf</packaging>

  <name>TA_UI_Test1 Flex</name>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>net.flexmojos.oss</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>7.1.0</version>
        <extensions>true</extensions>
          <configuration>
              <sourceFile>Main.mxml</sourceFile>
              <debug>true</debug>
              <!--<swfVersion>11</swfVersion>-->
              <!--<targetPlayer>10.2</targetPlayer>-->
          </configuration>
          <dependencies>
              <dependency>
                  <groupId>com.adobe.flex</groupId>
                  <artifactId>compiler</artifactId>
                  <version>4.6.b.23201</version>
                  <type>pom</type>
              </dependency>
          <dependency>
            <groupId>com.adobe.flex.compiler</groupId>
            <artifactId>flex-compiler-oem</artifactId>
            <version>4.1.0.16076</version>
          </dependency>
          <dependency>
            <groupId>com.adobe.flex.compiler</groupId>
            <artifactId>mxmlc</artifactId>
            <version>4.1.0.16076</version>
          </dependency>
          <!--<dependency>-->
            <!--<groupId>com.adobe.flex.framework</groupId>-->
            <!--<artifactId>playerglobal</artifactId>-->
            <!--<version>10-3.3.0.4852</version>-->
            <!--<type>swc</type>-->
          <!--</dependency>-->
            <!--<dependency>-->
                <!--<groupId>com.adobe.flex.framework</groupId>-->
                <!--<artifactId>playerglobal</artifactId>-->
                <!--<version>4.5.1.21328</version>-->
                <!--<classifier>10</classifier>-->
                <!--<type>2.swc</type>-->
            <!--</dependency>-->
              <dependency>
                  <groupId>com.adobe.flex.framework</groupId>
                  <artifactId>playerglobal</artifactId>
                  <version>3.2.0.3958</version>
                  <classifier>9</classifier>
                  <type>swc</type>
              </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

  <dependencies>        
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>4.6.b.23201</version>
      <type>pom</type>
    </dependency>
    <dependency>
      <groupId>com.adobe.flex.compiler</groupId>
      <artifactId>asdoc</artifactId>
      <version>4.6.b.23201</version>
    </dependency>
    <dependency>
      <groupId>com.adobe.flex</groupId>
      <artifactId>compiler</artifactId>
      <version>4.6.b.23201</version>
      <type>pom</type>
    </dependency>
    <dependency>
      <groupId>com.adobe.flex.compiler</groupId>
      <artifactId>flex-compiler-oem</artifactId>
      <version>3.6.0.16995</version>
    </dependency>
    <dependency>
      <groupId>com.adobe.flexunit</groupId>
      <artifactId>flexunit</artifactId>
      <version>0.85</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.adobe.flex.compiler</groupId>
      <artifactId>mxmlc</artifactId>
      <version>4.1.0.16076</version>
    </dependency>
      <!--<dependency>-->
          <!--<groupId>com.adobe.flex.framework</groupId>-->
          <!--<artifactId>playerglobal</artifactId>-->
          <!--<version>10-3.3.0.4852</version>-->
          <!--<classifier>10.2</classifier>-->
          <!--<type>swc</type>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>com.adobe.flex.framework</groupId>-->
          <!--<artifactId>playerglobal</artifactId>-->
          <!--<version>4.5.1.21328</version>-->
          <!--<classifier>10</classifier>-->
          <!--<type>2.swc</type>-->
      <!--</dependency>-->
      <dependency>
          <groupId>com.adobe.flex.framework</groupId>
          <artifactId>playerglobal</artifactId>
          <version>3.2.0.3958</version>
          <classifier>9</classifier>
          <type>swc</type>
      </dependency>
  </dependencies>
</project>

我尝试过的东西:
1. 我添加了所需的 artifact playerglobal 依赖项,如上面 pom.xml 文件所示,我尝试了它的 3 个不同版本(在上面的 pom 中看到)。但是,none 有帮助。
2. 我尝试在 'plugin' 节点内添加 playerglobal 依赖项,并在 pom.xml 中分别在公共 'dependencies' 节点内添加依赖项。然而,他们中的任何一个都没有帮助。 [尝试这两种方法的原因是,对于 flex-compiler-oem 和 mxmlc 的其他几个依赖项,当仅在公共 'dependencies' 节点中添加依赖项时,它无法识别所需的 类。当我将它们添加到 'plugin dependencies' 中时,它会从这些错误中继续。]
3. 根据 this 文章,我还尝试将 'com.adobe.flex > compiler' 保持在 'configuration' 节点之后。但是,这也无济于事。
4. 我现在正在使用 Maven 3.2.5,但我也尝试过其他各种 Maven 版本,如 3.3.9、3.0.5、3.1.1。他们也没有帮助。 (根据 this 文章,flexmojos-maven-plugin 7.1.0 不支持 3.3.9。它还说 maven 3.2.5 工作正常。使用 maven 3.0.5 表示最低要求的 maven 版本是3.1.1. 使用 maven 3.1.1 给出的错误与我现在使用 maven 3.2.5 时得到的错误相同。)

我的 SDK/IDE 版本:
Maven:3.2.5
弹性:3.2.0
JDK: 1.8
IntelliJ IDEA:旗舰版 2017.1

如有任何帮助,我们将不胜感激。提前致谢。

我不知道您对在 Maven 世界中使用 Flex 的熟悉程度,但是有很多关于在 post-Flash 世界中使用 Flex 的讨论(我没有'现在大约需要 5-6 年的时间才能处理建立和维护基于 Flex Maven 的项目)。基本上,Adobe 不想将他们的工件发布到 Maven Central,他们曾经有自己的存储库。然后 Adob​​e 放弃了他们的 Flex 项目并将其贡献给 Apache(如果我没记错的话,不是全部,而是大部分)。 Apache 的人在很大程度上重新设计了一些东西,并且现在是开发它的人。

老实说,这些年来我没有跟进过 Flex,因为我认为没有必要再使用它了,与 HTML5 一样,Flex 似乎是一种过时的技术。世界不再使用 Flash,这给每个人带来了很多好处。但是,这只是我的意见,我不是 UI 专家。

Apache 的人员决定不重置版本并继续 Adob​​e 离开的地方——只是更改了工件坐标。 groupId-s 现在是 org.apache.flex*(您可以检查发布的 Apache Flex 依赖项 here),而不是 com.apache.*。这些工件现在可以通过 Maven Central 获得。您应该切换到较新版本的 Maven 并至少使用 3.3.9.

有关项目历史的更多信息(这实际上非常重要,如果您想更好地了解依赖混乱以及现在的真相点和不是真相点,请检查here and here). The Flex documentation is now on the Apache site. This page 可能是我能找到的最新和最详细的,尽管我不是 100% 确定它是最新的。

您将不得不做一些进一步的阅读和调查,但根据您上面的示例,您似乎使用的是非常非常旧版本的 Flex 库。我建议使用 Maven Central's search engine 并搜索每个 artifactId-s 并将它们替换为最新的,然后看看结果如何...

祝你好运! :)

我现在已经解决了上面的问题。我遇到了一些 link 谈论 mavenizing Flex SDK,例如 this and this。第二个 link 是 carlspring 在他上面的回答中建议的那个;但是,我无法完全按照其步骤操作,因为其中提到的 git URL 在我公司的网络中被阻止了。于是我下载了之前link的代码,创建了mavenizer,按照link中给出的步骤执行,生成了mavenized SDK。 (我在 mavenizer 中遇到了一个问题,连接到外部 maven 存储库以检查更新,所以我评论了该代码并在之后成功创建了 mavenized SDK。)

生成Mavenized SDK后,只需将其复制到本地maven仓库,然后playerglobal/airglobal依赖项就会成功解析。

注意:除了上面提到的第一个link,还可以参考thislink,里面有更详细的Flex SDK mavenizing步骤。它对我正确创建文件夹结构有很大帮助。