Changeset 70e994fc for launchers/macosx


Ignore:
Timestamp:
May 2, 2018 3:39:14 AM (2 years ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
1c677cd
Parents:
c326bb7
Message:

Some changes, after much testing I find it best to spawn an sub java
process for I2P rather than trying to load Router via reflection or
anything runtime fancy stuff. Shell script is implemented in SBT now,
and can now link to download JRE script and so on.

Location:
launchers/macosx
Files:
1 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • launchers/macosx/build.sbt

    rc326bb7 r70e994fc  
    77lazy val i2pVersion = "0.9.34"
    88
     9lazy val cleanAllTask = taskKey[Unit]("Clean up and remove the OSX bundle")
    910lazy val buildAppBundleTask = taskKey[Unit](s"Build an Mac OS X bundle for I2P ${i2pVersion}.")
    1011lazy val bundleBuildPath = file("./output")
     
    2223
    2324lazy 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") }
     25lazy val i2pBuildDir = new File("./../pkg-temp")
     26lazy val warsForCopy = new File(i2pBuildDir, "webapps").list.filter { f => f.endsWith(".war") }
     27lazy val jarsForCopy = new File(i2pBuildDir, "lib").list.filter { f => f.endsWith(".jar") }
    2728
    2829
    29 
     30def defaultOSXLauncherShellScript(javaOpts: Seq[String] = Seq.empty): Seq[String] = {
     31  val javaOptsString = javaOpts.map(_ + " ").mkString
     32  Seq(
     33    "#!/usr/bin/env sh",
     34    s"""
     35       |echo "Yo"
     36       |export I2P=$$HOME/Library/I2P
     37       |for jar in `ls $${I2P}/lib/*.jar`; do
     38       |  if [ ! -z $$CP ]; then
     39       |      CP=$${CP}:$${jar};
     40       |  else
     41       |      CP=$${jar}
     42       |  fi
     43       |done
     44       |export CLASSPATH=$$CP
     45       |exec java -jar $javaOptsString$$JAVA_OPTS "$$0" "$$@"""".stripMargin,
     46    "")
     47}
    3048
    3149// Pointing the resources directory to the "installer" directory
     
    3351
    3452// Unmanaged base will be included in a fat jar
    35 unmanagedBase in Compile := baseDirectory.value / ".." / ".." / "build"
     53unmanagedBase in Compile := baseDirectory.value / ".." / ".." / "pkg-temp" / "lib"
    3654
    3755// Unmanaged classpath will be available at compile time
    3856unmanagedClasspath in Compile ++= Seq(
    39   baseDirectory.value / ".." / ".." / "build" / "*.jar"
     57  baseDirectory.value / ".." / ".." / "pkg-temp" / "lib" / "*.jar"
    4058)
    4159
    42 //assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript))
     60assemblyOption in assembly := (assemblyOption in assembly).value.copy(
     61  prependShellScript = Some(defaultOSXLauncherShellScript(
     62    Seq(
     63      "-Xmx512M",
     64      "-Xms128m",
     65      "-Dwrapper.logfile=/tmp/router.log",
     66      "-Dwrapper.logfile.loglevel=DEBUG",
     67      "-Dwrapper.java.pidfile=/tmp/routerjvm.pid",
     68      "-Dwrapper.console.loglevel=DEBUG",
     69      "-Djava.awt.headless=true",
     70      "-Di2p.dir.base=$I2P",
     71      "-Djava.library.path=$I2P"
     72    )))
     73)
     74
    4375
    4476assemblyJarName in assembly := s"OSXLauncher"
    4577
     78assemblyExcludedJars in assembly := {
     79  val cp = (fullClasspath in assembly).value
     80  cp filter { c => jarsForCopy.toList.contains(c.data.getName) }
     81}
    4682
    4783// TODO: MEEH: Add assemblyExcludedJars and load the router from own jar files, to handle upgrades better.
     
    5086convertToICNSTask := {
    5187  println("TODO")
     88}
     89
     90cleanAllTask := {
     91  clean.value
     92  IO.delete(bundleBuildPath)
    5293}
    5394
     
    81122    *
    82123    */
    83   dirsToCopy.map { d => IO.copyDirectory( new File(resDir, d), new File(paths.get("i2pbaseBunldePath").get, d) ) }
    84   warsForCopy.map { w => IO.copyFile( new File(i2pBuildDir, w), new File(paths.get("webappsBunldePath").get, w) ) }
    85   jarsForCopy.map { j => IO.copyFile( new File(i2pBuildDir, j), new File(paths.get("i2pJarsBunldePath").get, j) ) }
     124  dirsToCopy.map  { d => IO.copyDirectory( new File(resDir, d), new File(paths.get("i2pbaseBunldePath").get, d) ) }
     125  warsForCopy.map { w => IO.copyFile( new File(new File(i2pBuildDir, "webapps"), w), new File(paths.get("webappsBunldePath").get, w) ) }
     126  jarsForCopy.map { j => IO.copyFile( new File(new File(i2pBuildDir, "lib"), j), new File(paths.get("i2pJarsBunldePath").get, j) ) }
    86127}
  • launchers/macosx/src/main/scala/net/i2p/launchers/osx/LauncherAppMain.scala

    rc326bb7 r70e994fc  
    1 package net.i2p
     1package net.i2p.launchers.osx
    22
    33import java.io.File
    44
    5 import collection.JavaConverters._
    6 import net.i2p.launchers.{OSXDefaults, OSXDeployment}
     5import net.i2p.launchers.{DeployProfile, OSXDefaults, OSXDeployment}
    76
    87/**
     
    3433  * @since 0.9.35
    3534  */
    36 object MacOSXRouterLauncherApp extends App {
     35object LauncherAppMain extends App {
    3736
    3837  val i2pBaseDir = OSXDefaults.getOSXBaseDirectory
    39 
    4038
    4139  new OSXDeployment()
     
    4442  System.setProperty("user.dir", i2pBaseDir.getAbsolutePath)
    4543
    46   val i2pJarDir = new File(i2pBaseDir.getAbsolutePath, "lib")
    47   i2pJarDir.list().toList.map { jar => {
    48     val jarFile = new File(i2pJarDir, jar)
    49     println(s"Loading jar: ${jarFile.toURI.toURL} => ${MacOSXRouterLauncher.addJarToClassPath(jarFile.toURI.toURL)}")
    50 
    51   } }
    52 
    53   MacOSXRouterLauncher.runRouter(args)
    54   //net.i2p.Router.main(args)
     44  try {
     45    MacOSXRouterLauncher.runRouter(i2pBaseDir, args)
     46  } finally {
     47    System.out.println("Exit.")
     48  }
    5549}
Note: See TracChangeset for help on using the changeset viewer.