moduleKey property

String get moduleKey

Generates a module-specific key for duplicate detection.

Implementation

String get moduleKey {
  // Check the cache
  final cacheKey = libraryKey;
  if (_moduleIdCache.containsKey(cacheKey)) {
    return _moduleIdCache[cacheKey]!;
  }

  String moduleId;

  // Detect specific known module types
  for (final pattern in _knownModulePatterns) {
    if (pattern.hasMatch(groupId)) {
      // For modules that need special handling
      if (groupId.contains('asm')) {
        // For ASM modules, use the last segment of artifactId as the module name
        moduleId = 'asm.${artifactId.split('.').last}';
        _moduleIdCache[cacheKey] = moduleId;
        return moduleId;
      } else if (groupId.contains('minecraftforge')) {
        // Special handling for Forge modules
        moduleId = 'forge.$artifactId';
        _moduleIdCache[cacheKey] = moduleId;
        return moduleId;
      } else if (groupId.contains('cpw.mods')) {
        // For CPW modules
        moduleId = 'cpw.$artifactId';
        _moduleIdCache[cacheKey] = moduleId;
        return moduleId;
      }
    }
  }

  // Standard case: combine the last groupID segment and artifactID
  final lastGroupSegment = groupId.split('.').last;
  moduleId = '$lastGroupSegment.$artifactId';

  // Save to cache
  _moduleIdCache[cacheKey] = moduleId;
  return moduleId;
}