private String findFragment()

in src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java [544:569]


    private String findFragment(BuildException buildException) {
        if (buildException == null
                || buildException.getLocation() == null
                || buildException.getLocation().getFileName() == null) {
            return null;
        }

        File antFile = new File(buildException.getLocation().getFileName());
        if (!antFile.exists()) {
            return null;
        }

        try (LineNumberReader reader = new LineNumberReader(ReaderFactory.newXmlReader(antFile))) {
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                if (reader.getLineNumber() == buildException.getLocation().getLineNumber()) {
                    return "around Ant part ..." + line.trim() + "... @ "
                            + buildException.getLocation().getLineNumber() + ":"
                            + buildException.getLocation().getColumnNumber() + " in " + antFile.getAbsolutePath();
                }
            }
        } catch (Exception e) {
            getLog().debug(e.getMessage(), e);
        }

        return null;
    }