protected Hashtable removeDuplicateAndValidateInfos(AbstractSession session) {
   Hashtable infoHashtable = new Hashtable();
   for (int i = 0; i < infos.size(); i++) {
     Info info1 = infos.get(i);
     info1 = (Info) info1.clone();
     DatabaseField descField = getDescriptor().buildField(info1.getField());
     if (info1.getField().getType() == null) {
       info1.setField(descField);
     } else {
       // keep the original type if specified
       info1.getField().setName(descField.getName());
       info1
           .getField()
           .setTableName(
               getDescriptor().getDefaultTable().getQualifiedNameDelimited(session.getPlatform()));
     }
     Info info2 = (Info) infoHashtable.get(info1.getField());
     if (info2 == null) {
       infoHashtable.put(info1.getField(), info1);
     } else {
       Info infoMerged = mergeInfos(info1, info2, session, getDescriptor());
       if (infoMerged != null) {
         // substitute info2 with infoMerged
         infoHashtable.put(infoMerged.getField(), infoMerged);
       } else {
         // couldn't merge info1 and info2 due to a conflict.
         // substitute info2 with info1
         infoHashtable.put(info1.getField(), info1);
       }
     }
   }
   return infoHashtable;
 }
Beispiel #2
0
  private MavenProjectModifications setModel(
      MavenModelReaderResult readerResult, boolean clearArtifacts, boolean clearProfiles) {
    Info newInfo = info.clone();
    newInfo.problems = readerResult.getProblems();
    newInfo.activeProfiles = readerResult.getActiveProfiles();
    MavenModel model = readerResult.getMavenModel();
    newInfo.mavenKey = model.getMavenKey();
    if (model.getParent() != null) {
      newInfo.parentKey = model.getParent().getMavenKey();
    }

    newInfo.packaging = model.getPackaging();
    newInfo.name = model.getName();

    newInfo.sources = model.getBuild().getSources();
    newInfo.testSources = model.getBuild().getTestSources();
    newInfo.resources = model.getBuild().getResources();
    newInfo.testResources = model.getBuild().getTestResources();
    newInfo.properties = model.getProperties();
    newInfo.filters = model.getBuild().getFilters();

    Set<MavenRemoteRepository> remoteRepositories = new HashSet<>();
    Set<MavenArtifact> extensions = new HashSet<>();
    Set<MavenArtifact> dependencies = new HashSet<>();
    Set<MavenPlugin> plugins = new HashSet<>();
    Set<MavenKey> unresolvedArtifacts = new HashSet<>();

    if (!clearArtifacts) {
      if (info.remoteRepositories != null) {
        remoteRepositories.addAll(info.remoteRepositories);
      }
      if (info.extensions != null) {
        extensions.addAll(info.extensions);
      }
      if (info.dependencies != null) {
        dependencies.addAll(info.dependencies);
      }
      if (info.plugins != null) {
        plugins.addAll(info.plugins);
      }
      if (info.unresolvedArtifacts != null) {
        unresolvedArtifacts.addAll(info.unresolvedArtifacts);
      }
    }

    remoteRepositories.addAll(model.getRemoteRepositories());
    extensions.addAll(model.getExtensions());
    dependencies.addAll(model.getDependencies());
    plugins.addAll(model.getPlugins());
    unresolvedArtifacts.addAll(readerResult.getUnresolvedArtifacts());

    newInfo.remoteRepositories = new ArrayList<>(remoteRepositories);
    newInfo.extensions = new ArrayList<>(extensions);
    newInfo.dependencies = new ArrayList<>(dependencies);
    newInfo.plugins = new ArrayList<>(plugins);
    newInfo.unresolvedArtifacts = unresolvedArtifacts;

    newInfo.modulesNameToPath = collectModulesNameAndPath(model);
    // TODO add profiles

    return setInfo(newInfo);
  }