}
protected File rearrangeEar(EnterpriseArchive ear) {
final File root = getTempRoot();
final Node appXml = ear.get(ParseUtils.APPLICATION_XML);
if (appXml != null) {
InputStream stream = appXml.getAsset().openStream();
try {
ApplicationDescriptor ad = Descriptors.importAs(ApplicationDescriptor.class).fromStream(stream);
List<JavaArchive> libs = new ArrayList<JavaArchive>();
String libDir = ad.getLibraryDirectory();
if (libDir != null) {
libDir = "lib"; // default?
}
Node lib = ear.get(libDir);
if (lib != null) {
// defensive copy
final Set<Node> children = new HashSet<Node>(lib.getChildren());
for (Node child : children) {
if (child.getPath().get().endsWith(".jar")) {
JavaArchive jar = ear.getAsType(JavaArchive.class, child.getPath());
libs.add(jar);
}