How to get all the *.sln files from a given directory using Groovy script?
<p>Am writing a Jenkins Groovy script file to get all the .NET project solution files (<code>*.sln</code>) in a given directory (including subdirectories). </p>

<p>First I tried to get the list of directories in a given path. I used the below code which is working fine:</p>

<pre><code>File folder = new File("D:\\Data");
File[] listOfFiles = folder.listFiles();

for (int i = 0; i &lt; listOfFiles.length; i++) {
    if (listOfFiles[i].isFile()) {
        println("File " + listOfFiles[i].getName());
        }
    else if (listOfFiles[i].isDirectory()) {
        println("Directory " + listOfFiles[i].getName());
        }
    }
</code></pre>

<p>2) When modified the code as below to list out all the solution files in a given path I am getting error:</p>

<pre><code>File folder = new File("D:\\Data");
File[] listOfFiles = folder.listFiles();
Collection files = FileUtils.listFiles(
  folder, 
  new RegexFileFilter("^(*.sln)"), 
  DirectoryFileFilter.DIRECTORY
  );

for (int i = 0; i &lt; files.length; i++) {
    if (files[i].isFile()) {
        println("File " + files[i].getName());
        } 
    else if (files[i].isDirectory()) {
        println("Directory " + files[i].getName());
        }
    }
</code></pre>

<p>Error details:</p>

<pre><code>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 5: unable to resolve class RegexFileFilter 
 @ line 5, column 3.
     new RegexFileFilter("^(*.sln)"), 
     ^
</code></pre>

<p>Could anyone please help me on this to get all the solution files in a given path (including subdirectories)</p>

<p>Thanks in advance!!</p>