fedora-java / javapackages

Macros and scripts for Java packaging support
Other
7 stars 15 forks source link

Add Lua scripts for removing annotations #90

Closed mkoncek closed 2 years ago

mkoncek commented 2 years ago

Requires: rpm >= 4.18 (for /usr/bin/rpmlua)

Tested on package guava:

./java-utils/java_remove_symbols.lua -a guava-31.0.1 -p GwtCompatible GwtIncompatible VisibleForTesting Immutable CompatibleWith ReflectionSupport GuardedBy DoNotCall Beta DoNotMock Nullable MonotonicNonNull WeakOuter CanIgnoreReturnValue NonNull J2ObjCIncompatible LazyInit RetainedWith ForOverride Weak MustBeClosed CheckReturnValue OverridingMethodsMustInvokeSuper InlineMe InlineMeValidationDisabled

Diff after using it on the Fedora package classpathless-compiler:

-find -name '*.java' -exec sed -i '/@SuppressFBWarnings\|import edu\.umd\.cs\.findbugs/d' {} +
+%java_remove_annotations -p SuppressFBWarnings
mkoncek commented 2 years ago

The script cannot be interpreted by the current rpmlua present in Fedora Rawhide (version: RPM version 4.18.0-alpha2) 1) It complains about shebang 2) arg variable passing does not seem implemented so it is impossible to pass CLI args to the script.

mizdebsk commented 2 years ago

Why use rpmlua instead of plain lua? Requirement on RPM 4.18 is a no-go for now, we still need to support RPM 4.14. We can't even use RPM 4.16 features such as parametric dependency generators, or meta-requires. Otherwise looks good.

mizdebsk commented 2 years ago

I've fixed CI, it should run tests once you rebase the PR. Please remove use of rpmlua and I'll merge the PR.

codecov-commenter commented 2 years ago

Codecov Report

Merging #90 (df23120) into master (38e4a3a) will not change coverage. The diff coverage is n/a.

:exclamation: Current head df23120 differs from pull request most recent head 2e10481. Consider uploading reports for the commit 2e10481 to get more accurate results

@@           Coverage Diff           @@
##           master      #90   +/-   ##
=======================================
  Coverage   89.69%   89.69%           
=======================================
  Files          43       43           
  Lines        3009     3009           
=======================================
  Hits         2699     2699           
  Misses        310      310           

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

mkoncek commented 2 years ago

I separated the functions from wrappers so that it should work with both lua and rpmlua. So that for example javapackages in Fedora Rawhide can be patched downstream to use rpmlua. Note that rpmlua does not inspect paths listed in LUA_PATH. This can be worked around either by manually adding a line into the script before require clause:

package.path = package.path..";<PATH>"

or by installing the library into /usr/lib/rpm/javapackages-tools/lua/... although I haven't tested this.

mkoncek commented 2 years ago

I added a bunch of commits so that they are more easily reviewed. Should I squash them later?

mizdebsk commented 2 years ago

There is no need to squash commits. Merged.