@Override
  public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
    try {
      Map<String, MavenProject> projectMap = new HashMap<String, MavenProject>();
      for (MavenProject project : session.getProjects()) {
        projectMap.put(
            project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion(),
            project);
      }

      for (MavenProject project : session.getProjects()) {
        for (Plugin plugin : project.getBuild().getPlugins()) {
          if (plugin.getArtifactId().equals(PLUGIN_ID)) {
            BundleListDependencyAdder performer =
                new BundleListDependencyAdder(session, project, plugin);
            performer.addDependencies();
          }
        }
      }
    } catch (Exception e) {
      throw new MavenExecutionException(
          "Unable to determine launchpad plugin-based dependencies", e);
    }
    super.afterProjectsRead(session);
  }
  public void refreshSiblingProject(IMavenProjectFacade projectFacade, IProgressMonitor monitor)
      throws CoreException {
    // need to look up project configuration and refresh the *-service project associated with this
    // project
    try {
      // not doing any null checks since this is in large try/catch
      final Plugin liferayMavenPlugin = MavenUtil.getLiferayMavenPlugin(projectFacade, monitor);
      final Xpp3Dom config = (Xpp3Dom) liferayMavenPlugin.getConfiguration();
      final Xpp3Dom apiBaseDir = config.getChild(ILiferayMavenConstants.PLUGIN_CONFIG_API_BASE_DIR);
      // this should be the name path of a project that should be in user's workspace that we can
      // refresh
      final String apiBaseDirValue = apiBaseDir.getValue();

      final IFile apiBasePomFile =
          ResourcesPlugin.getWorkspace()
              .getRoot()
              .getFileForLocation(new Path(apiBaseDirValue).append(IMavenConstants.POM_FILE_NAME));
      final IMavenProjectFacade apiBaseFacade =
          this.projectManager.create(apiBasePomFile, true, monitor);

      apiBaseFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } catch (Exception e) {
      LiferayMavenCore.logError("Could not refresh sibling service project.", e); // $NON-NLS-1$
    }
  }
 public JBossPackagingPluginConfiguration(MavenProject mavenProject) {
   this.mavenProject = mavenProject;
   Plugin plugin = mavenProject.getPlugin("org.codehaus.mojo:jboss-packaging-maven-plugin");
   if (plugin != null) {
     configuration = (Xpp3Dom) plugin.getConfiguration();
   }
 }
Beispiel #4
0
  private List<MavenProject> fabricZipGoalProjects() {
    List<MavenProject> answer = new ArrayList<>();
    if (reactorProjects != null) {
      List<MavenProject> pomZipProjects = new ArrayList<>();
      for (MavenProject reactorProject : reactorProjects) {
        if (isPom(reactorProject)) {
          pomZipProjects.add(reactorProject);
        }

        List<Plugin> buildPlugins = reactorProject.getBuildPlugins();
        for (Plugin buildPlugin : buildPlugins) {
          String artifactId = buildPlugin.getArtifactId();
          if ("fabric8-maven-plugin".equals(artifactId)) {
            Object goals = buildPlugin.getGoals();
            boolean hasZipGoal = goals != null && goals.toString().contains("zip");
            List<PluginExecution> executions = buildPlugin.getExecutions();
            for (PluginExecution execution : executions) {
              List<String> execGoals = execution.getGoals();
              if (execGoals.contains("zip")) {
                hasZipGoal = true;
              }
            }
            getLog()
                .debug(
                    "Project " + reactorProject.getArtifactId() + " has zip goal: " + hasZipGoal);
            if (hasZipGoal) {
              answer.add(reactorProject);
            }
          }
        }
      }
    }
    return answer;
  }
 private List<String> getPackages(
     List<String> exportedPackagesList, MavenProject mavenProject, String packagetype)
     throws CoreException, JavaModelException, Exception {
   List<Plugin> plugins = mavenProject.getBuild().getPlugins();
   for (Plugin plugin : plugins) {
     if ("maven-bundle-plugin".equalsIgnoreCase(plugin.getArtifactId())) {
       Xpp3Dom configurationNode = (Xpp3Dom) plugin.getConfiguration();
       Xpp3Dom[] instructions = configurationNode.getChildren("instructions");
       if (instructions.length == 1) {
         Xpp3Dom[] exportPackage = instructions[0].getChildren(packagetype);
         if (exportPackage.length == 1) {
           exportedPackagesList.clear(); // clear default configuration (All packages by default)
           String exportpackages = exportPackage[0].getValue();
           if (exportpackages != null) {
             exportedPackagesList.addAll(Arrays.asList(exportpackages.split(",")));
           }
         } else {
           log.warn(
               "Invalid configuration for <Export-Package> entry"
                   + " using default configuration for <Export-Package>");
         }
       } else {
         log.warn(
             "Invalid instructions configuration for plugin : maven-bundle-plugin"
                 + " using default configuration for <Export-Package>");
       }
       break; // not considering multiple versions of the maven-bundle-plugin
     }
   }
   return exportedPackagesList;
 }
  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);
  }
Beispiel #7
0
 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);
 }
 private static String getKey(Plugin plugin, boolean extension) {
   String version = ArtifactUtils.toSnapshotVersion(plugin.getVersion());
   return (extension ? "extension>" : "plugin>")
       + plugin.getGroupId()
       + ":"
       + plugin.getArtifactId()
       + ":"
       + version;
 }
  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);
  }
  private List<String> alterModel(MavenProject project, String newVersion) {
    Model originalModel = project.getOriginalModel();
    originalModel.setVersion(newVersion);

    List<String> errors = new ArrayList<String>();

    String searchingFrom = project.getArtifactId();
    MavenProject parent = project.getParent();
    if (parent != null && isSnapshot(parent.getVersion())) {
      try {
        ReleasableModule parentBeingReleased =
            reactor.find(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
        originalModel.getParent().setVersion(parentBeingReleased.getVersionToDependOn());
        log.debug(
            " Parent "
                + parentBeingReleased.getArtifactId()
                + " rewritten to version "
                + parentBeingReleased.getVersionToDependOn());
      } catch (UnresolvedSnapshotDependencyException e) {
        errors.add("The parent of " + searchingFrom + " is " + e.artifactId + " " + e.version);
      }
    }
    for (Dependency dependency : originalModel.getDependencies()) {
      String version = dependency.getVersion();
      if (isSnapshot(version)) {
        try {
          ReleasableModule dependencyBeingReleased =
              reactor.find(dependency.getGroupId(), dependency.getArtifactId(), version);
          dependency.setVersion(dependencyBeingReleased.getVersionToDependOn());
          log.debug(
              " Dependency on "
                  + dependencyBeingReleased.getArtifactId()
                  + " rewritten to version "
                  + dependencyBeingReleased.getVersionToDependOn());
        } catch (UnresolvedSnapshotDependencyException e) {
          errors.add(searchingFrom + " references dependency " + e.artifactId + " " + e.version);
        }
      } else
        log.debug(
            " Dependency on "
                + dependency.getArtifactId()
                + " kept at version "
                + dependency.getVersion());
    }
    for (Plugin plugin : project.getModel().getBuild().getPlugins()) {
      String version = plugin.getVersion();
      if (isSnapshot(version)) {
        if (!isMultiModuleReleasePlugin(plugin)) {
          errors.add(
              searchingFrom + " references plugin " + plugin.getArtifactId() + " " + version);
        }
      }
    }
    return errors;
  }
 /**
  * Set the versions of any plugins which match the contents of the list of plugin overrides
  *
  * @param plugins The list of plugins to modify
  * @param pluginVersionOverrides The list of version overrides to apply to the plugins
  */
 private static void applyOverrides(
     List<Plugin> plugins, Map<String, String> pluginVersionOverrides) {
   for (Plugin plugin : plugins) {
     String groupIdArtifactId = plugin.getGroupId() + GAV_SEPERATOR + plugin.getArtifactId();
     if (pluginVersionOverrides.containsKey(groupIdArtifactId)) {
       String overrideVersion = pluginVersionOverrides.get(groupIdArtifactId);
       plugin.setVersion(overrideVersion);
       Log.getLog().debug("Altered plugin: " + groupIdArtifactId + "=" + overrideVersion);
     }
   }
 }
Beispiel #12
0
  @Test
  public void registerNewPlugin() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "registerNewPlugin.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", true);

    assertThat(mavenPlugin).isNotNull();
    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("1.0");
  }
Beispiel #13
0
  @Test
  public void keepPluginDependencies() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "keepPluginDependencies.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);
    assertThat(mavenPlugin).isNotNull();

    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("0.9");
    assertThat(plugin.getDependencies().size()).isEqualTo(1);
  }
  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);
  }
  @Override
  public void generate(final File reportsDir, final VersionManagerSession session)
      throws VManException {
    Map<VersionlessProjectKey, Set<Plugin>> missingPlugins = session.getUnmanagedPluginRefs();
    if (missingPlugins.isEmpty()) {
      return;
    }
    Element plugins = new Element("plugins");

    for (Map.Entry<VersionlessProjectKey, Set<Plugin>> pluginsEntry : missingPlugins.entrySet()) {
      if (plugins.getContentSize() > 0) {
        plugins.addContent("\n\n");
      }

      plugins.addContent(new Comment("START: " + pluginsEntry.getKey()));

      for (Plugin dep : pluginsEntry.getValue()) {
        Element d = new Element("plugin");
        plugins.addContent(d);

        d.addContent(new Element("groupId").setText(dep.getGroupId()));
        d.addContent(new Element("artifactId").setText(dep.getArtifactId()));
        d.addContent(new Element("version").setText(dep.getVersion()));
      }

      plugins.addContent(new Comment("END: " + pluginsEntry.getKey()));
    }

    Element build = new Element("build");
    build.addContent(new Element("pluginManagement").setContent(plugins));

    Document doc = new Document(build);

    Format fmt = Format.getPrettyFormat();
    fmt.setIndent("  ");
    fmt.setTextMode(TextMode.PRESERVE);

    XMLOutputter output = new XMLOutputter(fmt);

    File report = new File(reportsDir, ID + ".xml");
    FileWriter writer = null;
    try {
      reportsDir.mkdirs();

      writer = new FileWriter(report);
      output.output(doc, writer);
    } catch (IOException e) {
      throw new VManException("Failed to generate %s report! Error: %s", e, ID, e.getMessage());
    } finally {
      closeQuietly(writer);
    }
  }
 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());
 }
 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());
 }
 @Override
 public void removePlugin(Dependency dependency) {
   MavenCoreFacet mavenCoreFacet = project.getFacet(MavenCoreFacet.class);
   List<Plugin> pomPlugins = mavenCoreFacet.getPOM().getBuild().getPlugins();
   for (Plugin pomPlugin : pomPlugins) {
     if (pomPlugin.getGroupId().equals(dependency.getGroupId())
         && pomPlugin.getArtifactId().equals(dependency.getArtifactId())) {
       Model pom = mavenCoreFacet.getPOM();
       pom.getBuild().removePlugin(pomPlugin);
       mavenCoreFacet.setPOM(pom);
     }
   }
 }
Beispiel #19
0
  // DefaultProjectBuilder
  public Artifact createPluginArtifact(Plugin plugin) {
    VersionRange versionRange;
    try {
      String version = plugin.getVersion();
      if (StringUtils.isEmpty(version)) {
        version = "RELEASE";
      }
      versionRange = VersionRange.createFromVersionSpec(version);
    } catch (InvalidVersionSpecificationException e) {
      return null;
    }

    return XcreatePluginArtifact(plugin.getGroupId(), plugin.getArtifactId(), versionRange);
  }
  protected void addBuild() {
    Build build = model.getBuild();
    if (build == null) {
      build = new Build();
    }

    if (bwEdition.equals("cf")) {
      boolean cfplugin = false;
      List<Plugin> plugins = build.getPlugins();
      for (Plugin plg : plugins) {
        if (plg.getArtifactId().equals("cf-maven-plugin")) {
          cfplugin = true;
        }
      }

      // Add only if doesn't exist
      if (!cfplugin) {
        addPCFWithSkipMavenPlugin(build);
      }
    } else if (bwEdition.equals("docker")) {
      boolean dockerPlugin = false;
      List<Plugin> plugins = build.getPlugins();
      for (Plugin plg : plugins) {
        if (plg.getArtifactId().equals("docker-maven-plugin")) {
          dockerPlugin = true;
        }
      }

      if (!dockerPlugin) {
        // Add docker and platform plugins if doesn't exist
        addDockerWithSkipMavenPlugin(build);

        String platform = "";
        for (BWModule module : project.getModules()) {
          if (module.getType() == BWModuleType.Application) {
            platform = module.getBwDockerModule().getPlatform();
          }
        }

        if (platform.equals("K8S")) {
          addDockerK8SMavenPlugin(build, true);
        } else if (platform.equals("Mesos")) {

        } else if (platform.equals("Swarm")) {

        }
      }
    }
    model.setBuild(build);
  }
Beispiel #21
0
  @Test
  public void doNotOverrideVersionFromPluginManagementSection() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "overridePluginManagementSection.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);
    assertThat(mavenPlugin).isNotNull();

    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("0.9");

    Plugin pluginManagement =
        MavenUtils.getPlugin(pom.getPluginManagement().getPlugins(), "mygroup", "my.artifact");
    assertThat(pluginManagement).isNull();
  }
  @Test
  public void testSetupCommand() throws Exception {
    Project project = initializeJavaProject();
    getShell().execute("jacoco setup");
    MavenCoreFacet facet = project.getFacet(MavenCoreFacet.class);
    Model pom = facet.getPOM();
    Profile jacocoProfile = pom.getProfiles().get(0);
    assertEquals("jacoco", jacocoProfile.getId());

    Plugin jacocoPlugin = jacocoProfile.getBuild().getPlugins().get(0);
    assertEquals("jacoco-maven-plugin", jacocoPlugin.getArtifactId());

    PluginExecution exec = jacocoPlugin.getExecutions().get(0);
    assertEquals("prepare-agent", exec.getGoals().get(0));
  }
  private Plugin newPlugin(String artifactId, String... goals) {
    Plugin plugin = new Plugin();

    plugin.setGroupId("org.apache.maven.plugins");
    plugin.setArtifactId(artifactId);

    for (String goal : goals) {
      PluginExecution pluginExecution = new PluginExecution();
      pluginExecution.setId("default-" + goal);
      pluginExecution.addGoal(goal);
      plugin.addExecution(pluginExecution);
    }

    return plugin;
  }
    private void readConfiguration() throws IOException {
      Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
      defaultBundleList = null;
      jarWebSupport = null;
      includeDefaultBundles = true;
      bundleListFile = new File(project.getBasedir(), "src/main/bundles/list.xml");
      if (configuration != null) {
        includeDefaultBundles = nodeValue(configuration, "includeDefaultBundles", true);
        Xpp3Dom defaultBundleListConfig = configuration.getChild("defaultBundleList");
        if (defaultBundleListConfig != null) {
          defaultBundleList = new ArtifactDefinition(defaultBundleListConfig);
        }
        Xpp3Dom jarWebSupportConfig = configuration.getChild("jarWebSupport");
        if (jarWebSupportConfig != null) {
          jarWebSupport = new ArtifactDefinition(jarWebSupportConfig);
        }
        Xpp3Dom bundleListFileConfig = configuration.getChild("bundleListFile");
        if (bundleListFileConfig != null) {
          bundleListFile = new File(project.getBasedir(), bundleListFileConfig.getValue());
        }

        configureAdditionalBundles(configuration);
      }

      for (PluginExecution execution : plugin.getExecutions()) {
        Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration();
        if (executionConfiguration != null) {
          configureAdditionalBundles(executionConfiguration);
        }
      }

      initArtifactDefinitions(
          getClass().getClassLoader(),
          new ArtifactDefinitionsCallback() {

            public void initArtifactDefinitions(Properties dependencies) {
              if (defaultBundleList == null) {
                defaultBundleList = new ArtifactDefinition();
              }
              defaultBundleList.initDefaults(dependencies.getProperty("defaultBundleList"));

              if (jarWebSupport == null) {
                jarWebSupport = new ArtifactDefinition();
              }
              jarWebSupport.initDefaults(dependencies.getProperty("jarWebSupport"));
            }
          });
    }
  private List<String> findModules(Plugin pluginConfig, IJavaProject javaProject) {
    List<String> modNames = new ArrayList<String>();
    Xpp3Dom gwtConfig = (Xpp3Dom) pluginConfig.getConfiguration();

    if (gwtConfig != null) {
      Xpp3Dom[] moduleNodes = gwtConfig.getChildren("module");
      if (moduleNodes.length > 0) {
        String moduleQNameTrimmed = null;
        for (Xpp3Dom mNode : moduleNodes) {
          moduleQNameTrimmed = mNode.getValue().trim();
        }
        if (moduleQNameTrimmed != null) {
          modNames.add(moduleQNameTrimmed);
        }
      } else {
        Xpp3Dom modulesNode = gwtConfig.getChild("modules");
        if (modulesNode != null) {
          moduleNodes = modulesNode.getChildren("module");
          for (Xpp3Dom mNode : moduleNodes) {
            String moduleQNameTrimmed = mNode.getValue().trim();
            modNames.add(moduleQNameTrimmed);
          }
        }
      }
    }
    if (modNames.size() == 0) {
      IModule[] modules = ModuleUtils.findAllModules(javaProject, false);
      modNames = new ArrayList<String>();
      for (IModule iModule : modules) {
        modNames.add(iModule.getQualifiedName());
        log.debug("\t{}", iModule.getQualifiedName());
      }
    }
    return modNames;
  }
  public List<IResource> exportArtifact(IProject project) throws Exception {
    String projectPath = project.getLocation().toFile().toString();
    List<IResource> exportResources = new ArrayList<IResource>();
    clearTarget(project);
    IFile pomFile = project.getFile("pom.xml");

    if (pomFile.exists()) {
      MavenProject mavenProject = MavenUtils.getMavenProject(pomFile.getLocation().toFile());
      List<Plugin> plugins = mavenProject.getBuild().getPlugins();
      for (Plugin plugin : plugins) {
        if (plugin.getArtifactId().equals("maven-dataservice-plugin")
            && plugin.getGroupId().equals("org.wso2.maven")) {
          Xpp3Dom artifactNode = ((Xpp3Dom) plugin.getConfiguration()).getChild("artifact");
          String dbsFile = artifactNode.getValue();
          String[] pathArray = dbsFile.split("/");
          IFile dbsFileRef =
              project
                  .getFolder("src")
                  .getFolder("main")
                  .getFolder("dataservice")
                  .getFile(pathArray[pathArray.length - 1]);
          if (dbsFileRef.exists()) {
            exportResources.add((IResource) dbsFileRef);
          }
        }
      }
    } else {
      File[] dbsFiles =
          FileUtils.getAllMatchingFiles(
              project.getLocation().toString(), null, DBS_FILE_EXTENSION, new ArrayList<File>());
      for (File dbsFile : dbsFiles) {
        String filePath = dbsFile.toString();
        // excluded any files inside target dir
        if (!filePath
            .substring(projectPath.length())
            .startsWith(File.separator + "target" + File.separator)) {
          IFile dbsFileRef =
              ResourcesPlugin.getWorkspace()
                  .getRoot()
                  .getFileForLocation(Path.fromOSString(dbsFile.getAbsolutePath()));
          exportResources.add((IResource) dbsFileRef);
        }
      }
    }

    return exportResources;
  }
 static InputLocation findLocationForManagedArtifact(
     final ManagedArtifactRegion region, MavenProject mavprj) {
   Model mdl = mavprj.getModel();
   InputLocation openLocation = null;
   if (region.isDependency) {
     DependencyManagement dm = mdl.getDependencyManagement();
     if (dm != null) {
       List<Dependency> list = dm.getDependencies();
       String id = region.groupId + ":" + region.artifactId + ":"; // $NON-NLS-1$ //$NON-NLS-2$
       if (list != null) {
         for (Dependency dep : list) {
           if (dep.getManagementKey().startsWith(id)) {
             InputLocation location = dep.getLocation(ARTIFACT_ID); // $NON-NLS-1$
             // when would this be null?
             if (location != null) {
               openLocation = location;
               break;
             }
           }
         }
       }
     }
   }
   if (region.isPlugin) {
     Build build = mdl.getBuild();
     if (build != null) {
       PluginManagement pm = build.getPluginManagement();
       if (pm != null) {
         List<Plugin> list = pm.getPlugins();
         String id = Plugin.constructKey(region.groupId, region.artifactId);
         if (list != null) {
           for (Plugin plg : list) {
             if (id.equals(plg.getKey())) {
               InputLocation location = plg.getLocation(ARTIFACT_ID); // $NON-NLS-1$
               // when would this be null?
               if (location != null) {
                 openLocation = location;
                 break;
               }
             }
           }
         }
       }
     }
   }
   return openLocation;
 }
 private boolean hasPreparePackageExecution() {
   for (PluginExecution execution : plugin.getExecutions()) {
     if (execution.getGoals().contains("prepare-package")) {
       return true;
     }
   }
   return false;
 }
  private void parseLifecyclePhaseDefinitions(
      Map<Plugin, Plugin> plugins, String phase, LifecyclePhase goals) {
    List<LifecycleMojo> mojos = goals.getMojos();
    if (mojos != null) {

      for (int i = 0; i < mojos.size(); i++) {
        LifecycleMojo mojo = mojos.get(i);

        GoalSpec gs = parseGoalSpec(mojo.getGoal());

        if (gs == null) {
          logger.warn(
              "Ignored invalid goal specification '"
                  + mojo.getGoal()
                  + "' from lifecycle mapping for phase "
                  + phase);
          continue;
        }

        Plugin plugin = new Plugin();
        plugin.setGroupId(gs.groupId);
        plugin.setArtifactId(gs.artifactId);
        plugin.setVersion(gs.version);

        Plugin existing = plugins.get(plugin);
        if (existing != null) {
          if (existing.getVersion() == null) {
            existing.setVersion(plugin.getVersion());
          }
          plugin = existing;
        } else {
          plugins.put(plugin, plugin);
        }

        PluginExecution execution = new PluginExecution();
        execution.setId(getExecutionId(plugin, gs.goal));
        execution.setPhase(phase);
        execution.setPriority(i - mojos.size());
        execution.getGoals().add(gs.goal);
        execution.setConfiguration(mojo.getConfiguration());

        plugin.setDependencies(mojo.getDependencies());
        plugin.getExecutions().add(execution);
      }
    }
  }
  private List<MavenProblemInfo> findLiferayMavenPluginProblems(
      IProject project, MavenProject mavenProject) {
    final List<MavenProblemInfo> errors = new ArrayList<MavenProblemInfo>();

    // first check to make sure that the AppServer* properties are available and pointed to valid
    // location
    final Plugin liferayMavenPlugin = LiferayMavenUtil.getLiferayMavenPlugin(mavenProject);

    if (liferayMavenPlugin != null) {
      final Xpp3Dom config = (Xpp3Dom) liferayMavenPlugin.getConfiguration();

      final MavenProblemInfo valueProblemInfo =
          checkValidLiferayVersion(liferayMavenPlugin, config);

      if (valueProblemInfo != null) {
        errors.add(valueProblemInfo);
      }

      final String[] configDirParams =
          new String[] {
            ILiferayMavenConstants.PLUGIN_CONFIG_APP_AUTO_DEPLOY_DIR,
            ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_CLASSES_PORTAL_DIR,
            ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_DEPLOY_DIR,
            ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_LIB_GLOBAL_DIR,
            ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_LIB_PORTAL_DIR,
            ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_PORTAL_DIR,
            ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_TLD_PORTAL_DIR,
          };

      for (final String configParam : configDirParams) {
        final MavenProblemInfo configProblemInfo =
            checkValidConfigDir(liferayMavenPlugin, config, configParam);

        if (configProblemInfo != null) {
          errors.add(configProblemInfo);
        }
      }
    }

    return errors;
  }