title: gradle how to add only javascript files to a directory in the war file
body: <p>I am trying to create a web application that uses angular2. The part of the build.gradle responsible for compiling the typescript and adding it to the war is as follows:</p>
  
  <pre><code>public class TsCompileTask extends DefaultTask {
      File projectDir;
  
      @OutputDirectory
      File outputDir;
  
      @TaskAction
      void compile() {
          println "compiling TypeScript files..."
          project.exec {
              executable = "tsc"
  
              args "-p"
              args projectDir
              args "--outDir"
              args outputDir.toString()
          }
      }
  }
  
  public class npmInstallTask extends DefaultTask {
      File projectDir
  
      @TaskAction
      void compile(){
          println "installing npm packages"
          project.exec {
              workingDir = projectDir.path
              executable = "npm"
              args "install"
          }
      }
  }
  
  task tsCompile(type:TsCompileTask) {
      projectDir = file('./src/main/typescript')
      outputDir = file("$buildDir/ts")
  }
  
  war{
      into("js"){
          from tsCompile.outputs
      }
  }
  </code></pre>
  
  <p>This adds the output of the typescript compiler to the js directory in the war archive, but it does not add the dependencies, which are in the directory node_modules.</p>
  
  <p>I tried to use the following gradle snippet to add only the JavaScript files from the typescript directoryinto thw war:</p>
  
  <pre><code>war{
      into("js"){
          from fileTree(dir: './src/main/typescrypt/').matching{
              include('**/*.js)
          }.files
      }
  }
  </code></pre>
  
  <p>However, this includes all files under the directory.</p>
  
  <p>I have tried several variations of the above (e.g. having the into be in a closure for from instead of the other way around, using <code>fileTree('./src/main/typescript').include('**/*.js')</code>). How can I add <strong>only</strong> the files ending in .js to the js directory in the war file?</p>