MXMLFlexJSPublisher contains the following code that is run when no output
path is specified in the compiler options:

//begin code
String mainClassFolder = configuration.getTargetFileDirectory();
if (mainClassFolder.endsWith("src"))
    outputParentFolder = new
File(configuration.getTargetFileDirectory()).getParentFile();
else if (mainClassFolder.endsWith("src/main/flex") ||
mainClassFolder.endsWith("src\\main\\flex"))
    outputParentFolder = new
File(configuration.getTargetFileDirectory()).getParentFile().getParentFile().getParentFile();
else
    outputParentFolder = new File(configuration.getTargetFileDirectory());
//end code

In plain English:

1. If the main class is in a src directory, bin will be created in the
parent directory of src.

2. If the main class is in a src/main/flex directory (in other words, if
it's a Maven project), bin will be created in ../../..

3. Otherwise, bin will be created in the same directory as the main class.

I often use "source" rather than "src", so I was getting source/bin as my
output directory, which was unexpected.

Rather than hardcoding a couple of special paths, maybe we should create
bin relative to the current working directory instead. I think that's a
common behavior for command line tools.

With this change, both of these commands should continue to work exactly
the same way:

mxmlc src/Main.mxml
mxmlc src/main/flex/Main.mxml

I assume that Maven sets the CWD to the correct location before it runs the
compiler too.

This would also allow other build tools with different project structures
to work without modifying the compiler.

Thoughts?

- Josh

Reply via email to