2

I'm currently trying to do some much needed cleanup in one of our projects and as part of that I am splitting up a blob SWC into multiple smaller ones. So far so good.

The problem now is that due to legacy purposes I still need a single aggregate SWC that includes all the sources now split among the specialized SWCs. Is this possible without actually compiling the sources again? Is it possible to merge two or more SWCs into one single SWC?

In the long run dependencies to this single SWC will be replaced by dependencies to only the new SWCs that are actually needed. But in the transition phase I do need to support both cases. :/


UPDATE:

We manage our projects using Maven and so I have been looking to find a solution that works with the flexmojos maven plugin used. As noted by Brian compc can be used to merge multiple SWCs but there doesn't seem to be any exact equivalent that can be used in the pom.

Flexmojos docs note that the <scope> flag can be used when specifying dependencies with the same effect. But, this results in compile errors as it tries to merge all referenced recursively (and I only want to merge the specified libraries, not the ones they in turn depend on). So, that doesn't work.

Another possible solution I explored was the <include-libraries> configuration option, as can be seen in the ...-config.xml file that is generated together with the final SWC. Using the following syntax:

  <include-libraries>
     <library>string</library>
  </include-libraries>

However, this doesn't seem to be supported at all. :/

So, in the end all I can think of is using Ant script or something to manually call compc directly, something I'd really like to avoid if possible. :/

  • As I recall we need something similar when compiling flex applications for instrumentation (UI Tests). Here we define a normal dependency and set the scope to internal (https://docs.sonatype.org/display/FLEXMOJOS/Adding+libraries+to+compilation) – Christofer Dutz Sep 23 '14 at 08:16

2 Answers2

1

Yes, this is possible. From https://code.google.com/p/apparat/issues/detail?id=51 there's an example. It's as simple as doing the following

   compc -compiler.include-libraries=special1.swc,special2.swc -o aggregate.swc
Brian
  • 3,850
  • 3
  • 21
  • 37
1

Ok so if you have a library with this dependency:

<dependency>
    <groupId>my.lib.gid</groupId>
    <artifactId>my.lib.gid</artifactId>
    <version>1.2.3</version>
    <type>swc</type>
    <scope>internal</scope>
</dependency>

The "internal" scope should result in what you are looking for. I am pretty sure the feature already existed in Flexmojos 4.2 (Even if it is really, really old)

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34
  • Thanks for the reply, but as noted in the update section (paragraph 2) this will not work as the internal scope tries to recursively include libraries the swc files I'm trying to merge in turn relies on. :/ – Teodor Jakobsson Sep 24 '14 at 09:04
  • Well I just had a look in the sources, actually scope=internal is actually the thing you are looking for as "getIncludeLibraries" in AbstractFlexCompilerMojo exactly selects the "internal" dependencies. But I have to admit that I can't quite confirm the including of transitive dependencies. Will have a look though. Perhaps adding a Test to the testsuite will help. – Christofer Dutz Sep 24 '14 at 18:14