From 8c10ec9db3b55a0d8af4c90c3bceb46f690fb150 Mon Sep 17 00:00:00 2001 From: meeh Date: Sun, 22 Apr 2018 23:13:32 +0000 Subject: [PATCH] Realised a better way to handle the build process of both the Browser Bundle i2p launcher, as well as the upcoming Mac OS X i2p launcher. They share some few properties and how code has to be managed for both system's update managers and so on. More details will be documentated in README.md files as well as in those commit messages I now write :) --- build.xml | 22 +++++++++ launcher/README.md | 9 ---- launcher/build.sbt | 46 ------------------- launchers/README.md | 11 +++++ launchers/browserbundle/README.md | 5 ++ launchers/browserbundle/build.sbt | 26 +++++++++++ .../src/main/resources/blocklist.txt | 0 .../src/main/resources/clients.config | 0 .../src/main/resources/continents.txt | 0 .../src/main/resources/countries.txt | 0 .../src/main/resources/geoip.txt | 0 .../src/main/resources/hosts.txt | 0 .../src/main/resources/i2ptunnel.config | 0 .../src/main/resources/logger.config | 0 .../src/main/resources/router.config | 0 .../src/main/resources/webapps.config | 0 .../main/scala/net/i2p/DeployProfile.scala | 0 .../scala/net/i2p/RouterLauncherApp.scala | 0 launchers/build.sbt | 44 ++++++++++++++++++ launchers/macosx/README.md | 8 ++++ launchers/macosx/build.sbt | 22 +++++++++ .../net/i2p/MacOSXRouterLauncherApp.scala | 28 +++++++++++ .../project/build.properties | 0 {launcher => launchers}/project/plugins.sbt | 0 {launcher => launchers}/sbt | 0 25 files changed, 166 insertions(+), 55 deletions(-) delete mode 100644 launcher/README.md delete mode 100644 launcher/build.sbt create mode 100644 launchers/README.md create mode 100644 launchers/browserbundle/README.md create mode 100644 launchers/browserbundle/build.sbt rename {launcher => launchers/browserbundle}/src/main/resources/blocklist.txt (100%) rename {launcher => launchers/browserbundle}/src/main/resources/clients.config (100%) rename {launcher => launchers/browserbundle}/src/main/resources/continents.txt (100%) rename {launcher => launchers/browserbundle}/src/main/resources/countries.txt (100%) rename {launcher => launchers/browserbundle}/src/main/resources/geoip.txt (100%) rename {launcher => launchers/browserbundle}/src/main/resources/hosts.txt (100%) rename {launcher => launchers/browserbundle}/src/main/resources/i2ptunnel.config (100%) rename {launcher => launchers/browserbundle}/src/main/resources/logger.config (100%) rename {launcher => launchers/browserbundle}/src/main/resources/router.config (100%) rename {launcher => launchers/browserbundle}/src/main/resources/webapps.config (100%) rename {launcher => launchers/browserbundle}/src/main/scala/net/i2p/DeployProfile.scala (100%) rename {launcher => launchers/browserbundle}/src/main/scala/net/i2p/RouterLauncherApp.scala (100%) create mode 100644 launchers/build.sbt create mode 100644 launchers/macosx/README.md create mode 100644 launchers/macosx/build.sbt create mode 100644 launchers/macosx/src/main/scala/net/i2p/MacOSXRouterLauncherApp.scala rename {launcher => launchers}/project/build.properties (100%) rename {launcher => launchers}/project/plugins.sbt (100%) rename {launcher => launchers}/sbt (100%) diff --git a/build.xml b/build.xml index 2d785ae096..6d24ed4ffa 100644 --- a/build.xml +++ b/build.xml @@ -297,6 +297,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/README.md b/launcher/README.md deleted file mode 100644 index 58c8222afb..0000000000 --- a/launcher/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# The Launcher - -This code won't really make any sense for other than in the portable i2p that's shipped with the browser bundle. - -Anyway, if you wanna build it and have fun, just do `./sbt` - -Scala isn't scary - it's java except the ;;;;;;;; ;) - - diff --git a/launcher/build.sbt b/launcher/build.sbt deleted file mode 100644 index 9c5599e420..0000000000 --- a/launcher/build.sbt +++ /dev/null @@ -1,46 +0,0 @@ -import sbtassembly.AssemblyPlugin.defaultShellScript -import sbt.Keys._ - - -lazy val root = (project in file(".")) - .settings( - name := "RouterLaunchApp", - organization := "net.i2p", - scalaVersion := "2.11.11", // We have to use Scala 11 as long as we're going to support JRE 1.7 - version := "0.1.0-SNAPSHOT", - assemblyJarName in assembly := s"${name.value}-${version.value}.jar", - mainClass in assembly := Some("net.i2p.RouterLauncherApp") - - // This will prepend shebang and become executable, however, it will only work on unix systems and not windows. - //assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript)) - ) - -resolvers ++= Seq( - DefaultMavenRepository, - Resolver.mavenLocal, - Resolver.sonatypeRepo("releases"), - Resolver.typesafeRepo("releases"), - Resolver.sbtPluginRepo("releases") -) - -libraryDependencies ++= Seq( - "org.json4s" %% "json4s-native" % "3.5.3" -) - -assemblyExcludedJars in assembly := { - val donts = List("BOB.jar", "sam.jar", "desktopgui.jar", "i2ptunnel-ui.jar", "i2psnark.jar", "jetty-sslengine.jar") - val cp = (fullClasspath in assembly).value - cp filter { s => donts.contains(s.data.getName)} -} - -fork := true - -run / javaOptions += "-Xmx512M" -run / connectInput := true - -unmanagedBase := baseDirectory.value / ".." / "build" -unmanagedClasspath in Compile ++= Seq( - baseDirectory.value / ".." / "build" / "*.jar" -) - - diff --git a/launchers/README.md b/launchers/README.md new file mode 100644 index 0000000000..379b30e36c --- /dev/null +++ b/launchers/README.md @@ -0,0 +1,11 @@ +# The Launcher + +Here you'll find the code for the next generation Mac OS X launcher, as well as the Browser Bundle i2p launcher. + +Anyway, if you wanna build it and have fun, just do `./sbt` + +Scala isn't scary - it's java except the ;;;;;;;; ;) + +https://www.scala-lang.org/ +https://www.scala-sbt.org/ + diff --git a/launchers/browserbundle/README.md b/launchers/browserbundle/README.md new file mode 100644 index 0000000000..1b700698e1 --- /dev/null +++ b/launchers/browserbundle/README.md @@ -0,0 +1,5 @@ +# The browser bundle i2p launcher + +This code won't really make any sense for other than in the portable i2p that's shipped with the browser bundle. + + diff --git a/launchers/browserbundle/build.sbt b/launchers/browserbundle/build.sbt new file mode 100644 index 0000000000..ca570cb8fa --- /dev/null +++ b/launchers/browserbundle/build.sbt @@ -0,0 +1,26 @@ + + +libraryDependencies ++= Seq( + "org.json4s" %% "json4s-native" % "3.5.3" +) + +assemblyExcludedJars in assembly := { + val donts = List( + "BOB.jar", + "sam.jar", + "desktopgui.jar", + "i2ptunnel-ui.jar", + "i2psnark.jar", + "jetty-sslengine.jar" + ) + val cp = (fullClasspath in assembly).value + cp filter { s => donts.contains(s.data.getName)} +} + +// Unmanaged base will be included in a fat jar +unmanagedBase := baseDirectory.value / ".." / ".." / "build" + +// Unmanaged classpath will be available at compile time +unmanagedClasspath in Compile ++= Seq( + baseDirectory.value / ".." / ".." / "build" / "*.jar" +) diff --git a/launcher/src/main/resources/blocklist.txt b/launchers/browserbundle/src/main/resources/blocklist.txt similarity index 100% rename from launcher/src/main/resources/blocklist.txt rename to launchers/browserbundle/src/main/resources/blocklist.txt diff --git a/launcher/src/main/resources/clients.config b/launchers/browserbundle/src/main/resources/clients.config similarity index 100% rename from launcher/src/main/resources/clients.config rename to launchers/browserbundle/src/main/resources/clients.config diff --git a/launcher/src/main/resources/continents.txt b/launchers/browserbundle/src/main/resources/continents.txt similarity index 100% rename from launcher/src/main/resources/continents.txt rename to launchers/browserbundle/src/main/resources/continents.txt diff --git a/launcher/src/main/resources/countries.txt b/launchers/browserbundle/src/main/resources/countries.txt similarity index 100% rename from launcher/src/main/resources/countries.txt rename to launchers/browserbundle/src/main/resources/countries.txt diff --git a/launcher/src/main/resources/geoip.txt b/launchers/browserbundle/src/main/resources/geoip.txt similarity index 100% rename from launcher/src/main/resources/geoip.txt rename to launchers/browserbundle/src/main/resources/geoip.txt diff --git a/launcher/src/main/resources/hosts.txt b/launchers/browserbundle/src/main/resources/hosts.txt similarity index 100% rename from launcher/src/main/resources/hosts.txt rename to launchers/browserbundle/src/main/resources/hosts.txt diff --git a/launcher/src/main/resources/i2ptunnel.config b/launchers/browserbundle/src/main/resources/i2ptunnel.config similarity index 100% rename from launcher/src/main/resources/i2ptunnel.config rename to launchers/browserbundle/src/main/resources/i2ptunnel.config diff --git a/launcher/src/main/resources/logger.config b/launchers/browserbundle/src/main/resources/logger.config similarity index 100% rename from launcher/src/main/resources/logger.config rename to launchers/browserbundle/src/main/resources/logger.config diff --git a/launcher/src/main/resources/router.config b/launchers/browserbundle/src/main/resources/router.config similarity index 100% rename from launcher/src/main/resources/router.config rename to launchers/browserbundle/src/main/resources/router.config diff --git a/launcher/src/main/resources/webapps.config b/launchers/browserbundle/src/main/resources/webapps.config similarity index 100% rename from launcher/src/main/resources/webapps.config rename to launchers/browserbundle/src/main/resources/webapps.config diff --git a/launcher/src/main/scala/net/i2p/DeployProfile.scala b/launchers/browserbundle/src/main/scala/net/i2p/DeployProfile.scala similarity index 100% rename from launcher/src/main/scala/net/i2p/DeployProfile.scala rename to launchers/browserbundle/src/main/scala/net/i2p/DeployProfile.scala diff --git a/launcher/src/main/scala/net/i2p/RouterLauncherApp.scala b/launchers/browserbundle/src/main/scala/net/i2p/RouterLauncherApp.scala similarity index 100% rename from launcher/src/main/scala/net/i2p/RouterLauncherApp.scala rename to launchers/browserbundle/src/main/scala/net/i2p/RouterLauncherApp.scala diff --git a/launchers/build.sbt b/launchers/build.sbt new file mode 100644 index 0000000000..c696c56809 --- /dev/null +++ b/launchers/build.sbt @@ -0,0 +1,44 @@ +import sbt.Keys._ + +resolvers ++= Seq( + DefaultMavenRepository, + Resolver.mavenLocal, + Resolver.sonatypeRepo("releases"), + Resolver.typesafeRepo("releases"), + Resolver.sbtPluginRepo("releases") +) + +lazy val commonSettings = Seq( + organization := "net.i2p", + scalaVersion := "2.11.11", // We have to use Scala 11 as long as we're going to support JRE 1.7 + version := "0.1.0-SNAPSHOT" +) + + +lazy val browserbundle = (project in file("browserbundle")) + .settings( + commonSettings, + name := "RouterLaunchApp", + assemblyJarName in assembly := s"${name.value}-${version.value}.jar", + mainClass in assembly := Some("net.i2p.RouterLauncherApp") + ) + +lazy val macosx = (project in file("macosx")) + .settings( + commonSettings, + name := "RouterLaunchApp", + assemblyJarName in assembly := s"${name.value}-${version.value}.jar", + mainClass in assembly := Some("net.i2p.MacOSXRouterLauncherApp") + ) + + +lazy val root = (project in file(".")) + .aggregate(browserbundle, macosx) + + + + +fork := true + +run / javaOptions += "-Xmx512M" +run / connectInput := true diff --git a/launchers/macosx/README.md b/launchers/macosx/README.md new file mode 100644 index 0000000000..ca89b27a10 --- /dev/null +++ b/launchers/macosx/README.md @@ -0,0 +1,8 @@ +# The Mac OS X Launcher + +**Note** this project is WIP, cause Meeh has yet to merge in Obj-C/Swift code for GUI stuff in OSX. + +However, this is a thin wrapper launching both Mac OS X trayicon and the I2P router - and make them talk together. + +More code will be merged in, it's just a f* mess which Meeh needs to clean up and move into repo. + diff --git a/launchers/macosx/build.sbt b/launchers/macosx/build.sbt new file mode 100644 index 0000000000..3311b34aaf --- /dev/null +++ b/launchers/macosx/build.sbt @@ -0,0 +1,22 @@ +import sbtassembly.AssemblyPlugin.defaultShellScript + +lazy val i2pVersion = "0.9.34" + +// Unmanaged classpath will be available at compile time +unmanagedClasspath in Compile ++= Seq( + baseDirectory.value / ".." / ".." / "build" / "*.jar", + baseDirectory.value / ".." / ".." / "router" / "java" / "src" +) + +// Please note the difference between browserbundle, this has +// the "in Compile" which limit it's scope to that. +//unmanagedBase in Compile := baseDirectory.value / ".." / ".." / "build" + +libraryDependencies ++= Seq( + "net.i2p" % "router" % i2pVersion % Compile +) + + +assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript)) + +assemblyJarName in assembly := s"${name.value}-${version.value}" diff --git a/launchers/macosx/src/main/scala/net/i2p/MacOSXRouterLauncherApp.scala b/launchers/macosx/src/main/scala/net/i2p/MacOSXRouterLauncherApp.scala new file mode 100644 index 0000000000..c363786ddc --- /dev/null +++ b/launchers/macosx/src/main/scala/net/i2p/MacOSXRouterLauncherApp.scala @@ -0,0 +1,28 @@ +package net.i2p + +import net.i2p.router.Router + +/** + * + * For java developers: + * A scala object is like an instance of a class. + * If you define a method inside an object, it's equals to + * java's static methods. + * + * Also, in scala, the body of a class/object is executed as it's + * constructor. + * + * Also noteworthy; + * val is immutable + * var is mutable + * + * + * @author Meeh + * @version 0.0.1 + * @since 0.9.35 + */ +object MacOSXRouterLauncherApp extends App { + + + Router.main(args) +} diff --git a/launcher/project/build.properties b/launchers/project/build.properties similarity index 100% rename from launcher/project/build.properties rename to launchers/project/build.properties diff --git a/launcher/project/plugins.sbt b/launchers/project/plugins.sbt similarity index 100% rename from launcher/project/plugins.sbt rename to launchers/project/plugins.sbt diff --git a/launcher/sbt b/launchers/sbt similarity index 100% rename from launcher/sbt rename to launchers/sbt