FILE_DOT_WTPMODULES)), "UTF-8");
} catch (IOException ex) {
throw new MojoExecutionException(Messages.getString("EclipsePlugin.erroropeningfile"), ex); //$NON-NLS-1$
}
XMLWriter writer = new PrettyPrintXMLWriter(w, "UTF-8", null);
writer.startElement(ELT_PROJECT_MODULES);
writer.addAttribute(ATTR_MODULE_ID, "moduleCoreId"); //$NON-NLS-1$
writer.startElement(ELT_WB_MODULE);
// we should use the configured eclipse project name.
writer.addAttribute(ATTR_DEPLOY_NAME, this.config.getEclipseProjectName());
writer.startElement(ELT_MODULE_TYPE);
writeModuleTypeAccordingToPackaging(config.getProject(), writer, config.getBuildOutputDirectory());
writer.endElement(); // module-type
// source and resource paths.
// deploy-path is "/" for utility and ejb projects, "/WEB-INF/classes" for webapps
String target = "/"; //$NON-NLS-1$
if (Constants.PROJECT_PACKAGING_WAR.equals(config.getPackaging())) //$NON-NLS-1$
{
String warSourceDirectory =
IdeUtils.getPluginSetting(config.getProject(), JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN,
"warSourceDirectory", //$NON-NLS-1$
config.getProject().getBasedir() + "/src/main/webapp"); //$NON-NLS-1$
writer.startElement(ELT_WB_RESOURCE);
writer.addAttribute(ATTR_DEPLOY_PATH, "/"); //$NON-NLS-1$
writer.addAttribute(ATTR_SOURCE_PATH, "/" //$NON-NLS-1$
+ IdeUtils.toRelativeAndFixSeparator(config.getEclipseProjectDirectory(),
new File(warSourceDirectory),
false));
writer.endElement();
writeWarOrEarResources(writer, config.getProject(), config.getLocalRepository());
target = "/WEB-INF/classes"; //$NON-NLS-1$
} else if (Constants.PROJECT_PACKAGING_EAR.equals(config.getPackaging())) //$NON-NLS-1$
{
writer.startElement(ELT_WB_RESOURCE);
writer.addAttribute(ATTR_DEPLOY_PATH, "/"); //$NON-NLS-1$
writer.addAttribute(ATTR_SOURCE_PATH, "/"); //$NON-NLS-1$
writer.endElement();
writeWarOrEarResources(writer, config.getProject(), config.getLocalRepository());
}
for (int j = 0; j < config.getSourceDirs().length; j++) {
EclipseSourceDir dir = config.getSourceDirs()[j];
// test src/resources are not added to wtpmodules
if (!dir.isTest()) {
// <wb-resource deploy-path="/" source-path="/src/java" />
writer.startElement(ELT_WB_RESOURCE);
writer.addAttribute(ATTR_DEPLOY_PATH, target);
writer.addAttribute(ATTR_SOURCE_PATH, dir.getPath());
writer.endElement();
}
}
writer.endElement(); // wb-module
writer.endElement(); // project-modules
IOUtil.close(w);
}