test for pom repository filtering

This commit is contained in:
Mark Harrah 2010-04-24 09:39:41 -04:00
parent f7717023da
commit ed307259b4
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,2 @@
project.name=Pom Repository Filter
project.version=1.0

View File

@ -0,0 +1,24 @@
import sbt._
class PomRepoTest(info: ProjectInfo) extends DefaultProject(info)
{
val local = "local-maven-repo" at "file://" + (Path.userHome / ".m2" /"repository").absolutePath
val remote = ScalaToolsSnapshots
override def pomIncludeRepository(r: MavenRepository) =
if("repo.none".asFile.exists) false else if("repo.all".asFile.exists) true else super.pomIncludeRepository(r)
lazy val checkPom =
task { args => task { checkPomRepositories(args.toList) } dependsOn(makePom) }
def checkPomRepositories(args: List[String]): Option[String] =
{
val repositories = scala.xml.XML.loadFile(pomPath asFile) \\ "repository"
val extracted = repositories.map { repo => MavenRepository(repo \ "name" text, repo \ "url" text) }
val expected = args.map(GlobFilter.apply)
log.info("Extracted: " + extracted.mkString("\n\t", "\n\t", "\n"))
log.info("Expected: " + args.mkString("\n\t", "\n\t", "\n"))
(extracted.find { e => !expected.exists(_.accept(e.root)) } map { "Repository should not be exported: " + _ }) orElse
(expected.find { e => !extracted.exists(r => e.accept(r.root)) } map { "Repository should be exported: " + _ } )
}
}

View File

@ -0,0 +1,11 @@
# write the default pom. The only repositories should be Scala Tools Releases and Snapshots
> check-pom http://scala-tools.org/repo-releases/ http://scala-tools.org/repo-snapshots/
# include file:// repositories. The generated repositories section should include the local Maven repository as well
$ touch repo.all
> check-pom http://scala-tools.org/repo-releases/ http://scala-tools.org/repo-snapshots/ file://*.m2/repository/
# include file:// repositories. The generated repositories section should include the local Maven repository as well
$ delete repo.all
$ touch repo.none
> check-pom