I am migrating our flex applications to being build with gradle. So far, things have been going well, except unit testing.
root 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"
}
}
problematic project 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'
}
Compiling works with no problem, gradle test
results in the following output:
: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
The base class BaseModel
is defined in project ':library_common'. If I change the configuration from rsl
to merged
, everything works fine. So the problem seems to be related to the flash player not knowing where to look for ':library_common' when it tries to load it at runtime. How do I specify this? In my search I have found similar problems with maven using the flexmojos plugin, but overall no solutions.