<commit_before>#!/bin/bash

# this script reads the maven generated classpaths and run proguard appropriately
# we are not using the maven proguard plugin because it's terribly buggy. (injars being treated as outjars, outjars not working with filters for example)

RTJAR=$JAVA_HOME/jre/lib/rt.jar
PWD=`pwd -P`
VERSION=$MALHAR_BUILD_VERSION

if [ "$VERSION" = "" ]
then
    echo "ERROR: Environment variable MALHAR_BUILD_VERSION needs to be set!"
    exit 1;
fi

cat > proguard.conf <<EOF
-dontshrink
-dontoptimize
-dontwarn com.malhartech.contrib.**
-dontwarn org.apache.hadoop.**
-keeppackagenames com.malhartech.**
-keep public class com.malhartech.contrib.**
-keep public class com.malhartech.demos.**
-keep public class com.malhartech.lib.**
-keep public class com.malhartech.daemon.Daemon { public *; }
-keep public class com.malhartech.api.**
-keep public interface com.malhartech.api.**
-keep public interface com.malhartech.annotation.**
-keep public class com.malhartech.stram.cli.StramAppLauncher { public static java.lang.String runApp(com.malhartech.stram.cli.StramAppLauncher$AppConfig); }
-keep public class com.malhartech.stram.cli.StramCli { public static void main(java.lang.String[]); }
-keep public interface com.malhartech.stram.cli.StramAppLauncher$AppConfig
-printmapping proguard_map.txt
-printseeds proguard_seeds.txt
-libraryjars $RTJAR
EOF

cat mvn-generated-classpath | tr : '\n' > mvn-generated-classpath.tmp

for path in `cat mvn-generated-classpath.tmp`
do
   if [[ "$path" == *malhar* ]]
   then
       echo "-injars $path"  >> proguard.conf
   else
       echo "-libraryjars $path"  >> proguard.conf
   fi
done

cat >> proguard.conf <<EOF
-outjars malhar-contrib-$VERSION.jar(**/malhar-contrib/**,com/malhartech/contrib/**)
-outjars malhar-bufferserver-$VERSION.jar(**/malhar-bufferserver/**,com/malhartech/bufferserver/**)
-outjars malhar-daemon-$VERSION.jar(**/malhar-daemon/**,com/malhartech/daemon/**)
-outjars malhar-demos-$VERSION.jar(**/malhar-demos/**,com/malhartech/demos/**)
-outjars malhar-library-$VERSION.jar(**/malhar-library/**,com/malhartech/lib/**)
-outjars malhar-stram-$VERSION.jar
EOF

rm mvn-generated-classpath.tmp
proguard @proguard.conf -verbose

for module in contrib bufferserver daemon demos library stram
do
    cp -p malhar-$module-$VERSION.jar $HOME/.m2/repository/com/malhartech/malhar-$module/$VERSION/
done<commit_msg>proguard options so far, not completely working yet<commit_after>#!/bin/bash

# this script reads the maven generated classpaths and run proguard appropriately
# we are not using the maven proguard plugin because it's terribly buggy. (injars being treated as outjars, outjars not working with filters for example)

RTJAR=$JAVA_HOME/jre/lib/rt.jar
PWD=`pwd -P`
VERSION=$MALHAR_BUILD_VERSION

if [ "$VERSION" = "" ]
then
    echo "ERROR: Environment variable MALHAR_BUILD_VERSION needs to be set!"
    exit 1;
fi

cat > proguard.conf <<EOF
-dontshrink
-dontoptimize
-dontwarn com.malhartech.contrib.**
-dontwarn org.apache.hadoop.**
-keeppackagenames com.malhartech.**
-keep public class com.malhartech.contrib.** { *; }
-keep public class com.malhartech.demos.** { *; }
-keep public class com.malhartech.lib.** { *; }
-keep public class com.malhartech.daemon.Daemon { public *; }
-keep public class com.malhartech.api.** { *; }
-keep public class com.malhartech.bufferserver.Buffer { *; }
-keep public class com.malhartech.bufferserver.Buffer$** { *; }
-keep public class com.malhartech.util.VersionInfo { *; }
-keep public interface com.malhartech.api.** { *; }
-keep public interface com.malhartech.annotation.** { *; }
-keep public class com.malhartech.stram.cli.StramAppLauncher { 
    public static java.lang.String runApp(**); 
}
-keep public interface com.malhartech.stram.cli.StramAppLauncher$AppConfig
-keepclasseswithmembers class ** { 
    public static void main(java.lang.String[]); 
}
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    !static !transient <fields>;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}
-keepclassmembernames class ** { 
    public static final long versionID; 
}
-keepclassmembers enum * { *; }
-keepattributes *Annotation*
-printmapping proguard_map.txt
-printseeds proguard_seeds.txt
-libraryjars $RTJAR
EOF

cat mvn-generated-classpath | tr : '\n' > mvn-generated-classpath.tmp

for path in `cat mvn-generated-classpath.tmp`
do
   if [[ "$path" == *malhar* ]]
   then
       echo "-injars $path"  >> proguard.conf
   else
       echo "-libraryjars $path"  >> proguard.conf
   fi
done

cat >> proguard.conf <<EOF
-outjars malhar-contrib-$VERSION.jar(**/malhar-contrib/**,com/malhartech/contrib/**)
-outjars malhar-bufferserver-$VERSION.jar(**/malhar-bufferserver/**,com/malhartech/bufferserver/**)
-outjars malhar-daemon-$VERSION.jar(**/malhar-daemon/**,com/malhartech/daemon/**)
-outjars malhar-demos-$VERSION.jar(**/malhar-demos/**,com/malhartech/demos/**)
-outjars malhar-library-$VERSION.jar(**/malhar-library/**,com/malhartech/lib/**)
-outjars malhar-stram-$VERSION.jar
EOF

rm mvn-generated-classpath.tmp
proguard @proguard.conf -verbose

for module in contrib bufferserver daemon demos library stram
do
    cp -p malhar-$module-$VERSION.jar $HOME/.m2/repository/com/malhartech/malhar-$module/$VERSION/
    mkdir -p ../../$module/target
    cp -p malhar-$module-$VERSION.jar ../../$module/target
done
{'fraction_non_alphanumeric': 0.13745091038914672, 'fraction_numerical': 0.0007140307033202428, 'mean_word_length': 4.434529582929195, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6948130', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1868, 'n_words': 428}