Skip to content

Commit

Permalink
feat: shrink/optimize the plugin JAR file
Browse files Browse the repository at this point in the history
Signed-off-by: Art Shendrik <[email protected]>
  • Loading branch information
amal committed Apr 28, 2024
1 parent 7b35e3e commit b2dd53d
Show file tree
Hide file tree
Showing 10 changed files with 1,230 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .run/apiDump.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="apiDump" type="GradleRunConfiguration" factoryName="Gradle" folderName="baseline">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--stacktrace --no-build-cache" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="apiDump" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

[//]: # (Changed, Added, Removed, Fixed, Updated)

### Added
- shrink/optimize the plugin JAR file.


## [0.3.0] - 2024-04-28

Expand Down
2 changes: 2 additions & 0 deletions fluxo-bcv-js/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ fkcSetupGradlePlugin(
allWarningsAsErrors = false
experimentalLatestCompilation = true

shrinkWithProGuard()

publicationConfig {
version = pluginVersion
developerId = "amal"
Expand Down
103 changes: 103 additions & 0 deletions fluxo-bcv-js/pg/assumenosideeffects.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

###
# ProGuard/R8 assumenosideeffects rules
###

# Specifies methods that don't have any side effects (other than maybe returning a value).
# In the optimization step, ProGuard will then remove calls to such methods,
# if it can determine that the return values aren't used.

# https://www.guardsquare.com/en/products/proguard/manual/usage#assumenosideeffects
# https://www.guardsquare.com/en/products/proguard/manual/usage#classspecification
# https://www.guardsquare.com/en/products/proguard/manual/examples#logging

# http://www.alexeyshmalko.com/2014/proguard-real-world-example/#conclusion
# https://github.com/abgoyal/OT_4030X/blob/1cc51cbe346b0ed161957509f5004a1ace13161c/external/proguard/src/proguard/gui/boilerplate.pro#L93

# Note: -assumenosideeffects should not be used with constructors!
# It leads to bugs like https://sourceforge.net/p/proguard/bugs/702/
# Using -assumenoexternalsideeffects is fine though and should be used for that purpose.

# Note: -assumenoexternalsideeffects and -assumenoexternalreturnvalues are not supported by R8 and ignored!


# Remove Kotlin intrinsic assertions.
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
public static void checkExpressionValueIsNotNull(...);
public static void checkNotNullExpressionValue(...);
public static void checkParameterIsNotNull(...);
public static void checkNotNullParameter(...);
public static void checkReturnedValueIsNotNull(...);
public static void checkFieldIsNotNull(...);

# maybe not safe, needs testing
# public static void checkNotNull(...);
# public static void throwUninitializedPropertyAccessException(...);
# public static void throwNpe(...);
# public static void throwJavaNpe(...);
# public static void throwAssert(...);
# public static void throwIllegalArgument(...);
# public static void throwIllegalState(...);
}


-assumenosideeffects class org.slf4j.*, ** extends org.slf4j.* {
*** trace(...);
boolean isTraceEnabled(...);
}
-assumevalues class org.slf4j.*, ** extends org.slf4j.* {
boolean isTraceEnabled(...) return false;
}

-assumenosideeffects class java.lang.Character {
*** codePoint*(...);
*** to*Case(...);
boolean is*(...);
}

-assumenosideeffects class java.lang.Boolean {
boolean logical*(...);
}

-assumenosideeffects class java.lang.Iterable, ** implements java.lang.Iterable {
java.util.Iterator iterator(...);
*** spliterator(...);
}
-assumenosideeffects class java.util.Collection, ** implements java.util.Collection {
*** toArray(...);
boolean contains(...);
boolean containsAll(...);
boolean isEmpty();
int size();
int hashCode();
boolean equals(java.lang.Object);
*** stream(...);
*** parallelStream(...);
}
-assumenosideeffects class java.util.List, ** implements java.util.List {
*** get(...);
*** listIterator(...);
int indexOf(...);
int lastIndexOf(...);
java.util.List subList(int, int);
}
-assumenosideeffects class java.util.Map, ** implements java.util.Map {
*** get(...);
boolean contains*(...);
boolean isEmpty();
int size();
java.util.Collection values();
java.util.Set entrySet();
java.util.Set keySet();
}
-assumenosideeffects class java.util.Queue, ** implements java.util.Queue {
*** element();
*** peek();
}
-assumenosideeffects class java.util.Deque, ** implements java.util.Deque {
*** getFirst();
*** getLast();
*** peekFirst();
*** peekLast();
java.util.Iterator descendingIterator();
}
Loading

0 comments on commit b2dd53d

Please sign in to comment.