changeset 122:3a5d1c6148ed

Generate multi-module maven/m2e plugin Generate a multi-module maven project and add a maven nature so it works under m2e. Generate pom files and bundle activators with correct groupId, artifactId, version and package names.
author Omair Majid <omajid@redhat.com>
date Tue, 25 Mar 2014 12:25:58 -0400
parents 4c549b4c6fb3
children a0c68ec37305
files com.redhat.thermostat.tools.eclipse.plugin/META-INF/MANIFEST.MF com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ProjectCreator.java com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPage.java com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPageTwo.java
diffstat 5 files changed, 490 insertions(+), 293 deletions(-) [+]
line wrap: on
line diff
--- a/com.redhat.thermostat.tools.eclipse.plugin/META-INF/MANIFEST.MF	Tue Mar 25 12:25:44 2014 -0400
+++ b/com.redhat.thermostat.tools.eclipse.plugin/META-INF/MANIFEST.MF	Tue Mar 25 12:25:58 2014 -0400
@@ -21,7 +21,9 @@
  org.eclipse.core.databinding.observable,
  org.eclipse.core.databinding.property,
  org.eclipse.jface.databinding,
- com.ibm.icu
+ com.ibm.icu,
+ org.eclipse.m2e.core;bundle-version="1.4.0",
+ org.eclipse.m2e.core.ui;bundle-version="1.4.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-ActivationPolicy: lazy
 Export-Package: com.redhat.thermostat.tools.eclipse.plugin;x-friends:="com.redhat.thermostat.tools.eclipse.plugin.tests",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ProjectCreator.java	Tue Mar 25 12:25:58 2014 -0400
@@ -0,0 +1,397 @@
+package com.redhat.thermostat.tools.eclipse.plugin.wizards;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerService;
+
+import com.redhat.thermostat.tools.eclipse.plugin.Activator;
+import com.redhat.thermostat.tools.eclipse.plugin.wizards.PluginXmlCreator.Decisions;
+
+/** Creates a Thermostat project using the preferred thermostat defaults, settings, and style */
+public class ProjectCreator {
+
+    private static final String POM_FILE_NAME = "pom.xml";
+    private static final String POM_HEADER = ""
+            + "<?xml version='1.0' encoding='UTF-8'?>\n"
+            + "<project xsi:schemaLocation='http://maven.apache.org/POM/4.0.0\n"
+            + "                             http://maven.apache.org/xsd/maven-4.0.0.xsd'\n"
+            + "         xmlns='http://maven.apache.org/POM/4.0.0'\n"
+            + "         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\n"
+            + "\n"
+            + "  <modelVersion>4.0.0</modelVersion>\n"
+            + "\n";
+    private static final String POM_FOOTER = ""
+            + "</project>\n";
+
+    private static final String OSGI_DEPENDENCIES = ""
+            + "    <dependency>\n"
+            + "      <groupId>org.osgi</groupId>\n"
+            + "      <artifactId>org.osgi.core</artifactId>\n"
+            + "    </dependency>\n"
+            + "    <dependency>\n"
+            + "      <groupId>org.osgi</groupId>\n"
+            + "      <artifactId>org.osgi.compendium</artifactId>\n"
+            + "    </dependency>\n";
+
+    private static final String BUNDLE_ACTIVATOR_NAME = "Activator";
+    private static final String BUNDLE_ACTIVATOR = ""
+            + "package ${package.name};\n" // ${package.name} is replaced with actual package name
+            + "\n"
+            + "import org.osgi.framework.BundleActivator;\n"
+            + "import org.osgi.framework.BundleContext;\n"
+            + "\n"
+            + "public class " + BUNDLE_ACTIVATOR_NAME + " implements BundleActivator {\n"
+            + "\n"
+            + "    public void start(BundleContext context) throws Exception {\n"
+            + "        // TODO Auto-generated method stub\n"
+            + "    }\n"
+            + "\n"
+            + "    public void stop(BundleContext context) throws Exception {\n"
+            + "        // TODO Auto-generated method stub\n"
+            + "    }\n"
+            + "\n"
+            + "}\n";
+
+    private IHandlerService serviceHandler;
+
+    private String packagePrefix;
+    private String groupId;
+    private String artifactId;
+    private String version;
+    private String thermostatVersion;
+
+    private String parentId;
+
+    public ProjectCreator(String groupId, String artifactId, String version, String packagePrefix, String thermostatVersion) {
+        this((IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class), groupId, artifactId, version, packagePrefix, thermostatVersion);
+    }
+
+    public ProjectCreator(IHandlerService handler, String groupId, String artifactId, String version, String packagePrefix, String thermostatVersion) {
+        this.serviceHandler = handler;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.version = version;
+        this.packagePrefix = packagePrefix;
+
+        this.thermostatVersion = thermostatVersion;
+
+        this.parentId = artifactId + "-parent";
+
+    }
+
+    public void create() throws CoreException, IOException {
+        createParentModuleProject();
+
+        createCommonSubproject();
+
+        createJavaSubproject("agent");
+        createJavaSubproject("client");
+        createJavaSubproject("cli");
+
+        createDistributionProject();
+
+        refreshProjects();
+    }
+
+    private void createParentModuleProject() throws CoreException, IOException {
+        Projects projects = createJavaProject(parentId);
+
+        String pomContents = ""
+                + POM_HEADER
+                + "  <groupId>" + groupId + "</groupId>\n"
+                + "  <artifactId>" + parentId + "</artifactId>\n"
+                + "  <version>" + version + "</version>\n"
+                + "  <packaging>pom</packaging>\n"
+                + "\n"
+                + "  <modules>\n"
+                + "    <module>" + this.artifactId + "-agent</module>\n"
+                + "    <module>" + this.artifactId + "-common</module>\n"
+                + "    <module>" + this.artifactId + "-client</module>\n"
+                + "    <module>" + this.artifactId + "-cli</module>\n"
+                + "    <module>" + this.artifactId + "-distribution</module>\n"
+                + "  </modules>\n"
+                + "\n"
+                + "  <dependencyManagement>\n"
+                + "    <dependencies>\n"
+                + "      <dependency>\n"
+                + "        <groupId>org.osgi</groupId>\n"
+                + "        <artifactId>org.osgi.core</artifactId>\n"
+                + "        <version>4.3.1</version>\n"
+                + "      </dependency>\n"
+                + "      <dependency>\n"
+                + "        <groupId>org.osgi</groupId>\n"
+                + "        <artifactId>org.osgi.compendium</artifactId>\n"
+                + "        <version>4.3.1</version>\n"
+                + "      </dependency>\n"
+                + "    </dependencies>\n"
+                + "  </dependencyManagement>\n"
+                + POM_FOOTER;
+
+        createPomFile(projects, pomContents);
+    }
+
+    private void createCommonSubproject() throws IOException, CoreException {
+        String suffix = "common";
+        String artifactId = this.artifactId + "-" + suffix;
+        String packageName = packagePrefix + "." + suffix;
+        Projects projects = createJavaCodeProject(artifactId, packageName);
+
+        String pomContents = ""
+                + POM_HEADER
+                + "\n"
+                + "  <parent>\n"
+                + "    <groupId>" + groupId + "</groupId>\n"
+                + "    <artifactId>" + parentId + "</artifactId>\n"
+                + "    <version>" + version + "</version>\n"
+                + "  </parent>\n"
+                + "\n"
+                + "  <artifactId>" + artifactId + "</artifactId>\n"
+                + "  <packaging>jar</packaging>\n"
+                + "\n"
+                + "  <dependencies>\n"
+                + OSGI_DEPENDENCIES
+                + "  </dependencies>\n"
+                + POM_FOOTER;
+
+        createPomFile(projects, pomContents);
+
+    }
+
+    private void createJavaSubproject(String subproject) throws CoreException, IOException {
+        String artifactId = this.artifactId + "-" + subproject;
+        String subpackage = this.packagePrefix + "." + subproject;
+
+        Projects projects = createJavaCodeProject(artifactId, subpackage);
+
+        String pomContents = ""
+                + POM_HEADER
+                + "  <parent>\n"
+                + "    <groupId>" + groupId + "</groupId>\n"
+                + "    <artifactId>" + parentId + "</artifactId>\n"
+                + "    <version>" + version + "</version>\n"
+                + "  </parent>\n"
+                + "\n"
+                + "  <artifactId>" + artifactId + "</artifactId>\n"
+                + "  <packaging>jar</packaging>\n"
+                + "\n"
+                + "  <dependencies>\n"
+                + "    <dependency>\n"
+                + "      <groupId>" + groupId + "</groupId>\n"
+                + "      <artifactId>" + this.artifactId + "-common</artifactId>\n"
+                + "      <version>" + version + "</version>\n"
+                + "    </dependency>\n"
+                + OSGI_DEPENDENCIES
+                + "  </dependencies>\n"
+                + POM_FOOTER;
+
+        createPomFile(projects, pomContents);
+    }
+
+    private Projects createJavaCodeProject(String projectName, String packageName) throws CoreException {
+        Projects projects = createJavaProject(projectName);
+
+        IProject project = projects.project;
+
+        IFolder srcFolder = project.getFolder("src");
+        srcFolder.create(false, true, null);
+
+        IFolder srcMainFolder = srcFolder.getFolder("main");
+        srcMainFolder.create(true, true, null);
+
+        IFolder srcMainJavaFolder = srcMainFolder.getFolder("java");
+        srcMainJavaFolder.create(true, true, null);
+
+        IFolder srcTestFolder = srcFolder.getFolder("test");
+        srcTestFolder.create(true, true, null);
+
+        IFolder srcTestJavaFolder = srcTestFolder.getFolder("java");
+        srcTestJavaFolder.create(true, true, null);
+
+        createBundleActivator(projects, srcMainJavaFolder, packageName);
+
+        return projects;
+    }
+
+    private void createBundleActivator(Projects projects, IFolder root, String packageName) throws CoreException {
+        IJavaProject javaProject = projects.javaProject;
+
+        IPackageFragment pack = javaProject.getPackageFragmentRoot(root)
+                                    .createPackageFragment(packageName, false, null);
+
+        String bundleActivatorContents = BUNDLE_ACTIVATOR.replace("${package.name}", pack.getElementName());
+        pack.createCompilationUnit(BUNDLE_ACTIVATOR_NAME + ".java", bundleActivatorContents, false, null);
+    }
+
+    private void createDistributionProject() throws CoreException, IOException {
+        String artifactId = this.artifactId + "-distribution";
+
+        Projects projects = createJavaProject(artifactId);
+
+        String pomContents = ""
+                + POM_HEADER
+                + "  <parent>\n"
+                + "    <groupId>" + groupId + "</groupId>\n"
+                + "    <artifactId>" + parentId + "</artifactId>\n"
+                + "    <version>" + version + "</version>\n"
+                + "  </parent>\n"
+                + "\n"
+                + "  <artifactId>" + artifactId + "</artifactId>\n"
+                + "  <packaging>jar</packaging>\n"
+                + "\n"
+                + "  <!-- Explicitly list all plug-in artifacts, transitive dependencies\n"
+                + "       are not included in assembly. -->\n"
+                + "  <dependencies>\n"
+                + "    <dependency>\n"
+                + "      <groupId>" + groupId + "</groupId>\n"
+                + "      <artifactId>" + this.artifactId + "-agent</artifactId>\n"
+                + "      <version>${project.version}</version>\n"
+                + "    </dependency>\n"
+                + "    <dependency>\n"
+                + "      <groupId>" + groupId + "</groupId>\n"
+                + "      <artifactId>" + this.artifactId + "-common</artifactId>\n"
+                + "      <version>${project.version}</version>\n"
+                + "    </dependency>\n"
+                + "    <dependency>\n"
+                + "      <groupId>" + groupId + "</groupId>\n"
+                + "      <artifactId>" + this.artifactId + "-client</artifactId>\n"
+                + "      <version>${project.version}</version>\n"
+                + "    </dependency>\n"
+                + "    <dependency>\n"
+                + "      <groupId>" + groupId + "</groupId>\n"
+                + "      <artifactId>" + this.artifactId + "-cli</artifactId>\n"
+                + "      <version>${project.version}</version>\n"
+                + "    </dependency>\n"
+                + "  </dependencies>\n"
+                + POM_FOOTER;
+
+        createPomFile(projects, pomContents);
+
+        IProject project = projects.project;
+
+        IFolder srcFolder = project.getFolder("src");
+        srcFolder.create(false, true, null);
+
+        IFolder srcMainFolder = srcFolder.getFolder("main");
+        srcMainFolder.create(true, true, null);
+
+        IFolder srcMainResourcesFolder = srcMainFolder.getFolder("resources");
+        srcMainResourcesFolder.create(true, true, null);
+
+        // FIXME enable this
+        // createAssemblyDescriptor();
+        createThermostatPluginXml(project.getName());
+
+    }
+
+    private void createThermostatPluginXml(String projectName) throws CoreException, IOException {
+        PluginXmlCreator creator = new PluginXmlCreator(ResourcesPlugin.getWorkspace().getRoot());
+        creator.create(projectName, new NullProgressMonitor(), new Decisions() {
+            @Override
+            public boolean overwriteExistingFile() {
+                return true;
+            }
+        });
+    }
+
+    private Projects createJavaProject(String projectName) throws CoreException {
+        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+        IProject project = root.getProject(projectName);
+        if (project.exists()) {
+            project.delete(true, null);
+        }
+        try {
+            project.create(null);
+            project.open(null);
+        } catch (CoreException e) {
+            e.printStackTrace();
+        }
+
+        addJavaAndMavenNature(project);
+
+        // Create Java project
+        IJavaProject javaProject = JavaCore.create(project);
+
+        return new Projects(project, javaProject);
+    }
+
+    private void addJavaAndMavenNature(IProject project) throws CoreException {
+        IProjectDescription description = project.getDescription();
+        addJavaAndMavenNature(description);
+        project.setDescription(description, null);
+    }
+
+    private void addJavaAndMavenNature(IProjectDescription description) {
+        String[] existingNatureIds = description.getNatureIds();
+        Set<String> natures = new TreeSet<>(Arrays.asList(existingNatureIds));
+        natures.add(JavaCore.NATURE_ID);
+        // provided by m2e
+        // TODO what's the symbolic constant for this? IMavenConstants.NATURE_ID?
+        natures.add("org.eclipse.m2e.core.maven2Nature");
+        String[] newNatureIds = natures.toArray(new String[natures.size()]);
+        description.setNatureIds(newNatureIds);
+    }
+
+    private void createPomFile(Projects projects, String contents) throws IOException, CoreException {
+        IProject project = projects.project;
+        IFile pomFile = project.getFile(POM_FILE_NAME);
+        try (InputStream contentStream = new ByteArrayInputStream(contents.getBytes(StandardCharsets.UTF_8))) {
+            if (pomFile.exists()) {
+                pomFile.setContents(contentStream, true, true, null);
+            } else {
+                pomFile.create(contentStream, true, null);
+            }
+        }
+    }
+
+    private void refreshProjects() throws CoreException {
+        // Refresh projects
+        ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IWorkspaceRoot.DEPTH_INFINITE, new NullProgressMonitor());
+
+        // Refresh again, just to make sure changes are sane by the time maven sees them
+        ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IWorkspaceRoot.DEPTH_INFINITE, new NullProgressMonitor());
+
+        // Refresh maven things
+        try {
+            // provided by m2e
+            final String UPADATE_MAVEN_PROJECT_COMMAND = "org.eclipse.m2e.core.ui.command.updateProject";
+            serviceHandler.executeCommand(UPADATE_MAVEN_PROJECT_COMMAND, null);
+        } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) {
+            Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error refreshing maven configuration", e);
+            throw new CoreException(s);
+        }
+    }
+
+    private static class Projects {
+        private final IProject project;
+        private final IJavaProject javaProject;
+
+        public Projects(IProject project, IJavaProject javaProject) {
+            this.project = project;
+            this.javaProject = javaProject;
+        }
+    }
+}
--- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java	Tue Mar 25 12:25:44 2014 -0400
+++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java	Tue Mar 25 12:25:58 2014 -0400
@@ -1,35 +1,19 @@
 package com.redhat.thermostat.tools.eclipse.plugin.wizards;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map.Entry;
+import java.io.IOException;
 
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jdt.launching.LibraryLocation;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 
+import com.redhat.thermostat.tools.eclipse.plugin.Activator;
+
 public class ThermostatProjectCreationWizard extends Wizard implements INewWizard {
 
     private ThermostatProjectCreationWizardPage pageOne;
-    private ThermostatProjectCreationWizardPageTwo pageTwo;
-    private HashMap<String, Boolean> selectedComponents;
 
     @Override
     public void init(IWorkbench workbench, IStructuredSelection selection) {
@@ -41,117 +25,33 @@
     public void addPages() {
         pageOne = new ThermostatProjectCreationWizardPage();
         addPage(pageOne);
-
-        pageTwo = new ThermostatProjectCreationWizardPageTwo();
-        addPage(pageTwo);
     }
 
     @Override
     public boolean performFinish() {
         try {
-            selectedComponents = pageOne.getSelectedComponents();
+            String groupId = pageOne.getGroupId();
+            String artifactId = pageOne.getArtifactId();
+            String version = pageOne.getVersion();
 
-            createProject(pageOne.getProjectName());
-            for (Entry<String, Boolean> temp : selectedComponents.entrySet()) {
-                if (temp.getValue()) {
-                    createProject(pageOne.getProjectName() + "-" + temp.getKey());
-                }
-            }
-        } catch (CoreException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return true;
-    }
+            String packagePrefix = pageOne.getPackagePrefix();
+            String thermostatVersion = pageOne.getThermostatVersion();
 
-    private void createProject(String projectTitle) throws CoreException {
-        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
-        IProject project = root.getProject(projectTitle);
-        if (project.exists()) {
-            project.delete(true, null);
-        }
-        try {
-            project.create(null);
-            project.open(null);
+            createProject(groupId, artifactId, version, packagePrefix, thermostatVersion);
         } catch (CoreException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
-        // Set the Java nature to created project
-        IProjectDescription description = project.getDescription();
-        description.setNatureIds(new String[] { JavaCore.NATURE_ID });
-        project.setDescription(description, null);
 
-        // Create Java project
-        IJavaProject javaProject = JavaCore.create(project);
-
-        // Add bin/ouput folder
-        IFolder binFolder = project.getFolder("bin");
-        binFolder.create(false, true, null);
-        javaProject.setOutputLocation(binFolder.getFullPath(), null);
-
-        // Add libs to project class path
-        List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
-        IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
-        LibraryLocation[] locations = JavaRuntime
-                .getLibraryLocations(vmInstall);
-        for (LibraryLocation element : locations) {
-            entries.add(JavaCore.newLibraryEntry(
-                    element.getSystemLibraryPath(), null, null));
-        }
-
-        javaProject.setRawClasspath(
-                entries.toArray(new IClasspathEntry[entries.size()]), null);
-
-        // If root then folder create sub directories corresponding components
-        if (pageOne.getProjectName().equals(projectTitle)) {
-            for (Entry<String, Boolean> currentComponent : selectedComponents
-                    .entrySet()) {
-                if (currentComponent.getValue()) {
-                    IFolder componentFolder = project.getFolder(currentComponent
-                            .getKey());
-                    componentFolder.create(false, true, null);
-                }
-            }
-        }
-
-        // Create src folder
-        IFolder srcFolder = project.getFolder("src");
-        srcFolder.create(false, true, null);
-
-        IFolder srcMainFolder = srcFolder.getFolder("main");
-        srcMainFolder.create(true, true, null);
-
-        IFolder srcMainJavaFolder = srcMainFolder.getFolder("java");
-        srcMainJavaFolder.create(true, true, null);
-
-        IPackageFragmentRoot packageFragmentRoot = javaProject
-                .getPackageFragmentRoot(srcMainJavaFolder);
-        IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
-        IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
-        System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
-        newEntries[oldEntries.length] = JavaCore
-                .newSourceEntry(packageFragmentRoot.getPath());
-        javaProject.setRawClasspath(newEntries, null);
-
-        IPackageFragment pack = javaProject.getPackageFragmentRoot(
-                srcMainJavaFolder).createPackageFragment(pageTwo.getPackageName(),
-                false, null);
-
-        StringBuffer buffer = new StringBuffer();
-        buffer.append("package " + pack.getElementName() + ";\n");
-        buffer.append("\n");
-        // Empty file for testing
-        ICompilationUnit cu = pack.createCompilationUnit(
-                "ThermostatPlugin.java", buffer.toString(), false, null);
-
-        createThermostatPluginXml(projectTitle);
+        return true;
     }
 
-    private void createThermostatPluginXml(String projectName) {
-        if (pageOne.getProjectName().equals(projectName)) {
-            GuiPluginXmlCreator creator = new GuiPluginXmlCreator();
-            creator.createPluginWithFeedback(projectName, this);
+    private void createProject(String groupId, String artifactId, String version, String packagePrefix, String thermostatVersion) throws CoreException {
+        ProjectCreator creator = new ProjectCreator(groupId, artifactId, version, packagePrefix, thermostatVersion);
+        try {
+            creator.create();
+        } catch (IOException e) {
+            throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Error creating project", e));
         }
     }
 
--- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPage.java	Tue Mar 25 12:25:44 2014 -0400
+++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPage.java	Tue Mar 25 12:25:58 2014 -0400
@@ -1,27 +1,22 @@
 package com.redhat.thermostat.tools.eclipse.plugin.wizards;
 
-import java.util.HashMap;
-
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
 public class ThermostatProjectCreationWizardPage extends WizardPage {
-    private Text projectText;
 
-    private boolean agentSelected = false;
-    private boolean clientSelected = false;
-    private boolean commonSelected = false;
-    private boolean distributionSelected = false;
+    private Text groupIdText;
+    private Text artifactIdText;
+    private Text versionText;
+
+    private Text packageNameText;
+
+    private Text thermostatVersionText;
 
     public ThermostatProjectCreationWizardPage() {
         super("wizardPage");
@@ -29,95 +24,49 @@
         setDescription("This wizard creates a new Thermostat Plugin.");
     }
 
+    @Override
     public void createControl(Composite parent) {
         Composite container = new Composite(parent, SWT.NULL);
-        GridLayout layout = new GridLayout();
+        GridLayout layout = new GridLayout(2, false);
         container.setLayout(layout);
-        
-        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-        Label projectNameLabel = new Label(container, SWT.NULL);
-        projectNameLabel.setText("&Project name:");
-        
-        projectText = new Text(container, SWT.BORDER | SWT.SINGLE);
-        gd = new GridData(GridData.FILL_HORIZONTAL);
-        projectText.setLayoutData(gd);
-        projectText.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
-                dialogChanged();
-            }
-        });
-        
-        Label componentLabel = new Label(container, SWT.NULL);
-        componentLabel.setText("&Select components you would like to include in the project: ");
-        
-        Button agentButton = new Button(container, SWT.CHECK);
-        agentButton.setText("Agent");
-        agentButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e){
-                Button button = (Button) e.widget;
-                if (button.getSelection()) {
-                    agentSelected = true;
-                } else {
-                    agentSelected = false;
-                }
-            }
-        });
-        
-        Button clientButton = new Button(container, SWT.CHECK);
-        clientButton.setText("Client");
-        clientButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e){
-                Button button = (Button) e.widget;
-                if (button.getSelection()) {
-                    clientSelected = true;
-                } else {
-                    clientSelected = false;
-                }
-            }
-        });
-        
-        Button commonButton = new Button(container, SWT.CHECK);
-        commonButton.setText("Common");
-        commonButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e){
-                Button button = (Button) e.widget;
-                if (button.getSelection()) {
-                    commonSelected = true;
-                } else {
-                    commonSelected = false;
-                }
-            }
-        });
-        
-        Button distributionButton = new Button(container, SWT.CHECK);
-        distributionButton.setText("Distribution");
-        distributionButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e){
-                Button button = (Button) e.widget;
-                if (button.getSelection()) {
-                    distributionSelected = true;
-                } else {
-                    distributionSelected = false;
-                }
-            }
-        });
-        
-        initialize();
-        dialogChanged();
+
+        Label groupIdLabel = new Label(container, SWT.NULL);
+        groupIdLabel.setText("&Group Id:");
+
+        groupIdText = new Text(container, SWT.BORDER | SWT.SINGLE);
+        groupIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        Label artifactIdLabel = new Label(container, SWT.NULL);
+        artifactIdLabel.setText("&Artifact Id:");
+
+        artifactIdText = new Text(container, SWT.BORDER | SWT.SINGLE);
+        artifactIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        Label versionLabel = new Label(container, SWT.NULL);
+        versionLabel.setText("&Version:");
+
+        versionText = new Text(container, SWT.BORDER | SWT.SINGLE);
+        versionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        Label packageNameLabel = new Label(container, SWT.NULL);
+        packageNameLabel.setText("&Package Prefix:");
+
+        packageNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
+        packageNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        Label thermostatVersionLabel = new Label(container, SWT.NULL);
+        thermostatVersionLabel.setText("&Thermostat Version:");
+
+        thermostatVersionText = new Text(container, SWT.BORDER | SWT.SINGLE);
+        thermostatVersionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        checkProjectName();
 
         setControl(container);
     }
 
-    private void initialize() {
-        projectText.setText("Thermostat-Plugin-Project");
-    }
-
-    private void dialogChanged() {
-        String projectName = getProjectName();
+    private void checkProjectName() {
+        String projectName = artifactIdText.getText();
         if (projectName.length() == 0) {
             updateStatus("Project name must be specified");
             return;
@@ -133,23 +82,43 @@
         updateStatus(null);
     }
 
+    private void dialogChanged() {
+        String packageName = packageNameText.getText();
+        if (packageName.length() == 0) {
+            updateStatus("Package name must be specified");
+            return;
+        }
+        if (packageName.contains(" ")) {
+            updateStatus("Package name must be valid");
+            return;
+        }
+        updateStatus(null);
+    }
+
     private void updateStatus(String message) {
         setErrorMessage(message);
         setPageComplete(message == null);
     }
 
-    public String getProjectName() {
-        return projectText.getText();
+    public String getGroupId() {
+        return groupIdText.getText();
+    }
+
+    public String getArtifactId() {
+        return artifactIdText.getText();
     }
 
-    public HashMap<String, Boolean> getSelectedComponents() {
-        HashMap<String, Boolean> selectedComponentBoxes = new HashMap<String, Boolean>();
+    public String getVersion() {
+        return versionText.getText();
+    }
+
+    public String getPackagePrefix() {
+        return packageNameText.getText();
         
-        selectedComponentBoxes.put("agent", agentSelected);
-        selectedComponentBoxes.put("client", clientSelected);
-        selectedComponentBoxes.put("common", commonSelected);
-        selectedComponentBoxes.put("distribution", distributionSelected);
-        
-        return selectedComponentBoxes;
     }
+
+    public String getThermostatVersion() {
+        return thermostatVersionText.getText();
+    }
+
 }
--- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPageTwo.java	Tue Mar 25 12:25:44 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-package com.redhat.thermostat.tools.eclipse.plugin.wizards;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class ThermostatProjectCreationWizardPageTwo extends WizardPage {
-    private Text packageText;
-
-    public ThermostatProjectCreationWizardPageTwo() {
-        super("wizardPage");
-        setTitle("Thermostat Wizard");
-        setDescription("This wizard creates a new Thermostat Plugin.");
-    }
-
-    public void createControl(Composite parent) {
-        Composite container = new Composite(parent, SWT.NULL);
-        GridLayout layout = new GridLayout();
-        container.setLayout(layout);
-        
-        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-        Label packageNameLabel = new Label(container, SWT.NULL);
-        packageNameLabel.setText("&Package name:");
-        
-        packageText = new Text(container, SWT.BORDER | SWT.SINGLE);
-        gd = new GridData(GridData.FILL_HORIZONTAL);
-        packageText.setLayoutData(gd);
-        packageText.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
-                dialogChanged();
-            }
-        });
-        
-        initialize();
-        dialogChanged(); 
-
-        setControl(container);
-    }
-
-    private void initialize() {
-        packageText.setText("com.redhat.thermostat.plugin");
-    }
-
-    private void dialogChanged() {
-        String packageName = getPackageName();
-        if (packageName.length() == 0) {
-            updateStatus("Package name must be specified");
-            return;
-        }
-        if (packageName.contains(" ")) {
-            updateStatus("Package name must be valid");
-            return;
-        }
-        updateStatus(null);
-    }
-
-    private void updateStatus(String message) {
-        setErrorMessage(message);
-        setPageComplete(message == null);
-    }
-
-    public String getPackageName() {
-        return packageText.getText();
-    }
-}