* @return jar file
* @throws Exception the exception
*/
private File createJar(File pomFile, String classesDir, String buildDir, Model model)
throws Exception {
JarMojo jarMojo = new JarMojo();
String artifactId = model.getArtifactId();
// ----------------------------------------------------------------------
// Create pom.properties file
// ----------------------------------------------------------------------
Properties p = new Properties();
p.setProperty("groupId", model.getGroupId());
p.setProperty("artifactId", model.getArtifactId());
p.setProperty("version", model.getVersion());
File pomPropertiesDir =
new File(new File(classesDir), "META-INF/maven/" + model.getGroupId() + "/" + model.getArtifactId());
pomPropertiesDir.mkdirs();
File pomPropertiesFile = new File(pomPropertiesDir, "pom.properties");
OutputStream os = new FileOutputStream(pomPropertiesFile);
p.store(os, "Generated by Maven");
os.close(); // stream is flushed but not closed by Properties.store()
FileUtils.copyFile(pomFile, new File(pomPropertiesDir, "pom.xml"));
File jarFile = new File(buildDir, artifactId + ".jar");
jarMojo.execute(new File(classesDir), jarFile);
return jarFile;
}