IntelliJ IDEA迁移Flex到Maven编译报错:缺失playerglobal/airglobal
解决FlexMojos编译时"Global artifact is not available"的问题
这个错误我之前帮同事排查过,核心原因就是FlexMojos编译SWF时**必须依赖playerglobal(Flash Player环境)或者airglobal(Adobe AIR环境)**作为全局编译依赖,哪怕你已经加了其他Flex相关依赖,这个是绕不开的。下面给你一步步解决的办法:
1. 添加playerglobal/airglobal依赖到pom.xml
首先在你的<dependencies>节点里加入对应依赖,版本要和你项目使用的Flex SDK完全匹配:
如果是普通Flash Player项目:
<dependency> <groupId>com.adobe.flex.framework</groupId> <artifactId>playerglobal</artifactId> <version>4.16.1</version> <!-- 替换成你的Flex SDK版本 --> <classifier>swc</classifier> <type>swc</type> <scope>provided</scope> </dependency>
如果是Adobe AIR项目,替换成airglobal:
<dependency> <groupId>com.adobe.air.framework</groupId> <artifactId>airglobal</artifactId> <version>33.1.1.540</version> <!-- 替换成你的AIR版本 --> <classifier>swc</classifier> <type>swc</type> <scope>provided</scope> </dependency>
2. 配置FlexMojos插件的版本匹配
确保flexmojos插件的配置里指定了和依赖对应的Player/AIR版本,同时绑定正确的Flex SDK:
<plugin> <groupId>net.flexmojos.oss</groupId> <artifactId>flexmojos-maven-plugin</artifactId> <version>7.1.0</version> <extensions>true</extensions> <configuration> <!-- Flash Player版本,要和playerglobal兼容 --> <playerVersion>32.0</playerVersion> <!-- AIR项目请启用下面这行 --> <!-- <airVersion>33.1.1.540</airVersion> --> <sourceDirectory>src/main/flex</sourceDirectory> <!-- 其他编译配置按需添加 --> </configuration> <dependencies> <!-- 显式指定Flex SDK依赖,避免版本冲突 --> <dependency> <groupId>com.adobe.flex</groupId> <artifactId>flex-sdk</artifactId> <version>4.16.1</version> <!-- 和playerglobal版本一致 --> <type>pom</type> </dependency> </dependencies> </plugin>
3. 确保Maven能拉到这些依赖
如果你的本地仓库没有这些包,需要在pom.xml里添加Adobe的官方仓库:
<repositories> <repository> <id>adobe-public-releases</id> <name>Adobe Public Releases</name> <url>https://repo.adobe.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
最后,执行mvn clean compile重新编译,应该就能解决这个"Global artifact is not available"的错误了。
内容的提问来源于stack exchange,提问作者Vaibhav Shah
相关产品推荐
相关产品推荐

