public static void handleExtensions()

in src/main/java/org/apache/sling/maven/slingstart/JSONFeatures.java [81:103]


	public static void handleExtensions(final Feature feature, final File file) throws IOException {
        for(final Extension ext : feature.getExtensions()) {
            if ( ext.getType() == ExtensionType.TEXT && ext.getText().startsWith(FILE_PREFIX)) {
                final int pos = file.getName().lastIndexOf(".");
                final String baseName = pos == -1 ? file.getName() : file.getName().substring(0, pos);
                final String fileName;
                if ( FILE_PREFIX.equals(ext.getText()) ) {
                    fileName = baseName.concat("-").concat(ext.getName()).concat(".txt");
                } else {
                    if ( !ext.getText().substring(FILE_PREFIX.length()).startsWith(":") ) {
                        throw new IOException("Invalid file reference: " + ext.getText());
                    }
                    fileName = baseName.concat("-").concat(ext.getText().substring(FILE_PREFIX.length() + 1));
                }
                final File txtFile = new File(file.getParentFile(), fileName);
                if ( !txtFile.exists() || !txtFile.isFile()) {
                    throw new IOException("Extension text file " + txtFile.getAbsolutePath() + " not found.");
                }
                final String contents = FileUtils.readFileToString(txtFile, StandardCharsets.UTF_8);
                ext.setText(contents);
            }
        }
    }