我正在将我们的 flex 应用程序迁移到使用 gradle 构建。到目前为止,一切进展顺利,除了单元测试。
根build.gradle
description='Parent project for flex applications'
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath group: 'org.gradlefx', name: 'gradlefx', version: '0.6'
}
}
allprojects {
group='com.mycompany.flex'
version='0.0.1-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
}
}
subprojects {
apply plugin: 'gradlefx'
dependencies {
flexSDK group: 'org.apache', name: 'apache-flex-sdk', version: '4.1.0A', ext: 'zip'
//unit test libraries
test group: 'org.hamcrest', name: 'hamcrest-as3-flex', version: '1.1.3', ext: 'swc'
test group: 'org.flexunit', name: 'flexunit-tasks', version: '4.1.0-8', ext: 'jar'
test group: 'org.flexunit', name: 'flexunit-flex', version: '4.1.0-8', ext: 'swc'
test group: 'org.flexunit', name: 'flexunit-cilistener', version: '4.1.0-8', ext: 'swc'
}
flexUnit {
command="C:/Windows/System32/Macromed/Flash/flashplayer_11_sa_debug.exe"
}
}
有问题的项目build.gradle
description='module_MyModule'
type = 'swf'
dependencies {
rsl project(':library_common')
external group: 'flexlib', name: 'flexlib', version: '2.5', ext: 'swc'
merged group: 'com.esri.ags', name: 'agslib', version: '2.5-2011-11-30', ext: 'swc'
merged group: 'org.robotlegs', name: 'robotlegs-framework', version: '1.5.2', ext: 'swc'
merged group: 'org.alivepdf', name: 'alivepdf', version: '0.1.5RCfeb2010', ext: 'swc'
}
编译没有问题,gradle test
结果如下:
:module_MyModule:test
[ant:flexunit] Compiling test classes: [com.mycompany.MyModelTest]
[ant:null] Loading configuration file C:\Users\PGreen\.gradle\gradleFx\sdks\56bb8970d35ada5a72c3596118157aa694a7e83e\frameworks\flex-config.xml
:module_MyModule:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':module_MyModule:test'.
> Compilation failed:
C:\development\flexworkspaces\gradle\module_MyModule\src\main\actionscript\com\mycompany\MyModel.as(11): col: 22 Error: The definition of base class BaseModel was not found.
public class MyModel extends BaseModel
^
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 14.006 secs
基类BaseModel
在项目 ':library_common' 中定义。如果我将配置从 更改rsl
为merged
,一切正常。所以这个问题似乎与 Flash 播放器在运行时尝试加载它时不知道在哪里寻找 ':library_common' 有关。我该如何指定?在我的搜索中,我发现使用 flexmojos 插件的 maven 存在类似问题,但总体上没有解决方案。