[BETA] Dependencies Resolver - Resolve All The required Dependencies for your Extension

:mag_right: Dependencies Resolver

Typically, Android and Java library developers publish their libraries on maven repositories (i.e: MavenCentral), and by giving out its compiled jar file. This makes it simple for developers to import the library into their projects using a java build automation system, which provides built-in capability to resolve dependencies, such as gradle or Apache maven. Unfortunately, importing libraries when developing an extension or component for MIT AppInventor or any of its distributions is limited into using its .jar file (and additionally .aar and .so library files for components).
So, using the maven artifact itself is in fact impossible, unless by collecting and downloading the dependency library file as well as all of its required dependencies one by one, which is indeed a lengthy process and could eventually result in missing libraries, causing a NoClassDefFoundError or compile errors, another option might be to download maven or gradle to build the libraries, although, getting the library files is typically not trivial, since this tools are mainly designed to build java projects, not to work as a dependency resolver.

Dependency resolver is a CLI which supports resolving and downloading dependencies given a maven artifact, without having to download them all one by one.
To learn more about downloading and running dependency resolver, please see the wiki.
This CLI is fully open source, you can find the source code on github:

This library is still under beta, it may not perform as expected in some situations, please let me know about any bugs, suggestions or feature requests by writing a post on this topic, or by opening an issue on github.
Cheers,
Mohamed Tamer

19 Likes

Probably you can just wrap this in a JavaFX application as CLIs can be often confusing.

3 Likes

Thanks, that’s correct, i will put it on my plan for this project on a next version.

1 Like

I can see the amount of effort put into this. Great job! :+1:

I’ve been working on something similar lately, for Rush 2.0 :wink:.

8 Likes

Thanks!

That’s very interesting to hear, I’m looking forward to seeing it’s release :grinning_face_with_smiling_eyes:

5 Likes

A new version has been released :tada:

Version 0.3-beta Release Notes

Reference PR.

What’s New

  • Implement GUI desktop application! Find out here how to run it. (ref)

  • Support Gradle Kotlin implementations, i.e: implementation("com.test:test:1.0")

  • Implement progress reporting

Changes

  • Rename --compress flag to --merge
  • Updates code to Java 11. (Notice: Using a previous version of java when executing the CLI or GUI would fail ). This is change was made to support the javaFX implementation, in case you are OK of using JDK 8 with the CLI only, see the the Building Section in the GitHub wiki, you should be able to build the cli module using java 8. However, the automated CI would build the Jar file using java 11.
  • Warn when an AAR contains resources when using --jarOnly flag, since the resources will not be included in the output Jar file.

Internal Changes

  • Restructure the project into multiple gradle modules
  • Refactor most of the code
  • Rename packages from io.mohamed.* to io.mohamed.resolver.*.

Bug Fixes

  • Fix a bug where using the -v flag with the resolve command would prints the version text, instead of being treated as the abbreviation for the --verbose option.

Deprecations

  • Deprecates the --type flag, it’s automatically inferred from the artifact packaging. Setting it automatically was being overwritten.

Cheers,
Mohamed Tamer

4 Likes

hey i just tested it but somewhy here is a result when i try to run it from my command prompt -
PS C:\Users\asus\Downloads> java -jar dependencies-resolver-gui-0.3-beta.jar

Picked up _JAVA_OPTIONS: -Xmx2048M
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: io/mohamed/resolver/gui/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

oh i just saw it requires java 11 2 but if the java version is not 8 then how we build extensions?

Hello @luv.ak.tech ,
Please check the following guide:

1 Like

hi @Mohamed_Tamer so before starting that should i delete my old java jdk?

No need, if you are going to go with sdkman, then it should apply the java version you want to use to the current shell only, however, the java 8 JDK you downloaded would apply globally to other sessions.
If you will install it manually, skip installing java 8 as you have it already installed.

1 Like

what to do after this -

curl -s "https://get.sdkman.io" | bash

                                -+syyyyyyys:
                            `/yho:`       -yd.
                         `/yh/`             +m.
                       .oho.                 hy                          .`
                     .sh/`                   :N`                `-/o`  `+dyyo:.
                   .yh:`                     `M-          `-/osysoym  :hs` `-+sys:      hhyssssssssy+
                 .sh:`                       `N:          ms/-``  yy.yh-      -hy.    `.N-````````+N.
               `od/`                         `N-       -/oM-      ddd+`     `sd:     hNNm        -N:
              :do`                           .M.       dMMM-     `ms.      /d+`     `NMMs       `do
            .yy-                             :N`    ```mMMM.      -      -hy.       /MMM:       yh
          `+d+`           `:/oo/`       `-/osyh/ossssssdNMM`           .sh:         yMMN`      /m.
         -dh-           :ymNMMMMy  `-/shmNm-`:N/-.``   `.sN            /N-         `NMMy      .m/
       `oNs`          -hysosmMMMMydmNmds+-.:ohm           :             sd`        :MMM/      yy
      .hN+           /d:    -MMMmhs/-.`   .MMMh   .ss+-                 `yy`       sMMN`     :N.
     :mN/           `N/     `o/-`         :MMMo   +MMMN-         .`      `ds       mMMh      do
    /NN/            `N+....--:/+oooosooo+:sMMM:   hMMMM:        `my       .m+     -MMM+     :N.
   /NMo              -+ooooo+/:-....`...:+hNMN.  `NMMMd`        .MM/       -m:    oMMN.     hs
  -NMd`                                    :mm   -MMMm- .s/     -MMm.       /m-   mMMd     -N.
 `mMM/                                      .-   /MMh. -dMo     -MMMy        od. .MMMs..---yh
 +MMM.                                           sNo`.sNMM+     :MMMM/        sh`+MMMNmNm+++-
 mMMM-                                           /--ohmMMM+     :MMMMm.       `hyymmmdddo
 MMMMh.                  ````                  `-+yy/`yMMM/     :MMMMMy       -sm:.``..-:-.`
 dMMMMmo-.``````..-:/osyhddddho.           `+shdh+.   hMMM:     :MmMMMM/   ./yy/` `:sys+/+sh/
 .dMMMMMMmdddddmmNMMMNNNNNMMMMMs           sNdo-      dMMM-  `-/yd/MMMMm-:sy+.   :hs-      /N`
  `/ymNNNNNNNmmdys+/::----/dMMm:          +m-         mMMM+ohmo/.` sMMMMdo-    .om:       `sh
     `.-----+/.`       `.-+hh/`         `od.          NMMNmds/     `mmy:`     +mMy      `:yy.
           /moyso+//+ossso:.           .yy`          `dy+:`         ..       :MMMN+---/oys:
         /+m:  `.-:::-`               /d+                                    +MMMMMMMNh:`
        +MN/                        -yh.                                     `+hddhy+.
       /MM+                       .sh:
      :NMo                      -sh/
     -NMs                    `/yy:
    .NMy                  `:sh+.
   `mMm`               ./yds-
  `dMMMmyo:-.````.-:oymNy:`
  +NMMMMMMMMMMMMMMMMms:`
    -+shmNMMMNmdy+:`


                                                                 Now attempting installation...


Looking for a previous installation of SDKMAN...
Looking for unzip...
Looking for zip...
Not found.
======================================================================================================
 Please install zip on your system using your favourite package manager.

 Restart after installing zip.
======================================================================================================

Have you installed the zip command as in the first step in the guide above?

oh sorry i did not saw that will just do it

1 Like

ok sdkman installation was successful so do i need to run the cmd for installing java 8 because i already have it downloaded

You may only want to install it in case you want to switch back from java 11 to java 8 in the same shell session, using the use command, if not, it’s OK, just install java 11 and when you are done with using it, restart the terminal to use your computer’s default java 8.

1 Like

weird -

$ sdk use java 11.0.12-open

Using java version 11.0.12-open in this shell.

asus@LAPTOP-FRA1ARJR MINGW64 ~
$ java -version
Picked up _JAVA_OPTIONS: -Xmx2048M
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

Strange :thinking: Maybe your previous java installation is conflicting with it, perhaps temporarily try to remove the java path from your PATH variable, restart the terminal, and re-run the command.

1 Like

i guess you are right they both were conflicting the moment i removed it is now 11 thx

Great! Let me know if the program starts or any other error has occurred, for further development with java 8, either install java 8 using sdkman, or re-add it to the PATH variable.

1 Like