Add failing transitive exlcude test.

This commit is contained in:
Josh Suereth 2015-07-23 15:59:35 -04:00
parent bad1e9d487
commit 3613cc8c39
10 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,28 @@
resolvers += {
val f = baseDirectory.value / "repository"
"local-test-repo" at f.getCanonicalFile.toURI.toASCIIString
}
libraryDependencies += "exclude.test" % "app" % "1.0.0"
val checkDependencies = taskKey[Unit]("Checks that dependcies are correct.")
checkDependencies := {
val hasBadJar = (fullClasspath in Compile).value.exists { jar => jar.data.getName contains "bottom-1.0.0.jar"}
val errorJarString = (fullClasspath in Compile).value.map(_.data.getName).mkString(" * ", "\n * ", "")
assert(!hasBadJar, s"Failed to exclude transitive excluded dependency on classpath!\nFound:\n$errorJarString")
val modules =
(for {
c <- update.value.configurations
m <- c.modules
if !m.evicted
} yield m.module).distinct
val hasBadDep =
modules exists { m =>
(m.organization == "exclude.test") && (m.name == "bottom")
}
val errModuleString = modules.mkString("\n * ", "\n * ", "")
assert(!hasBadDep, s"Failed to exclude transitive excluded dependency!\nFound:\n$errModuleString")
}

View File

@ -0,0 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>exclude.test</groupId>
<artifactId>app</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<name>app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>exclude.test</groupId>
<artifactId>top</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>exclude.test</groupId>
<artifactId>bottom</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<name>bottom</name>
<url>http://maven.apache.org</url>
<dependencies>
</dependencies>
</project>

View File

@ -0,0 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>exclude.test</groupId>
<artifactId>middle</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<name>middle</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>exclude.test</groupId>
<artifactId>bottom</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>exclude.test</groupId>
<artifactId>top</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<name>top</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>exclude.test</groupId>
<artifactId>middle</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>exclude.test</groupId>
<artifactId>middle</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1 @@
> checkDependencies