-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support sbt 1.0 #107
Merged
Merged
support sbt 1.0 #107
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,28 +12,39 @@ licenses += ("BSD 3-Clause", url("http://opensource.org/licenses/BSD-3-Clause")) | |
scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt-site"), "git@github.com:sbt/sbt-site.git")) | ||
//#scm-info | ||
|
||
scalaVersion := "2.10.6" | ||
|
||
scalaVersion in Global := "2.10.6" | ||
|
||
scalacOptions ++= Seq("-deprecation", "-unchecked") | ||
|
||
resolvers += Resolver.sonatypeRepo("releases") | ||
|
||
val unfilteredVersion = "0.9.1" | ||
|
||
libraryDependencies ++= Seq( | ||
"net.databinder" %% "unfiltered-directives" % "0.8.4", | ||
"net.databinder" %% "unfiltered-filter" % "0.8.4", | ||
"net.databinder" %% "unfiltered-jetty" % "0.8.4", | ||
"net.databinder" %% "unfiltered-specs2" % "0.8.4" % "test", | ||
"ws.unfiltered" %% "unfiltered-directives" % unfilteredVersion, | ||
"ws.unfiltered" %% "unfiltered-filter" % unfilteredVersion, | ||
"ws.unfiltered" %% "unfiltered-jetty" % unfilteredVersion, | ||
"ws.unfiltered" %% "unfiltered-specs2" % unfilteredVersion % "test", | ||
"org.foundweekends" %% "pamflet-library" % "0.7.1", | ||
"org.yaml" % "snakeyaml" % "1.13", | ||
"com.typesafe" % "config" % "1.2.1", // Last version to support Java 1.6 | ||
"org.asciidoctor" % "asciidoctorj" % "1.5.4" | ||
) | ||
|
||
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.2.13") | ||
|
||
addSbtPlugin("org.planet42" % "laika-sbt" % "0.7.0") | ||
libraryDependencies ++= { | ||
if((sbtVersion in pluginCrossBuild).value.startsWith("0.13")) { | ||
Seq( | ||
Defaults.sbtPluginExtra( | ||
"com.lightbend.paradox" % "sbt-paradox" % "0.2.13", | ||
(sbtBinaryVersion in pluginCrossBuild).value, | ||
(scalaBinaryVersion in pluginCrossBuild).value | ||
), | ||
Defaults.sbtPluginExtra( | ||
"org.planet42" % "laika-sbt" % "0.7.0", | ||
(sbtBinaryVersion in pluginCrossBuild).value, | ||
(scalaBinaryVersion in pluginCrossBuild).value | ||
) | ||
) | ||
} else Nil | ||
} | ||
|
||
enablePlugins(ParadoxSitePlugin) | ||
sourceDirectory in Paradox := sourceDirectory.value / "main" / "paradox" | ||
|
@@ -50,6 +61,38 @@ git.remoteRepo := scmInfo.value.get.connection | |
|
||
scriptedSettings | ||
|
||
TaskKey[Unit]("runScriptedTest") := Def.taskDyn { | ||
if((sbtVersion in pluginCrossBuild).value.startsWith("0.13")) { | ||
Def.task{ | ||
scripted.toTask("").value | ||
} | ||
} else { | ||
case class Test(group: String, name: Option[String]) | ||
|
||
val exclude = Seq( | ||
Test("paradox", None), // paradox does not support sbt 1.0 | ||
Test("laika", None), // https://github.com/planet42/Laika/issues/57 | ||
Test("site", Some("can-run-generator-twice")), // use paradox | ||
Test("site", Some("plays-nice-with-tut")), // use paradox | ||
Test("site", Some("plays-nice-with-ghpages")) // https://github.com/sbt/sbt-ghpages/issues/36 | ||
) | ||
|
||
val groups = file("src/sbt-test").listFiles.map(_.getName).toList | ||
val runAll: Seq[String] = groups.filterNot(exclude.map(_.group).toSet).map(_ + "/*") | ||
val runPartial: Seq[String] = exclude.collect{ case Test(g, Some(t)) => (g, t) }.groupBy(_._1).flatMap { | ||
case (g, tests) => | ||
val excludeTests = tests.map(_._2).toSet | ||
(file("src/sbt-test") / g).listFiles.map(_.getName).filterNot(excludeTests).map(g + "/" + _) | ||
}.toList | ||
val args = (runAll ++ runPartial).mkString(" ", " ", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really nice, I didn't know this was possible. |
||
streams.value.log.info("scripted test args =" + args) | ||
|
||
Def.task{ | ||
scripted.toTask(args).value | ||
} | ||
} | ||
}.value | ||
|
||
scriptedLaunchOpts += "-Dproject.version="+version.value | ||
|
||
// scriptedBufferLog := false |
31 changes: 31 additions & 0 deletions
31
src/main/scala-sbt-0.13/com/typesafe/sbt/site/Compat.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.typesafe.sbt.site | ||
|
||
import sbt._ | ||
import sbt.Keys._ | ||
import sbt.FilesInfo.Style | ||
|
||
object Compat { | ||
|
||
type Process = sbt.Process | ||
val Process = sbt.Process | ||
type ProcessLogger = sbt.ProcessLogger | ||
|
||
def cached(cacheBaseDirectory: File, inStyle: Style, outStyle: Style)(action: (ChangeReport[File], ChangeReport[File]) => Set[File]): Set[File] => Set[File] = | ||
FileFunction.cached(cacheBaseDirectory = cacheBaseDirectory)(inStyle = inStyle, outStyle = outStyle)(action = action) | ||
|
||
val genSources = (s: State) => { | ||
Preview.runTask(watchSources, s) | ||
} | ||
|
||
def watchSettings(config: Configuration): Seq[Setting[_]] = | ||
Seq( | ||
watchSources in Global ++= (sourceDirectory in config).value.***.get | ||
) | ||
|
||
def CacheStore(file: File) = file | ||
|
||
implicit class FileOps(file: File) { | ||
def allPaths = file.*** | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.typesafe.sbt.site | ||
|
||
import java.nio.file.Files | ||
|
||
import sbt._ | ||
import sbt.Keys._ | ||
import sbt.util.CacheStoreFactory | ||
import FileInfo.Style | ||
import sbt.internal.io.Source | ||
|
||
object Compat { | ||
|
||
type Process = scala.sys.process.Process | ||
val Process = scala.sys.process.Process | ||
type ProcessLogger = scala.sys.process.ProcessLogger | ||
|
||
def cached(cacheBaseDirectory: File, inStyle: Style, outStyle: Style)(action: (ChangeReport[File], ChangeReport[File]) => Set[File]): Set[File] => Set[File] = | ||
sbt.util.FileFunction.cached(CacheStoreFactory(cacheBaseDirectory), inStyle = inStyle, outStyle = outStyle)(action = action) | ||
|
||
val genSources: State => Seq[File] = { | ||
import scala.collection.JavaConverters._ | ||
|
||
def sourceField[A](name: String): Source => A = { | ||
val f = classOf[Source].getDeclaredField(name) | ||
f.setAccessible(true) | ||
src => f.get(src).asInstanceOf[A] | ||
} | ||
|
||
val baseField = sourceField[File]("base") | ||
val includeField = sourceField[FileFilter]("includeFilter") | ||
val excludeField = sourceField[FileFilter]("excludeFilter") | ||
|
||
(s: State) => Preview.runTask(watchSources, s).flatMap { src => | ||
val base = baseField(src) | ||
val include = includeField(src) | ||
val exclude = excludeField(src) | ||
|
||
Files.find( | ||
base.toPath, | ||
64, | ||
(f, _) => include.accept(f.toFile) && !exclude.accept(f.toFile) | ||
).iterator().asScala.map(_.toFile).toList | ||
} | ||
} | ||
|
||
def watchSettings(config: Configuration): Seq[Setting[_]] = | ||
Seq( | ||
watchSources in Global += new Source( | ||
base = (sourceDirectory in config).value, | ||
includeFilter = (includeFilter in config).value, | ||
excludeFilter = (excludeFilter in config).value | ||
) | ||
) | ||
|
||
val CacheStore = sbt.util.CacheStore | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.typesafe.sbt.site.sphinx | ||
|
||
import com.typesafe.sbt.site.Compat._ | ||
import com.typesafe.sbt.site.SitePlugin.autoImport.siteSubdirName | ||
import com.typesafe.sbt.site.SitePlugin | ||
import com.typesafe.sbt.site.util.SiteHelpers | ||
|
@@ -56,15 +57,16 @@ object SphinxPlugin extends AutoPlugin { | |
} | ||
|
||
def defaultVersionProperties(version: String) = { | ||
val binV = CrossVersion.binaryVersion(version, "") | ||
val binV = CrossVersion.binarySbtVersion(version) | ||
Map("version" -> binV, "release" -> version) | ||
} | ||
|
||
def installPackagesTask = Def.task { | ||
val runner = sphinxRunner.value | ||
val packages = sphinxPackages.value | ||
val s = streams.value | ||
packages map { p => runner.installPackage(p, target.value, s.log) } | ||
val t = target.value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
packages map { p => runner.installPackage(p, t, s.log) } | ||
} | ||
|
||
def combineSphinxInputs = Def.task { | ||
|
@@ -112,8 +114,9 @@ object SphinxPlugin extends AutoPlugin { | |
key: TaskKey[S], | ||
f: Task[S] => Task[T], | ||
nil: T): Def.Initialize[Task[T]] = Def.task{ | ||
if ((enableOutput in key in key.scope).value) f(key.taskValue) else task {nil} | ||
}.flatMap(identity) | ||
val t = key.taskValue | ||
if ((enableOutput in key in key.scope).value) f(t) else task {nil} | ||
}.flatMap(identity(_)) | ||
|
||
def generateTask = Def.task { | ||
val htmlOutput = generatedHtml.value | ||
|
@@ -131,7 +134,7 @@ object SphinxPlugin extends AutoPlugin { | |
(epub ** "*.epub").get pair Path.rebase(epub, t) | ||
} | ||
val mapping = htmlMapping ++ pdfMapping ++ epubMapping | ||
Sync(cache)(mapping) | ||
Sync(CacheStore(cache))(mapping) | ||
s.log.info("Sphinx documentation generated: %s" format t) | ||
t | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.typesafe.sbt.site.util | ||
|
||
import com.typesafe.sbt.site.Compat.Process | ||
import sbt.Keys._ | ||
import sbt._ | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Laika and Paradox are fairly new additions.