How to compile maven/flex project without any *.mxml file?
Is there any way how to compile maven/flex project which does not contain any *.mxml? The flex project contains ActionScript classes only (i.e. "src/flex" directory contains *.as files only). My pom.xml is here:
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT开发者_Python百科</version>
<name>test</name>
<packaging>swf</packaging>
<build>
<sourceDirectory>src/main/flex</sourceDirectory>
<testSourceDirectory>src/test/flex</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.8</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>4.5.0.18623</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>4.5.0.18623</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.adobe.flexunit</groupId>
<artifactId>flexunit</artifactId>
<version>0.85</version>
<type>swc</type>
<scope>test</scope>
</dependency>
</dependencies>
"mvn package -e" throws this error:
[ERROR] Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:3.8:compile-swf (default-compile-swf) on project test: Source file not expecified and no default found! -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:3.8:compile-swf (default-compile-swf) on project q-integra-scorecard-ldservice: Source file not expecified and no default found!
Try to add this inside <plugin>, where "Main.as" is your class:
<configuration>
<sourceFile>Main.as</sourceFile>
</configuration>
In my case, I didn't have any primary source files (it was a SWC full of interface classes like ISessionProxy.as).
So I had to do two things to get this working:
1) reference my source directory (under the build tag):
<build>
<sourceDirectory>src/main/flex</sourceDirectory>
2) follow the advice I found on this mail group and the FlexMojos Google Group:
"...just remove all dependencies on your pom, because those dependencies are already defined on super pom."
So, I deleted all my dependencies and added them back, one by one until I got it to compile. All I needed was:
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>${flex.sdk.version}</version>
<type>pom</type>
</dependency>
I even deleted all the dependencies for the FlexMojos plugin:
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>${flexmojos.version}</version>
<configuration>
<targetPlayer>${flash.player.version}</targetPlayer>
</configuration>
</plugin>
This worked for me, producing the SWC I need and I hope it helps someone else, too!
精彩评论