Permalink
Browse files

Support for extra test configurations

  • Loading branch information...
Pawel Zawistowski authored and mpeltonen committed Mar 23, 2014
1 parent c839586 commit 388b3e48ee1fa1db5332181ae32afa1bd593e379
View
@@ -71,6 +71,19 @@ Or in your Build.scala:
lazy val myproject = Project(id = "XXXX" ....)
.settings(ideaExcludeFolders := ".idea" :: ".idea_modules" :: Nil)
+### Include extra test configurations
+
+In your Build.scala:
+
+ lazy val LoadTest = config("test-load") extend Test
+ lazy val loadTestSettings : Seq[Setting[_]] = inConfig(LoadTest)(Defaults.testSettings ++ Seq(sourceDirectory in LoadTest <<= (sourceDirectory in LoadTest)(_ / ".." / "test-load")))
+
+ lazy val root = Project(...)
+ .settings(ideaExtraTestConfigurations := Seq(LoadTest) :: Nil)
+ .configs( LoadTest )
+ .settings( loadTestSettings : _*)
+
+
TODO...
@@ -20,6 +20,7 @@ object SbtIdeaPlugin extends Plugin {
val ideaExcludeFolders = SettingKey[Seq[String]]("idea-exclude-folders")
val ideaExtraFacets = SettingKey[NodeSeq]("idea-extra-facets")
val ideaIncludeScalaFacet = SettingKey[Boolean]("idea-include-scala-facet")
+ val ideaExtraTestConfigurations = SettingKey[Seq[Configuration]]("idea-extra-test-configurations","Extra configurations to be included in test sources")
override lazy val settings = Seq(
Keys.commands += ideaCommand,
@@ -30,7 +31,8 @@ object SbtIdeaPlugin extends Plugin {
ideaJavadocsClassifiers <<= ideaJavadocsClassifiers ?? Seq("javadoc"),
ideaExcludeFolders <<= ideaExcludeFolders ?? Nil,
ideaExtraFacets <<= ideaExtraFacets ?? NodeSeq.Empty,
- ideaIncludeScalaFacet <<= ideaIncludeScalaFacet ?? true
+ ideaIncludeScalaFacet <<= ideaIncludeScalaFacet ?? true,
+ ideaExtraTestConfigurations <<= ideaExtraTestConfigurations ?? Seq()
)
private val NoClassifiers = "no-classifiers"
@@ -199,7 +201,14 @@ object SbtIdeaPlugin extends Plugin {
settings.setting(Keys.classDirectory in config, "Missing class directory!"))
}
val compileDirectories: Directories = directoriesFor(Configurations.Compile)
- val testDirectories: Directories = directoriesFor(Configurations.Test).addSrc(sourceDirectoriesFor(Configurations.IntegrationTest)).addRes(resourceDirectoriesFor(Configurations.IntegrationTest))
+
+ def appendExtraTestDirectories(directories: Directories) = {
+ val extraConfigurations = (Seq(Configurations.IntegrationTest) ++ settings.setting(ideaExtraTestConfigurations, "Missing extra test configuration"))
+ extraConfigurations.foldLeft(directories)((dirs,conf) =>
+ dirs.addSrc(sourceDirectoriesFor(conf)).addRes(resourceDirectoriesFor(conf))
+ )
+ }
+ val testDirectories: Directories = appendExtraTestDirectories(directoriesFor(Configurations.Test))
val librariesExtractor = new SbtIdeaModuleMapping.LibrariesExtractor(buildStruct, state, projectRef, scalaInstance,
withClassifiers = if (args.contains(NoClassifiers)) None else {
Some((settings.setting(ideaSourcesClassifiers, "Missing idea-sources-classifiers"), settings.setting(ideaJavadocsClassifiers, "Missing idea-javadocs-classifiers")))
@@ -0,0 +1,37 @@
+<module version="4" type="JAVA_MODULE">
+ <component name="FacetManager">
+ <facet name="Scala" type="scala">
+ <configuration>
+ <option name="compilerLibraryLevel" value="Project"></option>
+ <option name="compilerLibraryName" value="SBT: scala:2.10.2"></option>
+ <option name="languageLevel" value="Scala 2.10" />
+ <option name="fsc" value="true" />
+ <option name="compilerOptions" value=""/>
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../target/scala-2.10/classes"></output>
+ <output-test url="file://$MODULE_DIR$/../target/scala-2.10/test-classes"></output-test>
+ <exclude-output></exclude-output>
+ <content url="file://$MODULE_DIR$/../">
+ <sourceFolder url="file://$MODULE_DIR$/../src/main/scala" isTestSource="false"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/main/java" isTestSource="false"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/main/resources" isTestSource="false"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/test/scala" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/test/java" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/it/scala" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/it/java" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/test-load/scala" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/test-load/java" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/test/resources" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/it/resources" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../src/test-load/resources" isTestSource="true"></sourceFolder>
+ <excludeFolder url="file://$MODULE_DIR$/../target"></excludeFolder>
+ </content>
+ <orderEntry type="inheritedJdk"></orderEntry>
+ <orderEntry type="sourceFolder" forTests="false"></orderEntry>
+ <orderEntry level="project" name="SBT: org.scala-lang:scala-library:2.10.2" type="library"></orderEntry>
+ <orderEntry level="project" name="SBT: junit:junit:4.8.2" type="library"></orderEntry>
+ </component>
+</module>
@@ -0,0 +1,19 @@
+import org.sbtidea.test.util.AbstractScriptedTestBuild
+import sbt._
+import sbt.Keys._
+import org.sbtidea.SbtIdeaPlugin._
+
+object ScriptedTestBuild extends AbstractScriptedTestBuild("with-extra-tests") {
+ lazy val root = Project("main", file("."), settings = Defaults.defaultSettings ++ scriptedTestSettings ++ Seq(
+ libraryDependencies += "junit" % "junit" % "4.8.2",
+ ideaExtraTestConfigurations := Seq(LoadTest)
+ ))
+ .configs( IntegrationTest )
+ .settings( Defaults.itSettings : _*)
+ .configs( LoadTest)
+ .settings( loadTestSettings : _*)
+
+
+ lazy val LoadTest = config("test-load") extend Test
+ lazy val loadTestSettings : Seq[Setting[_]] = inConfig(LoadTest)(Defaults.testSettings ++ Seq(sourceDirectory in LoadTest <<= (sourceDirectory in LoadTest)(_ / ".." / "test-load")))
+}
@@ -0,0 +1,2 @@
+addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.7.0-SNAPSHOT")
+
@@ -0,0 +1,2 @@
+> gen-idea
+> assert-expected-xml-files

0 comments on commit 388b3e4

Please sign in to comment.