Rush β€’ A new and improved way of building extensions

i am so pleased that lambda expressions are finally added this is the only i needed now i will only use rush :smile: :smile:

1 Like

Great was waiting and finally came…

@Akshat_Rana I feel as though your comment can be taken in a way you didn’t mean it and to me the comment screams β€œyou took too long.” Thank Shreyash for his hard work, not just a short, possibly petty comment.

4 Likes

shreyash i have a doubt does this require ant to be installed and second does it automatically proguard the extensions???

AFAIK, you need to set the optimize to true in metadata file. And I think now it comes true default from new update. You just need to paas the -r flag while building and the extension will be proguard.

I think no. I read somewhere in this topic that rush don’t require ant for building the extension.

And now I think shreyash only may confirm this.

1 Like

when i try to run rush build -r
i get this error -

$ rush build -r
                      __
     _______  _______/ /_
    / ___/ / / / ___/ __ \
   / /  / /_/ (__  / / / /
  /_/   \__,_/____/_/ /_/

β€’ Build initialized

β”Œ Checking project files
β”‚ info Checking metadata file (rush.yml)
β”‚ info Checking AndroidManifest.xml file
β”” done
β”Œ Compiling source files
β”‚ info Picked 20 source files
β”” done
β”Œ Processing the extension
β”‚ info Desugaring Java 8 language features
β”‚ info Linking extension assets and dependencies
β”‚ info Optimizing the extension
β”‚      Picked up _JAVA_OPTIONS: -Xmx2048M
β”‚
β”‚ note there were 5004 duplicate class definitions.
β”‚            (https://www.guardsquare.com/proguard/manual/troubleshooting#duplicateclass)
β”‚
β”‚ warn org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory
β”‚ warn org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
β”‚ warn org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
β”‚ warn org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory
β”‚ warn org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
β”‚ warn org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
β”‚ warn org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory
β”‚ warn org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean
β”‚ warn org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory
β”‚ warn org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean
β”‚ warn there were 10 unresolved references to classes or interfaces.
β”‚               You may need to add missing library jars or update their versions.
β”‚               If your code works fine without the missing classes, you can suppress
β”‚               the warnings with '-dontwarn' options.
β”‚               (https://www.guardsquare.com/proguard/manual/troubleshooting#unresolvedclass)
β”‚
β”‚ erro Please correct the above warnings first.
β”” failed

β€’ Build failed [5s 854ms] [1 error; 11 warnings]

and same with rush build -o but it works when i just run rush build

Yes, that’s correct. Rush does not require Apache Ant in order to build extensions. It in itself is a build tool like Apache Ant, but designed specifically for building extensions.

Talking about optimizing your extensions with ProGuard, there are a couple of ways this can be done in Rush:

  • Using the --release flag (or -r for short): This flag is used to generate a release build of your extensions. When it is detected, Rush performs a clean build of your extension, and optionally optimizes your extension if build.release.optimize is set to true in the metadata file.

  • Using the --optimize flag (or -o for short): This flags optimizes your extension no matter what the value of build.release.optimize. Unlike the release flag, this doesn’t invalidates the build cache, resulting in faster builds.

1 Like

As the warning says, ProGuard is unable to find the mentioned classes. There are a couple of ways to solve these errors:

  • By adding the mentioned classes to the classpath.
  • By using the -dontwarn rule to the ProGuard rules file ONLY IF you’re sure that those missing classes won’t affect the rest of your code. Here you can read more about the -dontwarn rule: ProGuard Manual: Usage | Guardsquare
1 Like

Please solve this error-

     _______  _______/ /_
    / ___/ / / / ___/ __ \
   / /  / /_/ (__  / / / /
  /_/   \__,_/____/_/ /_/

β€’ Build initialized

β”Œ Checking project files
β”‚ info Checking metadata file (rush.yml)
β”‚ info Checking AndroidManifest.xml file
β”” done
β”Œ Compiling source files
β”‚ info Picked 1 source file
β”” done
β”Œ Processing the extension
β”‚ info Desugaring Java 8 language features
β”‚ info Linking extension assets and dependencies
β”‚ info Optimizing the extension
β”‚ note there were 4810 duplicate class definitions.
β”‚            (https://www.guardsquare.com/proguard/manual/troubleshooting#duplicateclass)
β”‚
β”‚ erro The output jar is empty. Did you specify the proper '-keep' options?
β”” failed

β€’ Build failed [15s 328ms] [1 error]

Can you show me the contents of your proguard-rules.pro file.

1 Like
# Add any ProGuard configurations specific to this
# extension here.

-keep public class in.sonraj.qrlogo.Qrlogo {
    public *;
 }
-keeppackagenames gnu.kawa**, gnu.expr**

-optimizationpasses 4
-allowaccessmodification
-mergeinterfacesaggressively

-repackageclasses 'in/sonraj/qrlogo/repack'
-flattenpackagehierarchy
-dontpreverify

Okay, this is a bit weird. Make sure that:

  1. The Java file, Qrlogo.java, isn’t empty.
  2. The package in which Qrlogo.java resides matches with this: in.sonraj.qrlogo
1 Like

Will I able to write code in both Kotlin and Java?

Yes, you can.

1 Like

is there any way to integrate xml in rush if yes it could be greatt

Please specify what do you mean by β€œintegrate XML”.

1 Like

i mean like xml files eg, strings.xml, attrs.xml

Nope, that’s not yet possible. Fyi, it’s not something that can be implemented entirely through Rush; some changes are necessary on the upstream (AI2) to support the use of XML resources in extensions.

4 Likes

Hello @Shreyash . First of all thanks for really great project Rush.
I’m very new to rush and commands. and I tried to create extension by using Rush. It created my extension folder successfully but I got some errors on build.

  • I have no spaces in my directory or in filename.
  • I’ve tried on desktop and D drive to make my project. (same error everywhere)
  • I’m using Windows PowerShell

As you can see java & rush versions on my machine and successfully created extension project folder :point_down:

But I’m getting this error while building my project :point_down: by using rush build -r

Your help will be appreciated :kodular:

1 Like

Also getting this error with version 1.2.0 :point_down: