# THIS IS A SPECIAL VERSION OF LITE.TXT
# It keeps more stuff in NetLogoLite.jar, in order for the network extension to work.
# It can be used to produce a special version of the jar by overwriting the equivalent
# file in the NetLogo 5.0.x distribution (in the project/proguard) directory.

-include common.txt

# since this file is in the project/proguard directory, we need to get back up to the root
-basedirectory ../..

# forcibly exclude the generator. at runtime, the code will notice it is missing
# and do without it (it doesn't work in applets anyway because of the security
# restrictions on class loading). also exclude unneeded resources
-injars target/classes(!org/nlogo/generator/**,!images/shapes-editor/**,!system/libraryShapes.txt,!system/about.txt,!system/library.html,!system/empty.nlogo3d,!system/behaviorspace.dtd,!system/dict3d.txt,!system/dict.txt,!system/info.css,!i18n/**,!images/title.jpg,**)

# this is an injar, not a library jar, because we're going to stuff the Scala classes
# we need directly into NetLogoLite.jar, so NetLogoLite.jar has no external dependencies
-injars <org.nlogo.scala-library>

-outjar NetLogoLite.jar

# ProGuard doc recommends keeping Exceptions,InnerClasses,Signature
# for libraries.  we keep SourceFile and LineNumberTable so we get
# nice stack traces.  but we get significant space savings (10% or so)
# by not keeping ScalaSignature - ST 5/13/11
-keepnames class * { *; }
-keepattributes Exceptions,InnerClasses,Signature,SourceFile,LineNumberTable

-keep public class org.nlogo.lite.*

# the Event stuff works by reflection so we need to explicitly include these
-keep public class * extends org.nlogo.window.Event

# pull in all the prims (but not threed, hubnet, dead)
-keep public class org.nlogo.prim._* {
    *;
}
-keep public class org.nlogo.prim.etc.* {
    *;
}
-keep public class org.nlogo.prim.gui.* {
    *;
}
-keep public class org.nlogo.prim.plot.* {
    *;
}
-keep public class org.nlogo.prim.file.* {
    *;
}

# keep applet stuff
-keep public class org.nlogo.lite.AppletPanel {
    *;
}
-keep public class org.nlogo.window.NetLogoListenerManager {
    *;
}

# pull in the extensions API
-keep public class org.nlogo.api.* {
    *;
}
-keep public class org.nlogo.nvm.ExtensionContext {
    *;
}
-keep public class org.nlogo.nvm.Workspace {
    *;
}
-keep public class org.nlogo.nvm.Argument {
    *;
}

# some methods used by extensions
-keep public class org.nlogo.window.GUIWorkspace {
    public org.nlogo.window.WidgetContainer getWidgetContainer();
    public void waitFor(java.lang.Runnable);
}
-keep public class org.nlogo.util.Utils {
    public static java.lang.String reader2String(java.io.Reader);
}

# pull in stuff we access only by reflection (for dependency injection)
-keep class org.nlogo.render.Renderer {
      Renderer(...);
}
-keep class org.nlogo.lex.Tokenizer?D {
    *;
}
-keep class org.nlogo.lex.TokenReader {
    *;
}
-keep class org.nlogo.sdm.AggregateManagerLite {
    *;
}
-keep class org.nlogo.compiler.Compiler$ {
    *;
}
-keep class org.nlogo.job.JobManager {
    *;
}

# Package objects need it
-keep class scala.runtime.EmptyMethodCache {
    *;
}

# Structural types need it
-keep class scala.runtime.ScalaRunTime$ {
    public java.lang.reflect.Method ensureAccessible(java.lang.reflect.Method);
}

# needed or extensions written in Scala won't build
-keep class scala.reflect.ScalaSignature {
    *;
}

# stuff added for the NW extension:
-keep class scala.collection.JavaConverters { *; }
-keep class scala.collection.JavaConverters$AsJavaCollection { *; }
-keep class scala.collection.generic.GenericTraversableTemplate { *; }
-keep class scala.collection.mutable.Map$ { *; }
-keep class scala.Option$WithFilter { *; }
-keep class scala.collection.mutable.MapLike { *; }
-keep class scala.collection.mutable.Set$ { *; }
-keep class scala.Option { *; }
-keep class scala.math.Ordering$Long$ { *; }
-keep class scala.collection.IterableLike { *; }
-keep class scala.collection.TraversableLike { *; }
-keep class scala.package$ { *; }
-keep class scala.collection.mutable.Publisher { *; }
-keep class scala.collection.mutable.Subscriber { *; }
-keep class scala.collection.immutable.Stream$ { *; }
-keep class scala.runtime.AbstractFunction1** { *; }

# remove those after testing:
#-dontobfuscate
#-verbose

# this is a bit of magic needed to make Java enums work, taken from the ProGuard manual
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep public class org.nlogo.widget.* {
 *;
}
