title: Gradle - throw exception if project still has SNAPSHOT dependencies
body: <p>I want to <strong>fail</strong> the gradle build if the current project still has <strong>snapshot</strong> dependencies.</p>
  
  <p>My code so far only looks for java dependencies, missing the .NET ones so it only works for java projects. I want to make it work for all projects.</p>
  
  <pre><code>def addSnapshotCheckingTask(Project project) {
      project.tasks.withType(JavaCompile) { compileJava -&gt;
          project.tasks.create(compileJava.name + 'SnapshotChecking', {
              onlyIf {
                  project.ext.isRelease || project.ext.commitVersion != null
              }
              compileJava.dependsOn it
              doLast {
                  def snapshots = compileJava.classpath
                          .filter { project.ext.isRelease || !(it.path ==~ /(?i)${project.rootProject.projectDir.toString().replace('\\', '\\\\')}.*build.libs.*/) }
                          .filter { it.path =~ /(?i)-SNAPSHOT/  }
                          .collect { it.name }
                          .unique()
                  if (!snapshots.isEmpty()) {
                      throw new GradleException("Please get rid of snapshots for following dependencies before releasing $snapshots")
                  }
              }
          })
      }
  }
  </code></pre>
  
  <p>I need some help in generifying this snippet to be applicable to all types of dependencies(not just java)</p>
  
  <p>Thanks!</p>
  
  <p>L.E. Could something like this work?
  <a href="https://discuss.gradle.org/t/how-can-i-check-for-snapshot-dependencies-and-throw-an-exception-if-some-where-found/4064" rel="nofollow noreferrer">https://discuss.gradle.org/t/how-can-i-check-for-snapshot-dependencies-and-throw-an-exception-if-some-where-found/4064</a></p>