Annotation "dateBuilt" in "DesignerComponent" is not evaluated

Extension always show that date/time when the extension was compiled. It should be that value from annotation DesignerComponent.dateBuilt.
In ComponentProcessor.ComponentInfo.ComponentInfo (ctor) there is this code (about line 660)

...
    dateBuilt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date());
...
        if (annotationName.equals(DesignerComponent.class.getName())) {
  ...
          for (Map.Entry entry : (Set<Map.Entry>) values.entrySet()) {
            if (((ExecutableElement) entry.getKey()).getSimpleName().contentEquals("dateBuilt")) {
              entry.setValue(new AnnotationValue() {
                @Override
                public Object getValue() {
                  return dateBuilt;  **<<<<<<< This not the value from the annotation. It is the current date/time**
                }
...

This code solved the problem:

...
for (Map.Entry entry : (Set<Map.Entry>) values.entrySet()) {
            if (((ExecutableElement) entry.getKey()).getSimpleName().contentEquals("dateBuilt")) {
              String tempDate = "" + entry.getValue(); // get value from entry
              if (tempDate.length() > 2) {
                tempDate = tempDate.substring(1, tempDate.length() - 1); // strip off \" at start and end
                dateBuilt = tempDate;
              }

              entry.setValue(new AnnotationValue() {
                @Override
                public Object getValue() {
                  return dateBuilt;
                }
...

This is by design. We intentionally want dateBuilt to be the date of compilation as a sanity check. It ensures that even if someone forgets to change the version number that we have a means of determining the relative order of extension versions.

It was not a good decision. Why don’t you just leave it up to the user how it should be.

I loaded the default configuration from GitHub. If I want to recompile one extension, all extensions will be recompiled. And everyone gets a new date :frowning:

First, I would recommend that you don’t keep all of your extensions on the same branch. That just means that every time you recompile you’re building them all even if you’re only modifying one (as you’ve pointed out). That seems like a bigger waste to me. It also means the history of all of the extensions are intertwined, so if you need to use something like git blame to find when a bug was introduced you have to step through unrelated histories.

Second, even if you are keeping all of your extensions in the same branch, you don’t have to redistributed all of the recompiled .aix files. Just distribute the one aix for the extension you actually updated.

May be we speek about different things. On my PC there is one folder “appinventor-sources” with a lot of subfolders. I got it with “git clone https://github.com/mit-cml/appinventor-sources.git”. “ant extensions” builds them all.
Ok, I can remove my sources and the build .aix from this folders and put them back if needed. But that is not a good solution too.
So, is there any description or tutorial how to do it in a different way?

I don’t have a formal guide readily available, but the process we use is to create a branch per extension. All of our extensions are available in the GitHub repository appinventor-extensions. In this repo, master/ucr still track those in appinventor-sources, but there is also a branch for each extension we’ve built. These branches begin with extension/, such as extension/bluetoothle or extension/look. Development for each extension occurs on the corresponding branch (exception: extension/bluetoothle also feeds into the arduino101 and microbit branches since they depend on the BluetoothLE extension).

Locally, once you clone the repo, you can create a new branch by invoking git checkout -b extension/new-extension to create a new branch for an extension. Switch between your extensions by using git checkout extension/other-extension.

1 Like

Thx, I will ave a look at it.

1 Like