Search in sources :

Example 1 with LineContainsRegExp

use of org.apache.tools.ant.filters.LineContainsRegExp in project ant-ivy by apache.

the class IvyExtractFromSources method configureConcat.

private void configureConcat() {
    concat.setProject(getProject());
    concat.setTaskName(getTaskName());
    FilterChain filterChain = new FilterChain();
    LineContainsRegExp lcre = new LineContainsRegExp();
    RegularExpression regexp = new RegularExpression();
    regexp.setPattern("^import .+;");
    lcre.addConfiguredRegexp(regexp);
    filterChain.add(lcre);
    TokenFilter tf = new TokenFilter();
    TokenFilter.ReplaceRegex rre = new TokenFilter.ReplaceRegex();
    rre.setPattern("import (.+);.*");
    rre.setReplace("\\1");
    tf.add(rre);
    filterChain.add(tf);
    concat.addFilterChain(filterChain);
}
Also used : RegularExpression(org.apache.tools.ant.types.RegularExpression) LineContainsRegExp(org.apache.tools.ant.filters.LineContainsRegExp) FilterChain(org.apache.tools.ant.types.FilterChain) TokenFilter(org.apache.tools.ant.filters.TokenFilter)

Example 2 with LineContainsRegExp

use of org.apache.tools.ant.filters.LineContainsRegExp in project ant by apache.

the class AbstractJarSignerTask method createRedirector.

/**
 * Create the redirector to use, if any.
 *
 * @return a configured RedirectorElement.
 */
private RedirectorElement createRedirector() {
    RedirectorElement result = new RedirectorElement();
    if (storepass != null) {
        StringBuilder input = new StringBuilder(storepass).append('\n');
        if (keypass != null) {
            input.append(keypass).append('\n');
        }
        result.setInputString(input.toString());
        result.setLogInputString(false);
        // Try to avoid showing password prompts on log output, as they would be confusing.
        LineContainsRegExp filter = new LineContainsRegExp();
        RegularExpression rx = new RegularExpression();
        // TODO only handles English locale, not ja or zh_CN
        rx.setPattern("^(Enter Passphrase for keystore: |Enter key password for .+: )$");
        filter.addConfiguredRegexp(rx);
        filter.setNegate(true);
        result.createErrorFilterChain().addLineContainsRegExp(filter);
    }
    return result;
}
Also used : RegularExpression(org.apache.tools.ant.types.RegularExpression) RedirectorElement(org.apache.tools.ant.types.RedirectorElement) LineContainsRegExp(org.apache.tools.ant.filters.LineContainsRegExp)

Aggregations

LineContainsRegExp (org.apache.tools.ant.filters.LineContainsRegExp)2 RegularExpression (org.apache.tools.ant.types.RegularExpression)2 TokenFilter (org.apache.tools.ant.filters.TokenFilter)1 FilterChain (org.apache.tools.ant.types.FilterChain)1 RedirectorElement (org.apache.tools.ant.types.RedirectorElement)1