コード例 #1
0
 public ProjectTemplateProjectGen(ProjectTemplate template) {
   props.put("PARENT_GROUPID", template.getParentGroupId());
   props.put("PARENT_ARTIFACTID", template.getParentArtifactId());
   props.put("PARENT_VERSION", template.getParentVersion());
   props.put("GROUPID", template.getGroupId());
   props.put("ARTIFACTID", template.getArtifactId());
   props.put("VERSION", template.getVersion());
   props.put("APILEVEL", template.getApiLevel());
   this.template = template;
 }
コード例 #2
0
  @Override
  public void generate(File outputFile) throws OutputProjectException {
    LOG.info("Generating: " + outputFile);

    Document pom = FilteredFileUtil.loadExpandedXml(template.getTemplateName(), props);

    if (template.hasDependencies()) {
      Element deps = (Element) pom.selectSingleNode("/project/dependencies");
      if (deps == null) {
        pom.getRootElement().addElement("dependencies");
      }

      for (ProjectDependency pd : template.getDependencies()) {
        ProjectTemplate proj = pd.getProject();
        Element dep = deps.addElement("dependency");
        dep.addElement("groupId").addText(proj.getGroupId());
        dep.addElement("artifactId").addText(proj.getArtifactId());
        dep.addElement("version").addText(proj.getVersion());
      }
    }

    FilteredFileUtil.write(pom, outputFile);
  }