Java Question Library Usage flow with AdditionalResources and Setup

Discussion in 'Libraries developers questions' started by thedesolatesoul, Jun 3, 2015.

  1. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Just thinking out loud regarding how to make library setup more simple.
    There are a lot of complex libraries that require quite a lot of setup i.e. multiple AdditionalRes, sometimes AdditionalJar, require a particular version of the SDK, then another version of the support library, some more files in the Files tab.
    So yes, its a big pain to setup some of these libs and even more difficult to debug the issues.

    In order to simplify the flow I recommend, we include all of the information in the jar/xml.
    How this would work:
    1 package any additionalres/file etc in the jar file (using either 7zip or eclipse)
    2 package an extra script in there to tell it what to do
    3 In CustomBuildActions add a command ParseLibSetup

    Step 3 is ALL the setup that the user needs

    ParseLibSetup first parses the .b4a file to find all the libraries.
    Then it will open each library xml file to find a particular identifier, to say whether the LibSetup.scr exists in the jar.
    Then it goes into the particular library.jar and extract its temporarily and reads the LibSetup.scr

    LibSetup.scr is in the form of:
    Code:
    cp <LIBROOT>\AddRes1 <PROJECTROOT>\<LIBNAME>\AddRes1
    cp <LIBROOT>\AddRes2 <PROJECTROOT>\<LIBNAME>\AddRes2
    cp <LIBROOT>\Files <PROJECTROOT>\Files\fonts
    INSERT <PROJECT_B4A_FILE> 
    "#AdditionalRes: " + <LIBNAME> + "\AddRes1"
    INSERT <PROJECT_B4A_FILE> 
    "#Extends: insaneActivity"
    INSERTMANIFEST <PROJECT_B4A_FILE> 
    "TEXT"
    CHECK_SDK platform-
    22
    CHECK_SUPPORT_LIBS v22
    CHECK_GENERAL_FILE <
    file> <value>
    One of the issues I see with this is that it edits the project.b4a file while it is open in the IDE, so we need a way to re-invoke and refresh the B4A file.
    The other issue is that it can be slow if it is done on every single time, so there can be a potential first-time flag.

    It is a bit of effort, but it solves most user errors in library setup.
    It also ensures whenever you start a new project, you dont need to setup everything again, especially if it is using multiple kinds of these libraries.
    This will also work with B4A built libraries if you manually put this files in the jar.

    Currently I dont intend to build it due to lack of time and resource. But it will be interesting to see what the community thinks could be further issues with it.
     
    DonManfred, walt61 and MarcoRome like this.
Loading...