コード例 #1
0
  public void updatePom() throws IOException, XmlPullParserException {
    File mavenProjectPomLocation = project.getFile("pom.xml").getLocation().toFile();
    MavenProject mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    version = mavenProject.getVersion();

    // Skip changing the pom file if group ID and artifact ID are matched
    if (MavenUtils.checkOldPluginEntry(
        mavenProject, "org.wso2.maven", "wso2-esb-template-plugin")) {
      return;
    }

    Plugin plugin =
        MavenUtils.createPluginEntry(
            mavenProject,
            "org.wso2.maven",
            "wso2-esb-template-plugin",
            MavenConstants.WSO2_ESB_TEMPLATE_VERSION,
            true);
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.addGoal("pom-gen");
    pluginExecution.setPhase("process-resources");
    pluginExecution.setId("template");

    Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode();
    Xpp3Dom artifactLocationNode = MavenUtils.createXpp3Node(configurationNode, "artifactLocation");
    artifactLocationNode.setValue(".");
    Xpp3Dom typeListNode = MavenUtils.createXpp3Node(configurationNode, "typeList");
    typeListNode.setValue("${artifact.types}");
    pluginExecution.setConfiguration(configurationNode);
    plugin.addExecution(pluginExecution);
    MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
  }
コード例 #2
0
  public void updatePom() throws Exception {
    File mavenProjectPomLocation = project.getFile("pom.xml").getLocation().toFile();
    MavenProject mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);

    boolean pluginExists =
        MavenUtils.checkOldPluginEntry(
            mavenProject,
            "org.wso2.maven",
            "wso2-esb-template-plugin",
            MavenConstants.WSO2_ESB_TEMPLATE_VERSION);
    if (pluginExists) {
      return;
    }

    Plugin plugin =
        MavenUtils.createPluginEntry(
            mavenProject,
            "org.wso2.maven",
            "wso2-esb-template-plugin",
            MavenConstants.WSO2_ESB_TEMPLATE_VERSION,
            true);

    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.addGoal("pom-gen");
    pluginExecution.setPhase("process-resources");
    pluginExecution.setId("template");

    Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode();
    Xpp3Dom artifactLocationNode = MavenUtils.createXpp3Node(configurationNode, "artifactLocation");
    artifactLocationNode.setValue(".");
    Xpp3Dom typeListNode = MavenUtils.createXpp3Node(configurationNode, "typeList");
    typeListNode.setValue("${artifact.types}");
    pluginExecution.setConfiguration(configurationNode);

    plugin.addExecution(pluginExecution);
    Repository repo = new Repository();
    repo.setUrl("http://maven.wso2.org/nexus/content/groups/wso2-public/");
    repo.setId("wso2-nexus");

    RepositoryPolicy releasePolicy = new RepositoryPolicy();
    releasePolicy.setEnabled(true);
    releasePolicy.setUpdatePolicy("daily");
    releasePolicy.setChecksumPolicy("ignore");

    repo.setReleases(releasePolicy);

    if (!mavenProject.getRepositories().contains(repo)) {
      mavenProject.getModel().addRepository(repo);
      mavenProject.getModel().addPluginRepository(repo);
    }

    MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
  }
コード例 #3
0
  public static void setCollectionValues(
      Xpp3Dom parent, String nodeName, String childName, Collection<String> values) {
    Xpp3Dom node = parent.getChild(nodeName);

    if (node != null) {
      for (int i = 0; i < parent.getChildCount(); i++) {
        Xpp3Dom existing = parent.getChild(i);

        if (StringUtils.equals(nodeName, existing.getName())) {
          parent.removeChild(i);

          break;
        }
      }

      node = null;
    }

    node = new Xpp3Dom(nodeName);

    parent.addChild(node);

    for (String childVal : values) {
      Xpp3Dom childNode = new Xpp3Dom(childName);
      node.addChild(childNode);
      childNode.setValue(childVal);
    }
  }
コード例 #4
0
 @Override
 public org.apache.maven.plugin.MojoExecution newMojoExecution() {
   MojoExecution execution = super.newMojoExecution();
   Xpp3Dom compilerId = new Xpp3Dom("compilerId");
   compilerId.setValue("jdt");
   execution.getConfiguration().addChild(compilerId);
   return execution;
 };
コード例 #5
0
ファイル: CARPOMGenMojo.java プロジェクト: ww102111/tools
 protected void addPlugins(MavenProject artifactMavenProject, Artifact artifact) {
   Plugin plugin =
       MavenUtils.createPluginEntry(
           artifactMavenProject, "org.wso2.maven", "maven-car-plugin", "1.0-SNAPSHOT", true);
   Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
   // add configuration
   Xpp3Dom aritfact = MavenUtils.createConfigurationNode(configuration, "archiveLocation");
   aritfact.setValue(archiveLocation);
 }
コード例 #6
0
  protected void addPlugins(MavenProject artifactMavenProject, Artifact artifact) {
    Plugin pluginAxis2 =
        CAppMavenUtils.createPluginEntry(
            artifactMavenProject,
            "org.wso2.maven",
            "maven-bpel-plugin",
            WSO2MavenPluginConstantants.MAVEN_BPEL_PLUGIN_VERSION,
            true);
    PluginExecution executionAxis2 = new PluginExecution();
    executionAxis2.setId("package-bpel");
    executionAxis2.setPhase("package");
    List goalsAxis2 = new ArrayList<String>();
    goalsAxis2.add("package-bpel");
    executionAxis2.setGoals(goalsAxis2);
    pluginAxis2.addExecution(executionAxis2);

    Xpp3Dom config = (Xpp3Dom) pluginAxis2.getConfiguration();
    Xpp3Dom artifactItems = CAppMavenUtils.createConfigurationNode(config, "artifact");
    //		String relativePath =
    //		                      org.wso2.carbonstudio.eclipse.utils.file.FileUtils.getRelativePath(new
    // File(
    //
    //      artifact.getFile()
    //
    //              .getParentFile()
    //
    //              .getParentFile()
    //
    //              .getParentFile()
    //
    //              .getParentFile()
    //
    //              .getParentFile()
    //
    //              .getPath() +
    //
    //              File.separator +
    //
    //              "target" +
    //
    //              File.separator +
    //
    //              "capp" +
    //
    //              File.separator +
    //
    //              "artifacts" +
    //
    //              File.separator +
    //
    //              artifactMavenProject.getArtifactId()),
    //
    // artifact.getFile());
    String relativePath = artifact.getFile().getName();
    artifactItems.setValue(relativePath);
  }
コード例 #7
0
 protected void addPlugins(MavenProject artifactMavenProject, Artifact artifact) {
   Plugin plugin =
       CAppMavenUtils.createPluginEntry(
           artifactMavenProject,
           "org.wso2.maven",
           "wso2-esb-messagestore-plugin",
           WSO2MavenPluginConstantants.WSO2_ESB_MESSAGE_STORE_PLUGIN_VERSION,
           true);
   Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
   // add configuration
   Xpp3Dom aritfact = CAppMavenUtils.createConfigurationNode(configuration, "artifact");
   aritfact.setValue(artifact.getFile().getName());
 }
コード例 #8
0
 protected void addPlugins(MavenProject artifactMavenProject, Artifact artifact) {
   Plugin plugin =
       CAppMavenUtils.createPluginEntry(
           artifactMavenProject,
           "org.wso2.maven",
           "maven-proxy-plugin",
           WSO2MavenPluginConstantants.MAVEN_PROXY_PLUGIN_VERSION,
           true);
   Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
   // add configuration
   Xpp3Dom aritfact = CAppMavenUtils.createConfigurationNode(configuration, "artifact");
   aritfact.setValue(artifact.getFile().getName());
 }
コード例 #9
0
ファイル: MojoExecutor.java プロジェクト: jhyle/qulice
 /**
  * Recuresively convert Properties to Xpp3Dom.
  *
  * @param config The config to convert
  * @param name High-level name of it
  * @return The Xpp3Dom document
  * @see #execute(String,String,Properties)
  * @checkstyle ExecutableStatementCountCheck (100 lines)
  */
 @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
 private Xpp3Dom toXppDom(final Properties config, final String name) {
   final Xpp3Dom xpp = new Xpp3Dom(name);
   for (final Map.Entry<?, ?> entry : config.entrySet()) {
     if (entry.getValue() instanceof String) {
       final Xpp3Dom child = new Xpp3Dom(entry.getKey().toString());
       child.setValue(config.getProperty(entry.getKey().toString()));
       xpp.addChild(child);
     } else if (entry.getValue() instanceof String[]) {
       final Xpp3Dom child = new Xpp3Dom(entry.getKey().toString());
       for (final String val : String[].class.cast(entry.getValue())) {
         final Xpp3Dom row = new Xpp3Dom(entry.getKey().toString());
         row.setValue(val);
         child.addChild(row);
       }
       xpp.addChild(child);
     } else if (entry.getValue() instanceof Collection) {
       final Xpp3Dom child = new Xpp3Dom(entry.getKey().toString());
       for (final Object val : Collection.class.cast(entry.getValue())) {
         final Xpp3Dom row = new Xpp3Dom(entry.getKey().toString());
         if (val != null) {
           row.setValue(val.toString());
           child.addChild(row);
         }
       }
       xpp.addChild(child);
     } else if (entry.getValue() instanceof Properties) {
       xpp.addChild(
           this.toXppDom(Properties.class.cast(entry.getValue()), entry.getKey().toString()));
     } else {
       throw new IllegalArgumentException(
           String.format("Invalid properties value at '%s'", entry.getKey().toString()));
     }
   }
   return xpp;
 }
コード例 #10
0
ファイル: MojoExecutor.java プロジェクト: jhyle/qulice
 /**
  * Recursively convert PLEXUS config to Xpp3Dom.
  *
  * @param config The config to convert
  * @return The Xpp3Dom document
  * @see #execute(String,String,Properties)
  */
 private Xpp3Dom toXppDom(final PlexusConfiguration config) {
   final Xpp3Dom result = new Xpp3Dom(config.getName());
   result.setValue(config.getValue(null));
   for (final String name : config.getAttributeNames()) {
     try {
       result.setAttribute(name, config.getAttribute(name));
     } catch (final PlexusConfigurationException ex) {
       throw new IllegalArgumentException(ex);
     }
   }
   for (final PlexusConfiguration child : config.getChildren()) {
     result.addChild(this.toXppDom(child));
   }
   return result;
 }
コード例 #11
0
    private Xpp3Dom toDom(Map<Object, Object> map) {
      Xpp3Dom dom = new Xpp3Dom("configuration");

      for (Map.Entry<Object, Object> entry : map.entrySet()) {
        if (entry.getValue() instanceof Xpp3Dom) {
          Xpp3Dom child = new Xpp3Dom((Xpp3Dom) entry.getValue(), entry.getKey().toString());
          dom.addChild(child);
        } else {
          Xpp3Dom child = new Xpp3Dom(entry.getKey().toString());
          child.setValue(entry.getValue().toString());
          dom.addChild(child);
        }
      }

      return dom;
    }
コード例 #12
0
  public static void setNodeValue(Xpp3Dom parent, String name, String value) {
    // if we do not have a current value, then just return without setting the node;
    if (value == null) {
      return;
    }

    Xpp3Dom node = parent.getChild(name);

    if (node == null) {
      node = new Xpp3Dom(name);

      parent.addChild(node);
    }

    node.setValue(value);
  }
  /**
   * If enabled, grab the execution root pom (which will be the topmost POM in terms of directory
   * structure). Check for the presence of the project-sources-maven-plugin in the base build
   * (/project/build/plugins/). Inject a new plugin execution for creating project sources if this
   * plugin has not already been declared in the base build section.
   */
  @Override
  public Set<Project> applyChanges(final List<Project> projects, final ManipulationSession session)
      throws ManipulationException {
    final ProjectSourcesInjectingState state = session.getState(ProjectSourcesInjectingState.class);

    // This manipulator will only run if its enabled *and* at least one other manipulator is
    // enabled.
    if (state.isEnabled() && session.anyStateEnabled(State.activeByDefault)) {
      for (final Project project : projects) {
        if (project.isExecutionRoot()) {
          logger.info("Examining {} to apply sources/metadata plugins.", project);

          final Model model = project.getModel();
          Build build = model.getBuild();
          if (build == null) {
            build = new Build();
            model.setBuild(build);
          }

          boolean changed = false;
          final Map<String, Plugin> pluginMap = build.getPluginsAsMap();
          if (state.isProjectSourcesPluginEnabled()
              && !pluginMap.containsKey(PROJECT_SOURCES_COORD)) {
            final PluginExecution execution = new PluginExecution();
            execution.setId(PROJECT_SOURCES_EXEC_ID);
            execution.setPhase(INITIALIZE_PHASE);
            execution.setGoals(Collections.singletonList(PROJECT_SOURCES_GOAL));

            final Plugin plugin = new Plugin();
            plugin.setGroupId(PROJECT_SOURCES_GID);
            plugin.setArtifactId(PROJECT_SOURCES_AID);
            plugin.setVersion(state.getProjectSourcesPluginVersion());
            plugin.addExecution(execution);

            build.addPlugin(plugin);

            changed = true;
          }

          if (state.isBuildMetadataPluginEnabled() && !pluginMap.containsKey(BMMP_COORD)) {
            final PluginExecution execution = new PluginExecution();
            execution.setId(BMMP_EXEC_ID);
            execution.setPhase(VALIDATE_PHASE);
            execution.setGoals(Collections.singletonList(BMMP_GOAL));

            final Xpp3Dom xml = new Xpp3Dom("configuration");

            final Map<String, Object> config = new HashMap<>();
            config.put("createPropertiesReport", true);
            config.put("hideCommandLineInfo", false);
            config.put("hideJavaOptsInfo", false);
            config.put("activateOutputFileMapping", true);
            config.put("addJavaRuntimeInfo", true);

            // Default name is build.properties but we currently prefer build.metadata.
            config.put("propertiesOutputFile", "build.metadata");
            // Deactivate features we don't want.
            config.put("createXmlReport", false);
            config.put("addLocallyModifiedTagToFullVersion", false);
            config.put("addToGeneratedSources", false);
            config.put("validateCheckout", false);
            config.put("forceNewProperties", true);
            config.put("addBuildDateToFullVersion", false);
            config.put("addHostInfo", false);
            config.put("addBuildDateInfo", false);
            config.put("addOsInfo", false);
            config.put("addMavenExecutionInfo", false);
            config.put("addToFilters", false);

            final Xpp3Dom additionalLocations = new Xpp3Dom("addToLocations");
            final Xpp3Dom additionalLocation = new Xpp3Dom("addToLocation");

            xml.addChild(additionalLocations);
            additionalLocations.addChild(additionalLocation);
            additionalLocation.setValue("${session.executionRootDirectory}");

            for (final Map.Entry<String, Object> entry : config.entrySet()) {
              final Xpp3Dom child = new Xpp3Dom(entry.getKey());
              if (entry.getValue() != null) {
                child.setValue(entry.getValue().toString());
              }

              xml.addChild(child);
            }

            execution.setConfiguration(xml);

            final Plugin plugin = new Plugin();
            plugin.setGroupId(BMMP_GID);
            plugin.setArtifactId(BMMP_AID);
            plugin.setVersion(state.getBuildMetadataPluginVersion());
            plugin.addExecution(execution);

            build.addPlugin(plugin);

            changed = true;
          }

          if (changed) {
            return Collections.singleton(project);
          }
        }
      }
    }

    return Collections.emptySet();
  }
コード例 #14
0
  public boolean performFinish() {
    try {
      project = createNewProject();
      sourceFolder = ProjectUtils.getWorkspaceFolder(project, "src", "main", "java");
      javaProject = JavaCore.create(project);
      root = javaProject.getPackageFragmentRoot(sourceFolder);
      JavaUtils.addJavaSupportAndSourceFolder(project, sourceFolder);
      addDependancies(project);

      String className = filterModel.getFilterClass();
      String packageName = filterModel.getFilterClassPackage();

      IPackageFragment sourcePackage = root.createPackageFragment(packageName, false, null);

      ICompilationUnit cu =
          sourcePackage.createCompilationUnit(
              className + ".java", getFilterClassSource(packageName, className), false, null);
      project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

      File pomfile = project.getFile("pom.xml").getLocation().toFile();
      getModel().getMavenInfo().setPackageName("bundle");
      if (!pomfile.exists()) {
        createPOM(pomfile);
      }

      MavenProject mavenProject = MavenUtils.getMavenProject(pomfile);

      mavenProject.getModel().getProperties().put("CApp.type", "lib/registry/filter");

      Plugin plugin =
          MavenUtils.createPluginEntry(
              mavenProject, "org.apache.felix", "maven-bundle-plugin", "2.3.4", true);

      Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode(plugin);
      Xpp3Dom instructionNode = MavenUtils.createXpp3Node(configurationNode, "instructions");
      Xpp3Dom symbolicNameNode = MavenUtils.createXpp3Node(instructionNode, "Bundle-SymbolicName");
      symbolicNameNode.setValue(mavenProject.getArtifactId());
      Xpp3Dom bundleNameNode = MavenUtils.createXpp3Node(instructionNode, "Bundle-Name");
      bundleNameNode.setValue(mavenProject.getArtifactId());
      Xpp3Dom exportPackageNode = MavenUtils.createXpp3Node(instructionNode, "Export-Package");
      exportPackageNode.setValue(packageName);
      Xpp3Dom dynamicImportNode =
          MavenUtils.createXpp3Node(instructionNode, "DynamicImport-Package");
      dynamicImportNode.setValue("*");

      Repository repo = new Repository();
      repo.setUrl("http://maven.wso2.org/nexus/content/groups/wso2-public/");
      repo.setId("wso2-maven2-repository-1");

      mavenProject.getModel().addRepository(repo);
      mavenProject.getModel().addPluginRepository(repo);

      List<Dependency> dependencyList = new ArrayList<Dependency>();

      Map<String, JavaLibraryBean> dependencyInfoMap =
          JavaLibraryUtil.getDependencyInfoMap(project);
      Map<String, String> map = ProjectDependencyConstants.DEPENDENCY_MAP;
      for (JavaLibraryBean bean : dependencyInfoMap.values()) {
        if (bean.getVersion().contains("${")) {
          for (String path : map.keySet()) {
            bean.setVersion(bean.getVersion().replace(path, map.get(path)));
          }
        }
        Dependency dependency = new Dependency();
        dependency.setArtifactId(bean.getArtifactId());
        dependency.setGroupId(bean.getGroupId());
        dependency.setVersion(bean.getVersion());
        dependencyList.add(dependency);
      }
      MavenUtils.addMavenDependency(mavenProject, dependencyList);
      MavenUtils.saveMavenProject(mavenProject, pomfile);
      ProjectUtils.addNatureToProject(project, false, Constants.REGISTRY_FILTER_PROJECT_NATURE);
      MavenUtils.updateWithMavenEclipsePlugin(
          pomfile,
          new String[] {JDT_BUILD_COMMAND},
          new String[] {Constants.REGISTRY_FILTER_PROJECT_NATURE, JDT_PROJECT_NATURE});
      project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

      try {
        refreshDistProjects();
        IEditorPart javaEditor = JavaUI.openInEditor(cu);
        JavaUI.revealInEditor(javaEditor, (IJavaElement) cu);
      } catch (Exception e) {
        /* ignore */
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    return true;
  }
コード例 #15
0
ファイル: YangProjectWizard.java プロジェクト: cyqw/yang-ide
 /**
  * Creates single configuration parameter.
  *
  * @param name name
  * @param value value
  * @return config parameter
  */
 private Xpp3Dom createSingleParameter(String name, String value) {
   Xpp3Dom parameter = new Xpp3Dom(name);
   parameter.setValue(value);
   return parameter;
 }
コード例 #16
0
ファイル: Dom4jVerifier.java プロジェクト: dennisl/modello
  public void verifyWriter() throws IOException, DocumentException {
    String expectedXml = FileUtils.fileRead(getTestFile("src/test/verifiers/dom4j/expected.xml"));
    expectedXml = expectedXml.replaceAll("(\r\n)|(\r)", "\n");

    // ----------------------------------------------------------------------
    // Build the model thats going to be written.
    // ----------------------------------------------------------------------

    Model expected = new Model();

    expected.setExtend("/foo/bar");

    expected.setName("Maven");

    expected.setModelVersion("4.0.0");

    MailingList mailingList = new MailingList();

    mailingList.setName("Mailing list");

    mailingList.setSubscribe("Super Subscribe");

    mailingList.setUnsubscribe("Duper Unsubscribe");

    mailingList.setArchive("?ber Archive");

    expected.addMailingList(mailingList);

    Scm scm = new Scm();

    String connection = "connection";

    String developerConnection = "developerConnection";

    String url = "url";

    scm.setConnection(connection);

    scm.setDeveloperConnection(developerConnection);

    scm.setUrl(url);

    expected.setScm(scm);

    Build build = new Build();

    build.setSourceDirectory("src/main/java");

    build.setUnitTestSourceDirectory("src/test/java");

    SourceModification sourceModification = new SourceModification();

    sourceModification.setClassName("excludeEclipsePlugin");

    sourceModification.setDirectory("foo");

    sourceModification.addExclude("de/abstrakt/tools/codegeneration/eclipse/*.java");

    build.addSourceModification(sourceModification);

    expected.setBuild(build);

    Component component = new Component();

    component.setName("component1");

    expected.addComponent(component);

    component = new Component();

    component.setName("component2");

    component.setComment("comment2");

    expected.addComponent(component);

    Component c2 = new Component();

    c2.setName("sub");

    c2.setComment("subcomment");

    component.getComponents().add(c2);

    component = new Component();

    component.setName("component3");

    Xpp3Dom xpp3Dom = new Xpp3Dom("custom");
    Xpp3Dom child = new Xpp3Dom("foo");
    child.setValue("bar");
    xpp3Dom.addChild(child);
    child = new Xpp3Dom("bar");
    child.setAttribute("att1", "value");
    child.setValue("baz");
    xpp3Dom.addChild(child);
    child = new Xpp3Dom("el1");
    xpp3Dom.addChild(child);
    Xpp3Dom el1 = child;
    child = new Xpp3Dom("el2");
    child.setValue("text");
    el1.addChild(child);

    component.setCustom(xpp3Dom);

    expected.addComponent(component);

    component = new Component();
    component.setName("component4");
    expected.addComponent(component);

    Properties properties = new Properties();
    properties.setProperty("name", "value");
    component.setFlatProperties(properties);

    properties = new Properties();
    properties.setProperty("key", "theValue");
    component.setProperties(properties);

    Repository repository = new Repository();
    repository.setId("foo");
    expected.addRepository(repository);

    // ----------------------------------------------------------------------
    // Write out the model
    // ----------------------------------------------------------------------

    MavenDom4jWriter writer = new MavenDom4jWriter();

    StringWriter buffer = new StringWriter();

    writer.write(buffer, expected);

    String actualXml = buffer.toString();
    actualXml = actualXml.replaceAll("(\r\n)|(\r)", "\n");

    //        System.out.println( expectedXml );
    //
    //        System.err.println( actualXml );

    Assert.assertEquals(expectedXml.trim(), actualXml.trim());

    MavenDom4jReader reader = new MavenDom4jReader();

    Model actual = reader.read(new StringReader(actualXml));

    Assert.assertNotNull("Actual", actual);

    assertModel(expected, actual);

    buffer = new StringWriter();

    writer.write(buffer, actual);

    Assert.assertEquals(
        expectedXml.trim(), buffer.toString().trim().replaceAll("(\r\n)|(\r)", "\n"));
  }
  public boolean performFinish() {
    try {

      if (customMediatorModel.getSelectedOption().equals("new.mediator")) {
        project = createNewProject();
        IFolder srcFolder = ProjectUtils.getWorkspaceFolder(project, "src", "main", "java");
        JavaUtils.addJavaSupportAndSourceFolder(project, srcFolder);

        /*create the new Java project*/
        String className = customMediatorModel.getMediatorClassName();
        String packageName = customMediatorModel.getMediatorClassPackageName();
        IJavaProject iJavaProject = JavaCore.create(project);
        IPackageFragmentRoot root = iJavaProject.getPackageFragmentRoot(srcFolder);
        IPackageFragment sourcePackage = root.createPackageFragment(packageName, false, null);

        /*get the Mediator class template*/
        String template = CustomMediatorClassTemplate.getClassTemplete(packageName, className);
        ICompilationUnit cu =
            sourcePackage.createCompilationUnit(className + ".java", template, false, null);

        project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
        try {
          IEditorPart javaEditor = JavaUI.openInEditor(cu);
          JavaUI.revealInEditor(javaEditor, (IJavaElement) cu);
        } catch (Exception e) {
          log.error(e);
        }
      } else {
        project = customMediatorModel.getMediatorProject();
        project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
      }
      File pomfile = project.getFile("pom.xml").getLocation().toFile();
      getModel().getMavenInfo().setPackageName("bundle");
      if (!pomfile.exists()) {
        createPOM(pomfile);
        addDependancies(project);
      }
      MavenProject mavenProject = MavenUtils.getMavenProject(pomfile);
      boolean pluginExists =
          MavenUtils.checkOldPluginEntry(
              mavenProject, "org.apache.felix", "maven-bundle-plugin", "2.3.4");
      if (!pluginExists) {
        Plugin plugin =
            MavenUtils.createPluginEntry(
                mavenProject, "org.apache.felix", "maven-bundle-plugin", "2.3.4", true);

        Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode(plugin);
        Xpp3Dom instructionNode = MavenUtils.createXpp3Node("instructions");
        Xpp3Dom bundleSymbolicNameNode =
            MavenUtils.createXpp3Node(instructionNode, "Bundle-SymbolicName");
        Xpp3Dom bundleNameNode = MavenUtils.createXpp3Node(instructionNode, "Bundle-Name");
        ;
        Xpp3Dom exportPackageNode = MavenUtils.createXpp3Node(instructionNode, "Export-Package");
        Xpp3Dom dynamicImportNode =
            MavenUtils.createXpp3Node(instructionNode, "DynamicImport-Package");
        bundleSymbolicNameNode.setValue(project.getName());
        bundleNameNode.setValue(project.getName());
        if (customMediatorModel.getMediatorClassPackageName() != null
            && !customMediatorModel.getMediatorClassPackageName().trim().isEmpty()) {
          exportPackageNode.setValue(customMediatorModel.getMediatorClassPackageName());
        } else {
          IJavaProject javaProject = JavaCore.create(project);
          if (null != javaProject) {
            StringBuffer sb = new StringBuffer();
            for (IPackageFragment pkg : javaProject.getPackageFragments()) {
              if (pkg.getKind() == IPackageFragmentRoot.K_SOURCE) {
                if (pkg.hasChildren()) {
                  sb.append(pkg.getElementName()).append(",");
                }
              }
            }
            exportPackageNode.setValue(sb.toString().replaceAll(",$", ""));
          }
        }
        dynamicImportNode.setValue("*");
        configurationNode.addChild(instructionNode);
        MavenUtils.saveMavenProject(mavenProject, pomfile);
      }

      project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
      ProjectUtils.addNatureToProject(project, false, MEDIATOR_PROJECT_NATURE);
      MavenUtils.updateWithMavenEclipsePlugin(
          pomfile,
          new String[] {JDT_BUILD_COMMAND},
          new String[] {MEDIATOR_PROJECT_NATURE, JDT_PROJECT_NATURE});
      customMediatorModel.addToWorkingSet(project);
      project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
      refreshDistProjects();
    } catch (CoreException e) {
      log.error(e);
    } catch (Exception e) {
      log.error(e);
    }
    return true;
  }