Пример #1
0
 @Override
 public boolean install() {
   if (!this.isInstalled()) {
     for (DirectoryResource folder : this.getSourceDirectories()) {
       folder.mkdirs();
     }
   }
   return isInstalled();
 }
Пример #2
0
  @Override
  public Result execute(UIExecutionContext context) throws Exception {
    Result result = Results.success("Project named '" + named.getValue() + "' has been created.");
    DirectoryResource directory = targetLocation.getValue();
    DirectoryResource targetDir = directory.getChildDirectory(named.getValue());

    if (targetDir.mkdirs() || overwrite.getValue()) {
      ProjectType value = type.getValue();

      Project project = null;
      if (value != null) {
        project =
            projectFactory.createProject(
                targetDir, buildSystem.getValue(), value.getRequiredFacets());
      } else {
        project = projectFactory.createProject(targetDir, buildSystem.getValue());
      }

      if (project != null) {
        UIContext uiContext = context.getUIContext();
        MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
        metadataFacet.setProjectName(named.getValue());
        metadataFacet.setProjectVersion(version.getValue());
        metadataFacet.setTopLevelPackage(topLevelPackage.getValue());

        if (finalName.hasValue()) {
          PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class);
          packagingFacet.setFinalName(finalName.getValue());
        }

        uiContext.setSelection(project.getRoot());
        uiContext.getAttributeMap().put(Project.class, project);
      } else result = Results.fail("Could not create project of type: [" + value + "]");
    } else result = Results.fail("Could not create target location: " + targetDir);

    return result;
  }