2018-04-22 23:13:32 +00:00
|
|
|
import sbtassembly.AssemblyPlugin.defaultShellScript
|
2018-04-24 04:18:21 +00:00
|
|
|
import sbt._
|
|
|
|
import Keys._
|
|
|
|
import sbt.io.IO
|
|
|
|
import java.io.File
|
2018-04-22 23:13:32 +00:00
|
|
|
|
|
|
|
lazy val i2pVersion = "0.9.34"
|
|
|
|
|
2018-05-02 03:39:14 +00:00
|
|
|
lazy val cleanAllTask = taskKey[Unit]("Clean up and remove the OSX bundle")
|
2018-04-24 04:18:21 +00:00
|
|
|
lazy val buildAppBundleTask = taskKey[Unit](s"Build an Mac OS X bundle for I2P ${i2pVersion}.")
|
|
|
|
lazy val bundleBuildPath = file("./output")
|
|
|
|
|
2018-05-01 02:54:36 +00:00
|
|
|
lazy val staticFiles = List(
|
|
|
|
"blocklist.txt",
|
|
|
|
"clients.config",
|
|
|
|
"continents.txt",
|
|
|
|
"countries.txt",
|
|
|
|
"hosts.txt",
|
|
|
|
"geoip.txt",
|
|
|
|
"router.config",
|
|
|
|
"webapps.config"
|
|
|
|
)
|
2018-04-24 04:18:21 +00:00
|
|
|
|
|
|
|
lazy val resDir = new File("./../installer/resources")
|
2018-05-02 03:39:14 +00:00
|
|
|
lazy val i2pBuildDir = new File("./../pkg-temp")
|
|
|
|
lazy val warsForCopy = new File(i2pBuildDir, "webapps").list.filter { f => f.endsWith(".war") }
|
|
|
|
lazy val jarsForCopy = new File(i2pBuildDir, "lib").list.filter { f => f.endsWith(".jar") }
|
|
|
|
|
|
|
|
|
|
|
|
def defaultOSXLauncherShellScript(javaOpts: Seq[String] = Seq.empty): Seq[String] = {
|
|
|
|
val javaOptsString = javaOpts.map(_ + " ").mkString
|
|
|
|
Seq(
|
|
|
|
"#!/usr/bin/env sh",
|
|
|
|
s"""
|
|
|
|
|echo "Yo"
|
|
|
|
|export I2P=$$HOME/Library/I2P
|
|
|
|
|for jar in `ls $${I2P}/lib/*.jar`; do
|
|
|
|
| if [ ! -z $$CP ]; then
|
|
|
|
| CP=$${CP}:$${jar};
|
|
|
|
| else
|
|
|
|
| CP=$${jar}
|
|
|
|
| fi
|
|
|
|
|done
|
|
|
|
|export CLASSPATH=$$CP
|
|
|
|
|exec java -jar $javaOptsString$$JAVA_OPTS "$$0" "$$@"""".stripMargin,
|
|
|
|
"")
|
|
|
|
}
|
2018-05-01 03:21:04 +00:00
|
|
|
|
|
|
|
// Pointing the resources directory to the "installer" directory
|
|
|
|
resourceDirectory in Compile := baseDirectory.value / ".." / ".." / "installer" / "resources"
|
|
|
|
|
2018-05-01 11:15:11 +00:00
|
|
|
// Unmanaged base will be included in a fat jar
|
2018-05-02 03:39:14 +00:00
|
|
|
unmanagedBase in Compile := baseDirectory.value / ".." / ".." / "pkg-temp" / "lib"
|
2018-05-01 11:15:11 +00:00
|
|
|
|
2018-05-01 03:21:04 +00:00
|
|
|
// Unmanaged classpath will be available at compile time
|
|
|
|
unmanagedClasspath in Compile ++= Seq(
|
2018-05-02 03:39:14 +00:00
|
|
|
baseDirectory.value / ".." / ".." / "pkg-temp" / "lib" / "*.jar"
|
|
|
|
)
|
|
|
|
|
|
|
|
assemblyOption in assembly := (assemblyOption in assembly).value.copy(
|
|
|
|
prependShellScript = Some(defaultOSXLauncherShellScript(
|
|
|
|
Seq(
|
|
|
|
"-Xmx512M",
|
|
|
|
"-Xms128m",
|
|
|
|
"-Dwrapper.logfile=/tmp/router.log",
|
|
|
|
"-Dwrapper.logfile.loglevel=DEBUG",
|
|
|
|
"-Dwrapper.java.pidfile=/tmp/routerjvm.pid",
|
|
|
|
"-Dwrapper.console.loglevel=DEBUG",
|
|
|
|
"-Djava.awt.headless=true",
|
|
|
|
"-Di2p.dir.base=$I2P",
|
|
|
|
"-Djava.library.path=$I2P"
|
|
|
|
)))
|
2018-05-01 03:21:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-01 11:15:11 +00:00
|
|
|
assemblyJarName in assembly := s"OSXLauncher"
|
2018-05-01 03:21:04 +00:00
|
|
|
|
2018-05-02 03:39:14 +00:00
|
|
|
assemblyExcludedJars in assembly := {
|
|
|
|
val cp = (fullClasspath in assembly).value
|
|
|
|
cp filter { c => jarsForCopy.toList.contains(c.data.getName) }
|
|
|
|
}
|
2018-05-01 03:21:04 +00:00
|
|
|
|
|
|
|
// TODO: MEEH: Add assemblyExcludedJars and load the router from own jar files, to handle upgrades better.
|
|
|
|
// In fact, most likely the bundle never would need an update except for the router jars/wars.
|
|
|
|
|
2018-04-24 05:01:25 +00:00
|
|
|
convertToICNSTask := {
|
|
|
|
println("TODO")
|
|
|
|
}
|
|
|
|
|
2018-05-02 03:39:14 +00:00
|
|
|
cleanAllTask := {
|
|
|
|
clean.value
|
|
|
|
IO.delete(bundleBuildPath)
|
|
|
|
}
|
|
|
|
|
2018-04-24 04:18:21 +00:00
|
|
|
buildAppBundleTask := {
|
|
|
|
println(s"Building Mac OS X bundle for I2P version ${i2pVersion}.")
|
|
|
|
bundleBuildPath.mkdir()
|
|
|
|
val paths = Map[String,File](
|
|
|
|
"execBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/MacOS"),
|
2018-05-01 03:21:04 +00:00
|
|
|
"resBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources"),
|
|
|
|
"i2pbaseBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase"),
|
2018-04-24 04:18:21 +00:00
|
|
|
"i2pJarsBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase/lib"),
|
2018-05-01 03:21:04 +00:00
|
|
|
"webappsBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase/webapps")
|
2018-04-24 04:18:21 +00:00
|
|
|
)
|
|
|
|
paths.map { case (s,p) => p.mkdirs() }
|
|
|
|
val dirsToCopy = List("certificates","locale","man")
|
2018-05-01 02:54:36 +00:00
|
|
|
|
2018-05-01 11:15:11 +00:00
|
|
|
val launcherBinary = Some(assembly.value)
|
|
|
|
launcherBinary.map { l => IO.copyFile( new File(l.toString), new File(paths.get("execBundlePath").get, "I2P") ) }
|
|
|
|
|
|
|
|
|
2018-05-01 02:54:36 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* First of, if "map" is unknown for you - shame on you :p
|
|
|
|
*
|
|
|
|
* It's a loop basically where it loops through a list/array
|
|
|
|
* with the current indexed item as subject.
|
|
|
|
*
|
|
|
|
* The code bellow takes the different lists and
|
|
|
|
* copy all the directories or files from the i2p.i2p build dir,
|
|
|
|
* and into the bundle so the launcher will know where to find i2p.
|
|
|
|
*
|
|
|
|
*/
|
2018-05-02 03:39:14 +00:00
|
|
|
dirsToCopy.map { d => IO.copyDirectory( new File(resDir, d), new File(paths.get("i2pbaseBunldePath").get, d) ) }
|
|
|
|
warsForCopy.map { w => IO.copyFile( new File(new File(i2pBuildDir, "webapps"), w), new File(paths.get("webappsBunldePath").get, w) ) }
|
|
|
|
jarsForCopy.map { j => IO.copyFile( new File(new File(i2pBuildDir, "lib"), j), new File(paths.get("i2pJarsBunldePath").get, j) ) }
|
2018-04-24 04:18:21 +00:00
|
|
|
}
|