MetadataFacet meta = project.getFacet(MetadataFacet.class);
meta.setProjectName(name);
meta.setTopLevelPackage(javaPackage);
PackagingFacet packaging = project.getFacet(PackagingFacet.class);
packaging.setPackagingType(type);
DependencyFacet deps = project.getFacet(DependencyFacet.class);
deps.addRepository(KnownRepository.JBOSS_NEXUS);
if (packaging.getPackagingType().equals(PackagingType.JAR) && createMain)
{
project.getFacet(JavaSourceFacet.class).saveJavaSource(JavaParser
.create(JavaClass.class)
.setPackage(javaPackage)
.setName("Main")
.addMethod("public static void main(String[] args) {}")
.setBody("System.out.println(\"Hi there! I was forged as part of the project you call " + name
+ ".\");")
.getOrigin());
}
if (project.hasFacet(JavaSourceFacet.class))
{
DirectoryResource sourceFolder = project.getFacet(JavaSourceFacet.class).getSourceFolder();
createTopLevelPackage(sourceFolder, javaPackage);
}
if (finalName != null)
{
packaging.setFinalName(finalName);
}
else
{
packaging.setFinalName(name);
}
if (project.hasFacet(ResourceFacet.class))
{
project.getFacet(ResourceFacet.class).createResource("<forge/>".toCharArray(), "META-INF/forge.xml");