从DefaultShellCallback中借用的解析文件夹的函数

@param targetProject target project
@param targetPackage target package
@return file instance
@throws ShellException Cannot get infos form environment
772000
public File getDirectory(String targetProject, String targetPackage)
      throws ShellException {
    // targetProject is interpreted as a directory that must exist
    //
    // targetPackage is interpreted as a sub directory, but in package
    // format (with dots instead of slashes). The sub directory will be
    // created
    // if it does not already exist

    File project = new File(targetProject);
    if (!project.isDirectory()) {
      throw new ShellException(getString("Warning.9", //$NON-NLS-1$
          targetProject));
    }

    StringBuilder sb = new StringBuilder();
    StringTokenizer st = new StringTokenizer(targetPackage, "."); //$NON-NLS-1$
    while (st.hasMoreTokens()) {
      sb.append(st.nextToken());
      sb.append(File.separatorChar);
    }

    File directory = new File(project, sb.toString());
    if (!directory.isDirectory()) {
      boolean rc = directory.mkdirs();
      if (!rc) {
        throw new ShellException(getString("Warning.10", //$NON-NLS-1$
            directory.getAbsolutePath()));
      }
    }

    return directory;
  }
38721
@TaskAction
    public void packageForSwarm() throws Exception {
        final Project project = getProject();
        final ThorntailExtension extension = getThorntailExtension();

        GradleArtifactResolvingHelper resolvingHelper = new GradleArtifactResolvingHelper(project);
        Properties propertiesFromExtension = extension.getProperties();
        Set<File> moduleDirs = extension.getModules();
        if (moduleDirs.isEmpty()) {
            Path resourcesOutputDir = project.getConvention()
                    .getPlugin(JavaPluginConvention.class)
                    .getSourceSets()
                    .findByName(SourceSet.MAIN_SOURCE_SET_NAME)
                    .getOutput()
                    .getResourcesDir()
                    .toPath()
                    .resolve(MODULE_DIR_NAME);
            if (Files.isDirectory(resourcesOutputDir)) {
                File moduleDir = resourcesOutputDir.toFile();

                moduleDirs.add(moduleDir);
            }
        }


        BuildTool tool = new BuildTool(resolvingHelper)
                .projectArtifact(this.jarTask.getGroup(), this.jarTask.getBaseName(), this.jarTask.getVersion(),
                                 getPackaging(), getProjectArtifactFile())
                .mainClass(getMainClassName())
                .bundleDependencies(extension.isBundleDependencies())
                .executable(extension.isIncludeExecutable())
                .executableScript(extension.getExecutableScript())
                .properties(propertiesFromExtension)
                .properties(getPropertiesFromFile())
                .properties(PropertiesUtil.filteredSystemProperties(propertiesFromExtension, false))
                .fractionDetectionMode(extension.getFractionDetectionMode())
                .hollow(extension.isHollow())
                .additionalModules(moduleDirs.stream()
                                           .filter(File::exists)
                                           .map(File::getAbsolutePath)
                                           .collect(Collectors.toList()))
                .logger(new SimpleLogger() {
                    @Override
                    public void debug(String msg) {
                        getLogger().debug(msg);
                    }

                    @Override
                    public void info(String msg) {
                        getLogger().info(msg);
                    }

                    @Override
                    public void error(String msg) {
                        getLogger().error(msg);
                    }

                    @Override
                    public void error(String msg, Throwable t) {
                        getLogger().error(msg, t);
                    }
                });

        tool.declaredDependencies(GradleToolingHelper.toDeclaredDependencies(extension.getDependencies()));
        tool.bundleDependencies(extension.isBundleDependencies());
        // Add the explicitly defined fractions from the configuration.
        extension.getDeclaredFractions().stream().map(DependencyDescriptor::toArtifactSpec).forEach(tool::fraction);
        // Build the Thorntail archive.
        tool.build(getOutputFile().getName(), getOutputDirectory());

        /* We expect a war task to be present before scanning for war files. */
        final java.util.Optional<Task> task = project.getTasks().stream().filter(t -> "war".equals(t.getName())).findAny();
        if (task.isPresent()) {
            /* Look for all the war archives present */
            final Set<File> warArchives = project.getConfigurations()
                    .stream()
                    .map(Configuration::getAllArtifacts)
                    .map(PublishArtifactSet::getFiles)
                    .map(FileCollection::getFiles)
                    .flatMap(Collection::stream)
                    .filter(f -> f.getName().endsWith(".war"))
                    .collect(Collectors.toSet());
            for (File warArchive : warArchives) {
                tool.repackageWar(warArchive);
            }
        }
    }
479746
@Override
    @GET
    @Path("/invoke/{name}/{namespace}/{projectName}/{path: .*}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response executeCommandViaGet(@PathParam("name") final String name,
                                         @PathParam("namespace") final String namespace,
                                         @PathParam("projectName") final String project,
                                         @PathParam("path") final String path) throws Exception {

        LOG.info("Invoking command " + name + " in project " + namespace + "/" + project + " with path: " + path);

        ExecutionRequest executionRequest = new ExecutionRequest();
        executionRequest.setNamespace(namespace);
        executionRequest.setProjectName(project);
        executionRequest.setResource(path);
        List<Map<String, Object>> inputList = new ArrayList<>();
        Map<String, Object> arguments = new HashMap<>();

        // lets pass in query arguments that are not secret related stuff
        Map<String, String[]> parameterMap = request.getParameterMap();
        for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
            String parameterName = entry.getKey();
            String[] value = entry.getValue();
            if (value != null) {
                if (!RequestParameters.REQUEST_PARAMETERS.contains(parameterName)) {
                    Object paramValue = value;
                    if (value.length == 1) {
                        paramValue = value[0];
                    }
                    arguments.put(parameterName, paramValue);
                }
            }
        }
        inputList.add(arguments);
        executionRequest.setInputList(inputList);
        return executeCommand(name, executionRequest);
    }
48486
public void importResourcesWithTempProject(String importFile) throws Exception {

        CmsProject project = m_cms.createProject(
            "SystemUpdate",
            getMessages().key(Messages.GUI_SHELL_IMPORT_TEMP_PROJECT_NAME_0),
            OpenCms.getDefaultUsers().getGroupAdministrators(),
            OpenCms.getDefaultUsers().getGroupAdministrators(),
            CmsProject.PROJECT_TYPE_TEMPORARY);
        CmsUUID id = project.getUuid();
        m_cms.getRequestContext().setCurrentProject(project);
        m_cms.copyResourceToProject("/");

        CmsImportParameters params = new CmsImportParameters(importFile, "/", true);

        OpenCms.getImportExportManager().importData(
            m_cms,
            new CmsShellReport(m_cms.getRequestContext().getLocale()),
            params);

        m_cms.unlockProject(id);
        OpenCms.getPublishManager().publishProject(m_cms);
        OpenCms.getPublishManager().waitWhileRunning();
    }
883549
private static void initFromPackageInfo(PackageDescriptor pd,
                                            Class<?> packageInfoClass) 
    throws Exception {


        pd.setExists(true);

        Class<?>[] ca = new Class[0];
        Object[] oa = new Object[0];

        pd.setSpecificationTitle(
            (String) (packageInfoClass.getMethod("getSpecificationTitle", 
                                                 ca)).invoke(null, oa));

        pd.setSpecificationVersion(
            (String) (packageInfoClass.getMethod("getSpecificationVersion", 
                                                 ca)).invoke(null, oa));

        pd.setSpecificationVendor(
            (String) (packageInfoClass.getMethod("getSpecificationVendor", 
                                                 ca)).invoke(null, oa));

        pd.setImplementationTitle(
            (String) (packageInfoClass.getMethod("getImplementationTitle", 
                                                 ca)).invoke(null, oa));

        pd.setImplementationVersion(
            (String) (packageInfoClass.getMethod("getImplementationVersion", 
                                                 ca)).invoke(null, oa));

        pd.setImplementationVendor(
            (String) (packageInfoClass.getMethod("getImplementationVendor", 
                                                 ca)).invoke(null, oa));

        pd.setBaseDirectory(
            (String) (packageInfoClass.getMethod("getBaseDirectory", 
                                                 ca)).invoke(null, oa));

        pd.setRepository(
            (String) (packageInfoClass.getMethod("getRepository", 
                                                 ca)).invoke(null, oa));

        pd.setUsername(
            (String) (packageInfoClass.getMethod("getUsername", 
                                                 ca)).invoke(null, oa));

        pd.setBuildMachine(
            (String) (packageInfoClass.getMethod("getBuildMachine", 
                                                 ca)).invoke(null, oa));

        pd.setGroup(
            (String) (packageInfoClass.getMethod("getGroup", 
                                                 ca)).invoke(null, oa));

        pd.setProject(
            (String) (packageInfoClass.getMethod("getProject", 
                                                 ca)).invoke(null, oa));

        pd.setBuildLocation(
            (String) (packageInfoClass.getMethod("getBuildLocation", 
                                                 ca)).invoke(null, oa));

        pd.setProduct(
            (String) (packageInfoClass.getMethod("getProduct", 
                                                 ca)).invoke(null, oa));

        pd.setProductVersion(
            (String) (packageInfoClass.getMethod("getProductVersion", 
                                                 ca)).invoke(null, oa));

        pd.setBuildNumber(
            (String) (packageInfoClass.getMethod("getBuildNumber", 
                                                 ca)).invoke(null, oa));

        pd.setBuildDate(
            (Date) (packageInfoClass.getMethod("getBuildDate", 
                                               ca)).invoke(null, oa));


    }
876783
def packageProject(self, dir=os.getcwd(), configuration='Shipping', extraArgs=[]):
		
		
		# Verify that the specified build configuration is valid
		if configuration not in self.validBuildConfigurations():
			raise UnrealManagerException('invalid build configuration "' + configuration + '"')
		
		# Strip out the `-NoCompileEditor` flag if the user has specified it, since the Development version
		# of the Editor modules for the project are needed in order to run the commandlet that cooks content
		extraArgs = Utility.stripArgs(extraArgs, ['-nocompileeditor'])
		
		# Prevent the user from specifying multiple `-platform=` or `-targetplatform=` arguments,
		# and use the current host platform if no platform argument was explicitly specified
		platformArgs = Utility.findArgs(extraArgs, ['-platform=', '-targetplatform='])
		platform = Utility.getArgValue(platformArgs[0]) if len(platformArgs) > 0 else self.getPlatformIdentifier()
		extraArgs = Utility.stripArgs(extraArgs, platformArgs) + ['-platform={}'.format(platform)]
		
		# If we are packaging a Shipping build, do not include debug symbols
		if configuration == 'Shipping':
			extraArgs.append('-nodebuginfo')
		
		# Do not create a .pak file when packaging for HTML5
		pakArg = '-package' if platform.upper() == 'HTML5' else '-pak'
		
		# Invoke UAT to package the build
		distDir = os.path.join(os.path.abspath(dir), 'dist')
		self.runUAT([
			'BuildCookRun',
			'-utf8output',
			'-clientconfig=' + configuration,
			'-serverconfig=' + configuration,
			'-project=' + self.getProjectDescriptor(dir),
			'-noP4',
			'-cook',
			'-allmaps',
			'-build',
			'-stage',
			'-prereqs',
			pakArg,
			'-archive',
			'-archivedirectory=' + distDir
		] + extraArgs)
1237195
@Override
    @GET
    @Path("/invoke/{name}/{namespace}/{projectName}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response executeCommandViaGetNoPath(@PathParam("name") final String name,
                                               @PathParam("namespace") final String namespace,
                                               @PathParam("projectName") final String project) throws Exception {
        return executeCommandViaGet(name, namespace, project, "");

    }
25648
public static ResourceBundle getResourceBundle(String baseName,
            Locale targetLocale) {
        Locale.setDefault(targetLocale);
        return ResourceBundle.getBundle(baseName);
    }
417173
public boolean pack(final File targetArchiveFile, List<FileData> fileDatas,
                        final ArchiveRetriverCallback<FileData> callback) throws ArchiveException {
        int count = 0;
        Exception exception = null;
        while (++count <= retry) {
            try {
                return doPack(targetArchiveFile, fileDatas, callback);
            } catch (Exception ex) {
                exception = ex;
            }
        }

        throw new ArchiveException("pack fileDatas error!", exception);
    }
447844
public static boolean extractPackage(
      String packageName, String targetFolder, boolean isVerbose, boolean isInheritIO) {
    String cmd = String.format("tar -xvf %s", packageName);

    int ret = runSyncProcess(isVerbose, isInheritIO,
        splitTokens(cmd), new StringBuilder(), new File(targetFolder));

    return ret == 0;
  }
1252996
@SuppressWarnings("deprecation")
    public CmsResource createFolder(String targetFolder, String folderName) throws Exception {

        if (m_cms.existsResource(targetFolder + folderName)) {
            m_shell.getOut().println(
                getMessages().key(Messages.GUI_SHELL_FOLDER_ALREADY_EXISTS_1, targetFolder + folderName));
            return null;
        }
        return m_cms.createResource(targetFolder + folderName, CmsResourceTypeFolder.getStaticTypeId());
    }
1347353
protected String getMessageText(final File pZipFile, final PackageManager pPackageManager) {
        String version = "";
        try {
            final PackageInfo pi = pPackageManager.getPackageInfo(getPackageName(), 0);
            version = " " + pi.versionName;
        } catch (final PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Version name not found", e);
        }
        return getString(R.string.email_text, version,
                Build.MODEL, Build.DEVICE, Build.VERSION.RELEASE, Build.ID,
                pZipFile.getName(), (pZipFile.length() + 512) / 1024);
    }
984091
protected void generatePackageTreeFile() throws IOException {
        Content body = getPackageTreeHeader();
        Content headContent = getResource("doclet.Hierarchy_For_Package",
                Util.getPackageName(packagedoc));
        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
                HtmlStyle.title, headContent);
        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
        if (configuration.packages.length > 1) {
            addLinkToMainTree(div);
        }
        body.addContent(div);
        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
        divTree.addStyle(HtmlStyle.contentContainer);
        addTree(classtree.baseclasses(), "doclet.Class_Hierarchy", divTree);
        addTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy", divTree);
        addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
        addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree);
        body.addContent(divTree);
        addNavLinks(false, body);
        addBottom(body);
        printHtmlDocument(null, true, body);
    }
132864
public function prepare_package_file() {
        if (empty($this->singlefile) && empty($this->multifiles)) {
            throw new portfolio_caller_exception('invalidpreparepackagefile', 'portfolio', $this->get_return_url());
        }
        if ($this->singlefile) {
            return $this->exporter->copy_existing_file($this->singlefile);
        }
        foreach ($this->multifiles as $file) {
            $this->exporter->copy_existing_file($file);
        }
    }
343792
@Override
    public List<String> setTargetHostsFromCmsQueryUrl(String cmsQueryUrl)
            throws TargetHostsLoadException {
        List<String> targetHosts = new ArrayList<String>();
        try {

            logger.info("will use default project label");
            targetHosts = setTargetHostsFromCmsQueryUrl(cmsQueryUrl, "label");
        } catch (Exception e) {
            throw new TargetHostsLoadException("error when reading  "
                    + cmsQueryUrl, e);
        }

        return targetHosts;

    }
61153
void processPackageInfo(String src, String filename, SimpleGroovyPackageDoc packageDoc) {
        String relPath = packageDoc.getRelativeRootPath();
        String description = calcThenSetPackageDescription(src, filename, relPath);
        packageDoc.setDescription(description);
        // get same description but with paths relative to root
        String altDescription = calcThenSetPackageDescription(src, filename, "");
        calcThenSetSummary(altDescription, packageDoc);
    }
938716
private File ensureThatArtifactFileIsSet(MavenProject project) {
        Artifact artifact = project.getArtifact();
        if (artifact == null) {
            return null;
        }
        File oldFile = artifact.getFile();
        if (oldFile != null) {
            return oldFile;
        }
        Build build = project.getBuild();
        if (build == null) {
            return null;
        }
        String finalName = build.getFinalName();
        String target = build.getDirectory();
        if (finalName == null || target == null) {
            return null;
        }
        File artifactFile = new File(target, finalName + "." + project.getPackaging());
        if (artifactFile.exists() && artifactFile.isFile()) {
            setArtifactFile(project, artifactFile);
        }
        return null;
    }