diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 0c0e69821..d0cf1145b 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -566,17 +566,19 @@ object Defaults extends BuildCommon { def selectedFilter(args: Seq[String]): Seq[String => Boolean] = { - val (excludeArgs, includeArgs) = args.partition(s => s.startsWith("-")) + def matches(nfs: Seq[NameFilter], s: String) = nfs.exists(_.accept(s)) + + val (excludeArgs, includeArgs) = args.partition(_.startsWith("-")) val includeFilters = includeArgs map GlobFilter.apply val excludeFilters = excludeArgs.map(_.substring(1)).map(GlobFilter.apply) - if (includeFilters.isEmpty && excludeArgs.isEmpty) + if (includeFilters.isEmpty && excludeArgs.isEmpty) { Seq(const(true)) - else if (includeFilters.isEmpty) { - excludeFilters.map { f => (s: String) => !f.accept(s) } + } else if (includeFilters.isEmpty) { + Seq({ (s: String) => !matches(excludeFilters, s) }) } else { - includeFilters.map { f => (s: String) => (f.accept(s) && !excludeFilters.exists(x => x.accept(s))) } + includeFilters.map { f => (s: String) => (f.accept(s) && !matches(excludeFilters, s)) } } } def detectTests: Initialize[Task[Seq[TestDefinition]]] = (loadedTestFrameworks, compile, streams) map { (frameworkMap, analysis, s) => diff --git a/main/src/test/scala/DefaultsTest.scala b/main/src/test/scala/DefaultsTest.scala index 43e8dd064..c09a806c0 100644 --- a/main/src/test/scala/DefaultsTest.scala +++ b/main/src/test/scala/DefaultsTest.scala @@ -5,13 +5,13 @@ import java.io._ import org.specs2.mutable.Specification object DefaultsTest extends Specification { + private def assertFiltered(filter: List[String], expected: Map[String, Boolean]) = { + val actual = expected.map(t => (t._1, Defaults.selectedFilter(filter).exists(fn => fn(t._1)))) + + actual must be equalTo (expected) + } + "`selectedFilter`" should { - def assertFiltered(filter: List[String], expected: Map[String, Boolean]) = { - val actual = expected.map(t => (t._1, Defaults.selectedFilter(filter).exists(fn => fn(t._1)))) - - actual must be equalTo (expected) - } - "return all tests for an empty list" in { assertFiltered(List(), Map("Test1" -> true, "Test2" -> true)) } @@ -39,6 +39,14 @@ object DefaultsTest extends Specification { "cope with multiple filters" in { assertFiltered(List("T*1", "T*2", "-F*"), Map("Test1" -> true, "Test2" -> true, "Foo" -> false)) } + + "cope with multiple exclusion filters, no includes" in { + assertFiltered(List("-A*", "-F*"), Map("Test1" -> true, "Test2" -> true, "AAA" -> false, "Foo" -> false)) + } + + "cope with multiple exclusion filters with includes" in { + assertFiltered(List("T*", "-T*1", "-T*2"), Map("Test1" -> false, "Test2" -> false, "Test3" -> true)) + } } } diff --git a/sbt-maven-resolver/src/main/scala/sbt/mavenint/MavenRepositoryResolver.scala b/sbt-maven-resolver/src/main/scala/sbt/mavenint/MavenRepositoryResolver.scala index 6796efcd7..6ee17cced 100644 --- a/sbt-maven-resolver/src/main/scala/sbt/mavenint/MavenRepositoryResolver.scala +++ b/sbt-maven-resolver/src/main/scala/sbt/mavenint/MavenRepositoryResolver.scala @@ -259,7 +259,7 @@ abstract class MavenRepositoryResolver(settings: IvySettings) extends AbstractRe // Here we add in additional artifact requests, which ALLWAYS have to be explicit since // Maven/Aether doesn't include all known artifacts in a pom.xml // TODO - This does not appear to be working correctly. - if (dd.getAllDependencyArtifacts.isEmpty) { + if (dd.getAllDependencyArtifacts.isEmpty) { val artifactId = s"${drid.getName}-${drid.getRevision}" // Add the artifacts we know about the module packaging match { diff --git a/sbt/src/sbt-test/tests/test-exclude/test b/sbt/src/sbt-test/tests/test-exclude/test index ec11c6a39..913c97312 100644 --- a/sbt/src/sbt-test/tests/test-exclude/test +++ b/sbt/src/sbt-test/tests/test-exclude/test @@ -53,3 +53,9 @@ $ delete target/Test2.run > test-only -Test* -$ exists target/Test1.run -$ exists target/Test2.run + + +# with only glob exclusion +> test-only -T*1 -T*2 +-$ exists target/Test1.run +-$ exists target/Test2.run