Skip to content

Commit

Permalink
moved helper functions to a separate script
Browse files Browse the repository at this point in the history
  • Loading branch information
mausch committed Nov 9, 2010
1 parent 237e7b4 commit fe98fe8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
27 changes: 1 addition & 26 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,17 @@
#r "FakeLib.dll"
#r "Fake.Gallio.dll"
#r "System.Xml.Linq"
#load "fake.fsx"

open System
open System.Xml.Linq
open Fake

let version = "0.3.0"
let solr = "solr-1.4.0"
let buildDir = "merged"
let config = getBuildParamOrDefault "config" "debug"
let target = getBuildParamOrDefault "target" "BuildAll"

// helper functions
let (.>) (a: #seq<XElement>) (b: string) = Extensions.Descendants(a, xname b)
let startsWith s (n: XElement) = n.Value.StartsWith s
let contains s (n: XElement) = n.Value.Contains s
let setValue s (n: XElement) = n.Value <- s
let replaceValue orig repl (n: XElement) = n.Value <- n.Value.Replace((orig:string), (repl:string))
let httpGet = Fake.REST.ExecuteGetCommand null null

module Solr =
let private cmdline = "-DSTOP.PORT=8079 -DSTOP.KEY=secret -jar start.jar"
let private execParam cmd =
{ WorkingDirectory = solr
Program = "java"
CommandLine = cmdline + " " + cmd
Args = [] }
let start() =
asyncShellExec (execParam "") |> Async.StartAsTask |> ignore
let watch = System.Diagnostics.Stopwatch.StartNew()
while httpGet "http://localhost:8983/solr/admin/ping" = null do
if watch.Elapsed > (TimeSpan.FromSeconds 10.)
then failwith "Solr test instance didn't work"
System.Threading.Thread.Sleep 500
let stop() =
shellExec (execParam "--stop") |> ignore

let slnBuild sln x =
sln |> build (fun p -> { p with
Targets = [x]
Expand Down
34 changes: 34 additions & 0 deletions fake.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#I @"lib"
#r "FakeLib.dll"
#r "System.Xml.Linq"

open System
open System.Xml.Linq
open Fake

let solr = "solr-1.4.0"

// helper functions
let (.>) (a: #seq<XElement>) (b: string) = Extensions.Descendants(a, xname b)
let startsWith s (n: XElement) = n.Value.StartsWith s
let contains s (n: XElement) = n.Value.Contains s
let setValue s (n: XElement) = n.Value <- s
let replaceValue orig repl (n: XElement) = n.Value <- n.Value.Replace((orig:string), (repl:string))
let httpGet = Fake.REST.ExecuteGetCommand null null

module Solr =
let private cmdline = "-DSTOP.PORT=8079 -DSTOP.KEY=secret -jar start.jar"
let private execParam cmd =
{ WorkingDirectory = solr
Program = "java"
CommandLine = cmdline + " " + cmd
Args = [] }
let start() =
asyncShellExec (execParam "") |> Async.StartAsTask |> ignore
let watch = System.Diagnostics.Stopwatch.StartNew()
while httpGet "http://localhost:8983/solr/admin/ping" = null do
if watch.Elapsed > (TimeSpan.FromSeconds 10.)
then failwith "Solr test instance didn't work"
System.Threading.Thread.Sleep 500
let stop() =
shellExec (execParam "--stop") |> ignore

0 comments on commit fe98fe8

Please sign in to comment.