tag:support.gradlefx.org,2011-05-23:/discussions/questions/3523-best-way-to-build-swf-and-swcair-artifacts-for-a-single-projectGradleFx: Discussion 2018-10-19T04:56:01Ztag:support.gradlefx.org,2011-05-23:Comment/362191862015-03-06T22:14:37Z2015-03-06T22:14:37ZBest way to build .swf AND .swcAir artifacts for a single project?<div><p>I'm investigating migrating a complex multi-module Flash/Air
build from Ant to Gradle. One the things I'm trying to figure out
how to build two artifacts from the same project: a .swf, targeting
Flash on the desktop, and a .swcAir, targeting Air on mobile. Is
there a way I can build both artifacts from the same project in one
invocation?</p>
<p>I'm currently working around this using ConfigSlurper +
environments and passing a property on the command line to build
the project for either Flash or Air (tailoring the buildDir, type
and additionalCompilerOptions). This works fine for build CI
purposes (it just has to be built twice using a different
environment property), but doesn't help when we want to generate
IDEA project files, as they only support what environment is active
when invoked.</p>
<p>Any suggestions on the feasibility to either:<br>
* Build two artifacts for one project in a single invocation (e.g.:
'gradle :project:compile' produces .swc and .swcAir)? * Generate
IDEA project files that support building both the Flash and AIR
variants of a project's artifacts?</p>
<p>Looking at this from a different perspective, I suppose we could
have a peer project for building the other variant (e.g.: project
FooBar and FooBarAir) but point the sources for the *Air project to
its non-Air peer's src directory. This would potentially "pollute"
the directory tree with pairs, but could preserve the 1:1
relationship between project and artifact, and allow IDEA project
file creation to support both types. If this sounds like the most
feasible way, any ideas on some clever Groovy script to configure a
set of projects in one blurb (vs. spelling out each one)?</p>
<p>Thanks for your advice!</p></div>wenslayertag:support.gradlefx.org,2011-05-23:Comment/362191862015-03-17T19:28:54Z2015-03-17T19:28:54ZBest way to build .swf AND .swcAir artifacts for a single project?<div><p>When having to build multiple artifacts, I generally recommend
to to use multiple projects, one for each artifact. Each of these
use a library which contains the shared code. These projects are
sub-projects of one root project, which only has a build file with
common build logic in it.<br>
This keeps everything nicely separated, allows you to build
multiple artifacts with one single call and should allow you to
generate IDEA project files for each project.</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/362191862015-03-23T21:29:45Z2015-03-23T21:29:45ZBest way to build .swf AND .swcAir artifacts for a single project?<div><p>Thanks Yennick, I decided to pursue an approach with a 1:1
project:artifact mapping, and abandon the use of an environment to
determine the artifact to build. It is working much better.</p></div>wenslayer