Solved What is the best way to use large external libraries when making a plugin? (scala runtime)

Discussion in 'Plugin Development' started by jtjj222, Nov 24, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    jtjj222

    I picked up a copy of the book "Seven languages in seven weeks," and now I am hooked on trying to develop a plugin using scala. So far, I can get a simple Scala plugin to run, but I need to pack the entire scala runtime into it, and it is about 8mb :eek:

    Code:scala
    1. package me.jtjj222.scalatest
    2. import org.bukkit.plugin.java.JavaPlugin;
    3.  
    4. class ScalaPlugin extends JavaPlugin{
    5.  
    6. override def onEnable() {
    7. println("hi");
    8. }
    9. }

    It outputs this (from jd-gui) when compiled (note, it actually outputs bytecode, but it is easier to show you the decompiled java):
    Code:java
    1. package me.jtjj222.scalatest;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4. import scala.Predef.;
    5. import scala.ScalaObject;
    6. import scala.reflect.ScalaSignature;
    7.  
    8. @ScalaSignature(bytes="\006\001\0352A!\001\002\001\023\tY1kY1mCBcWoZ5o\025\t\031A!A\005tG\006d\027\r^3ti*\021QAB\001\bURT'N\r\0323\025\0059\021AA7f\007\001\0312\001\001\006\027!\tYA#D\001\r\025\tia\"\001\003kCZ\f'BA\b\021\003\031\001H.^4j]*\021\021CE\001\007EV\\7.\033;\013\003M\t1a\034:h\023\t)BB\001\006KCZ\f\007\013\\;hS:\004\"a\006\016\016\003aQ\021!G\001\006g\016\fG.Y\005\0037a\0211bU2bY\006|%M[3di\")Q\004\001C\001=\0051A(\0338jiz\"\022a\b\t\003A\001i\021A\001\005\006E\001!\teI\001\t_:,e.\0312mKR\tA\005\005\002\030K%\021a\005\007\002\005+:LG\017")
    9. public class ScalaPlugin extends JavaPlugin
    10. implements ScalaObject
    11. {
    12. public void onEnable()
    13. {
    14. Predef..MODULE$.println("hi");
    15. }
    16. }

    So while it might not be the most clean output, the language offers some awesome features that I want to try out. Does anyone know of a better way to do this?
     
  2. Offline

    Sagacious_Zed Bukkit Docs

  3. Offline

    md_5

    For something as niche and big as scala, if you do decide to release on BukkitDev, shading is not the way to go. In almost every other plugin it is.
     
  4. Offline

    jtjj222

    Ok, I figured it out. I created a "loader" plugin that loads all of the scala dependencies, then loads my plugin. Thanks guys!
     
Thread Status:
Not open for further replies.

Share This Page