There was a similar requirement in my project. I need to include swf file which is an output of flex project into java project and build the war.
1. I created a two sub project under war project, flex and java.
2. Included them in settings file.
3. The main build.gradle file has basic configuration.
4. In flex sub project gradlefx plugin is applied and the output swf file is copied to the directory using a copy task.
5. In java sub project war plugin is applied and the source directory is mentioned from which war has to be generated.
Here is an example code for your reference:
settings.xml:
include myproject,
myproject:mysubproject:flex,
myproject:mysubproject:java
build.gradle file in myproject dir:
buildscript {
dependencies {
classpath project (":FlexProject") //include all the flex project from which the swf file to be included
}
}
dependencies {
classpath project (":JavaProject") //include all the dependent java project if any
}
sourceSets {
main {
output.classesDir = 'root/WEB-INF/classes' //This is the directory from which I am going to generate war.
}
}
build.gradle file in myproject/mysubproject/flex dir:
apply plugin: 'gradlefx'
type = 'swf'
dependencies{
merged project (":FlexProject")
}
String rootProjectDir = rootDir
rootProjectDir = rootProjectDir.replaceAll("\\\\","/")
task copyTask <<{
copy{
from rootProjectDir +'/MyFlexProject1/build'
into rootProjectDir +'/myproject/root'
include '**/*.swf'
}
}
build.finalizedBy(copyTask)
build.gradle file in myproject/mysubproject/java dir:
String rootProjectDir = rootDir
rootProjectDir = rootProjectDir.replaceAll("\\\\","/")
String rootProjectDirDocRoot = rootProjectDir + '/myproject/root'
dependencies {
compile project (":JavaProject") //to include dependent jars in war
}
group = "com.abc.enterprise"
archivesBaseName = "myprojet"
description = "myproject"
apply plugin: 'war'
war{
from rootProjectDirDocRoot
exclude('.gradle')
exclude('.settings')
}
This will compile the flex project every time and he swf file will in be included into the directory from which the war has to be built. Hope this helps.