1 | import sbtassembly.AssemblyPlugin.defaultShellScript |
---|
2 | import sbt._ |
---|
3 | import Keys._ |
---|
4 | import sbt.io.IO |
---|
5 | import java.io.File |
---|
6 | |
---|
7 | lazy val i2pVersion = "0.9.34" |
---|
8 | |
---|
9 | lazy val buildAppBundleTask = taskKey[Unit](s"Build an Mac OS X bundle for I2P ${i2pVersion}.") |
---|
10 | lazy val bundleBuildPath = file("./output") |
---|
11 | |
---|
12 | lazy val staticFiles = List( |
---|
13 | "blocklist.txt", |
---|
14 | "clients.config", |
---|
15 | "continents.txt", |
---|
16 | "countries.txt", |
---|
17 | "hosts.txt", |
---|
18 | "geoip.txt", |
---|
19 | "router.config", |
---|
20 | "webapps.config" |
---|
21 | ) |
---|
22 | |
---|
23 | lazy val resDir = new File("./../installer/resources") |
---|
24 | lazy val i2pBuildDir = new File("./../build") |
---|
25 | lazy val warsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".war") } |
---|
26 | lazy val jarsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".jar") } |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | // Pointing the resources directory to the "installer" directory |
---|
32 | resourceDirectory in Compile := baseDirectory.value / ".." / ".." / "installer" / "resources" |
---|
33 | |
---|
34 | // Unmanaged classpath will be available at compile time |
---|
35 | unmanagedClasspath in Compile ++= Seq( |
---|
36 | baseDirectory.value / ".." / ".." / "build" / "*.jar", |
---|
37 | baseDirectory.value / ".." / ".." / "router" / "java" / "src" |
---|
38 | ) |
---|
39 | |
---|
40 | // Please note the difference between browserbundle, this has |
---|
41 | // the "in Compile" which limit it's scope to that. |
---|
42 | //unmanagedBase in Compile := baseDirectory.value / ".." / ".." / "build" |
---|
43 | |
---|
44 | libraryDependencies ++= Seq( |
---|
45 | "net.i2p" % "router" % i2pVersion % Compile |
---|
46 | ) |
---|
47 | |
---|
48 | |
---|
49 | //assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript)) |
---|
50 | |
---|
51 | assemblyJarName in assembly := s"${name.value}-${version.value}" |
---|
52 | |
---|
53 | |
---|
54 | // TODO: MEEH: Add assemblyExcludedJars and load the router from own jar files, to handle upgrades better. |
---|
55 | // In fact, most likely the bundle never would need an update except for the router jars/wars. |
---|
56 | |
---|
57 | convertToICNSTask := { |
---|
58 | println("TODO") |
---|
59 | } |
---|
60 | |
---|
61 | buildAppBundleTask := { |
---|
62 | println(s"Building Mac OS X bundle for I2P version ${i2pVersion}.") |
---|
63 | bundleBuildPath.mkdir() |
---|
64 | val paths = Map[String,File]( |
---|
65 | "execBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/MacOS"), |
---|
66 | "resBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources"), |
---|
67 | "i2pbaseBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase"), |
---|
68 | "i2pJarsBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase/lib"), |
---|
69 | "webappsBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase/webapps") |
---|
70 | ) |
---|
71 | paths.map { case (s,p) => p.mkdirs() } |
---|
72 | val dirsToCopy = List("certificates","locale","man") |
---|
73 | |
---|
74 | /** |
---|
75 | * |
---|
76 | * First of, if "map" is unknown for you - shame on you :p |
---|
77 | * |
---|
78 | * It's a loop basically where it loops through a list/array |
---|
79 | * with the current indexed item as subject. |
---|
80 | * |
---|
81 | * The code bellow takes the different lists and |
---|
82 | * copy all the directories or files from the i2p.i2p build dir, |
---|
83 | * and into the bundle so the launcher will know where to find i2p. |
---|
84 | * |
---|
85 | */ |
---|
86 | dirsToCopy.map { d => IO.copyDirectory( new File(resDir, d), new File(paths.get("i2pbaseBunldePath").get, d) ) } |
---|
87 | warsForCopy.map { w => IO.copyFile( new File(i2pBuildDir, w), new File(paths.get("webappsBunldePath").get, w) ) } |
---|
88 | warsForCopy.map { j => IO.copyFile( new File(i2pBuildDir, j), new File(paths.get("i2pJarsBunldePath").get, j) ) } |
---|
89 | } |
---|