source: launchers/macosx/build.sbt @ 6d0f80f

Last change on this file since 6d0f80f was 6d0f80f, checked in by meeh <meeh@…>, 2 years ago

Fixed a load of issues related to my "sync" approach, and Mac OSX's "async" API.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1import java.io.{File, FileNotFoundException, FileOutputStream}
2import java.util.zip._
3
4lazy val i2pVersion = "0.9.35"
5
6lazy val cleanAllTask = taskKey[Unit]("Clean up and remove the OSX bundle")
7lazy val buildAppBundleTask = taskKey[Unit](s"Build an Mac OS X bundle for I2P ${i2pVersion}.")
8lazy val buildDeployZipTask = taskKey[String](s"Build an zipfile with base directory for I2P ${i2pVersion}.")
9lazy val bundleBuildPath = new File("./output")
10
11
12lazy val resDir = new File("./../installer/resources")
13lazy val i2pBuildDir = new File("./../pkg-temp")
14lazy val warsForCopy = new File(i2pBuildDir, "webapps").list.filter { f => f.endsWith(".war") }
15lazy val jarsForCopy = new File(i2pBuildDir, "lib").list.filter { f => f.endsWith(".jar") }
16
17
18// Pointing the resources directory to the "installer" directory
19resourceDirectory in Compile := baseDirectory.value / ".." / ".." / "installer" / "resources"
20
21// Unmanaged base will be included in a fat jar
22unmanagedBase in Compile := baseDirectory.value / ".." / ".." / "pkg-temp" / "lib"
23
24
25// Unmanaged classpath will be available at compile time
26unmanagedClasspath in Compile ++= Seq(
27    baseDirectory.value / ".." / ".." / "pkg-temp" / "lib" / "*.jar"
28)
29
30assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false, includeDependency = false)
31
32assemblyExcludedJars in assembly := {
33    val cp = (fullClasspath in assembly).value
34    cp filter { c => jarsForCopy.toList.contains(c.data.getName) }
35}
36
37/*
38
39assemblyJarName in assembly := s"package.jar"
40
41// TODO: MEEH: Add assemblyExcludedJars and load the router from own jar files, to handle upgrades better.
42// In fact, most likely the bundle never would need an update except for the router jars/wars.
43
44convertToICNSTask := {
45  println("TODO")
46}
47
48cleanAllTask := {
49  clean.value
50  IO.delete(bundleBuildPath)
51}
52
53buildDeployZipTask := {
54  println(s"Starting the zip file build process. This might take a while..")
55  if (!bundleBuildPath.exists()) bundleBuildPath.mkdir()
56  val sourceDir = i2pBuildDir
57  def recursiveListFiles(f: File): Array[File] = {
58    val these = f.listFiles
59    these ++ these.filter { f => f.isDirectory }.flatMap(recursiveListFiles).filter(!_.isDirectory)
60  }
61  def zip(out: String, files: Iterable[String]) = {
62    import java.io.{ BufferedInputStream, FileInputStream, FileOutputStream }
63    import java.util.zip.{ ZipEntry, ZipOutputStream }
64
65    val zip = new ZipOutputStream(new FileOutputStream(out))
66
67    files.foreach { name =>
68      val fname = sourceDir.toURI.relativize(new File(name).toURI).toString
69      //println(s"Zipping ${fname}")
70      if (!new File(name).isDirectory) {
71        zip.putNextEntry(new ZipEntry(fname))
72        val in = new BufferedInputStream(new FileInputStream(name))
73        var b = in.read()
74        while (b > -1) {
75          zip.write(b)
76          b = in.read()
77        }
78        in.close()
79        zip.closeEntry()
80      }
81    }
82    zip.close()
83  }
84  val fileList = recursiveListFiles(sourceDir.getCanonicalFile).toList
85  val zipFileName = new File(bundleBuildPath, "i2pbase.zip").getCanonicalPath
86  zip(zipFileName, fileList.map { f => f.toString }.toIterable)
87  zipFileName.toString
88}
89
90buildAppBundleTask := {
91  println(s"Building Mac OS X bundle for I2P version ${i2pVersion}.")
92  if (!bundleBuildPath.exists()) bundleBuildPath.mkdir()
93  val paths = Map[String,File](
94    "execBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/MacOS"),
95    "resBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources")
96  )
97  paths.map { case (s,p) => p.mkdirs() }
98
99  val launcherBinary = Some(assembly.value)
100  launcherBinary.map { l => IO.copyFile( new File(l.toString), new File(paths.get("execBundlePath").get, "I2P") ) }
101
102  val zipFilePath = Some(buildDeployZipTask.value)
103
104  val zipFileOrigin = new File(zipFilePath.get)
105  IO.copyFile(zipFileOrigin, new File(paths.get("resBundlePath").get, "i2pbase.zip"))
106  println(s"Zip placed into bundle :)")
107
108}
109*/
Note: See TracBrowser for help on using the repository browser.