inductiveautomation / ignition-module-tools

Tools that help in the creation and development of Modules for Inductive Automation's Ignition.
49 stars 14 forks source link

De-duplicate Module.xml jar entries based on scope. #53

Closed benmusson closed 3 months ago

benmusson commented 3 months ago

The logic:

  1. Group the manifests by jarName.
  2. For each jarName, find all the scopes where it is applied and append them together in a list using flatMap.
  3. Convert this list of scopes to a set in order to deduplicate, then join back together into a string.

At this point the de-duplication is complete and the original issue is resolved. https://github.com/inductiveautomation/ignition-module-tools/issues/52

I think it would also be a good idea to force a sort order for the jars, so I added it in.

  1. Sort by scope length (jars used in more places are listed first).
  2. Sort by scope alphabetically
  3. Sort by jarName alphabetically

Before:

<jar scope="C">core-client-0.1.0.jar</jar>
<jar scope="C">kotlin-stdlib-2.0.0.jar</jar>
<jar scope="C">annotations-13.0.jar</jar>
<jar scope="C">if97-steam-tables-client-0.1.0.jar</jar>
<jar scope="CDG">core-common-0.3.0.jar</jar>
<jar scope="CDG">if97-2.0.0.jar</jar>
<jar scope="CDG">kotlin-stdlib-2.0.0.jar</jar> 
<jar scope="CDG">annotations-13.0.jar</jar>
<jar scope="CDG">if97-steam-tables-common-0.1.0.jar</jar>
<jar scope="D">core-designer-0.3.0.jar</jar>
<jar scope="D">kotlin-stdlib-2.0.0.jar</jar>
<jar scope="D">annotations-13.0.jar</jar>
<jar scope="D">if97-steam-tables-designer-0.1.0.jar</jar>
<jar scope="G">core-gateway-0.3.0.jar</jar>
<jar scope="G">kotlin-stdlib-2.0.0.jar</jar>
<jar scope="G">annotations-13.0.jar</jar>
<jar scope="G">if97-steam-tables-gateway-0.1.0.jar</jar>

After:

<jar scope="CDG">annotations-13.0.jar</jar>
<jar scope="CDG">core-common-0.3.0.jar</jar>
<jar scope="CDG">if97-2.0.0.jar</jar>
<jar scope="CDG">if97-steam-tables-common-0.1.0.jar</jar>
<jar scope="CDG">kotlin-stdlib-2.0.0.jar</jar>
<jar scope="C">core-client-0.1.0.jar</jar>
<jar scope="C">if97-steam-tables-client-0.1.0.jar</jar>
<jar scope="D">core-designer-0.3.0.jar</jar>
<jar scope="D">if97-steam-tables-designer-0.1.0.jar</jar>
<jar scope="G">core-gateway-0.3.0.jar</jar>
<jar scope="G">if97-steam-tables-gateway-0.1.0.jar</jar>
brianeray commented 3 months ago

Hi @benmusson , thanks for the PR. Can you add a unit test in WriteModuleXmlTest.kt?

benmusson commented 3 months ago

@brianeray rebased/squashed

brianeray commented 3 months ago

@benmusson can you take a look at my stab in #56? I'll probably pull in a reviewer from our side too, someone who knows module dev, because I'm a build engineer.

My focus is too narrow. I can do stuff in Gradle and JVM languages but not have the bigger picture in focus.

brianeray commented 3 months ago

One final (🤞 ) bit of ping pong after the module developers here weighed in. It's in my new draft PR #57 at the last commit 22946e2.