Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 10, 2025

Problem

CobiGen was unable to handle version conflicts when multiple versions of the same template set existed in the adapted folder. This caused both template sets to be loaded and processed incrementally, overwriting each other and leading to unpredictable generation results.

Solution

Implemented automatic version conflict resolution in TemplateSetConfigurationManager that:

  1. Parses POM files to extract Maven coordinates (groupId, artifactId, version) from each template set
  2. Groups template sets by groupId:artifactId combination
  3. Compares versions using semantic versioning logic to identify the latest version
  4. Filters results to return only the template set with the highest version for each group

Key Features

  • Semantic version comparison: Handles versions like "1.0", "1.1", "dev-SNAPSHOT-1", etc.
  • Snapshot handling: Prefers release versions over snapshot versions when base versions are equal
  • Robust error handling: Continues processing if individual POM parsing fails
  • Detailed logging: Debug logs show which template sets are selected/skipped and why
  • Backward compatibility: Falls back gracefully if POM parsing fails

Example

Consider two template sets in the adapted folder:

  • template-set1/pom.xml: version dev-SNAPSHOT-1
  • template-set2/pom.xml: version dev-SNAPSHOT-1.1

Before: Both template sets would be loaded, causing conflicts
After: Only template-set2 (version 1.1) is loaded, with debug log:

Skipping older template set template-set1 in favor of version dev-SNAPSHOT-1.1

Testing

  • ✅ Unit tests verify version comparison logic works correctly
  • ✅ Integration tests confirm only the latest version is selected
  • ✅ Re-enabled the previously ignored system test callClassLoadingTemplateSetTestWithVersionConflict
  • ✅ Added test data with conflicting template sets to simulate real scenarios

Impact

Users can now safely have multiple versions of the same template set in their adapted folder, and CobiGen will automatically use only the latest version for code generation, ensuring consistent and predictable behavior.

Fixes #1665.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repository.sonatype.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.10/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.10/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.10 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.10/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/cobigen/cobigen org.codehaus.plexus.classworlds.launcher.Launcher clean (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: maybeec <1427255+maybeec@users.noreply.github.com>
…e tests

Co-authored-by: maybeec <1427255+maybeec@users.noreply.github.com>
Copilot AI changed the title [WIP] CobiGen can't handle a version conflict of template sets Implement version conflict resolution for CobiGen template sets Jul 10, 2025
Copilot AI requested a review from maybeec July 10, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CobiGen can't handle a version conflict of template sets

3 participants