@Test public void validateConsistentTychoVersionWithSameVersion() throws MavenExecutionException { TychoMavenLifecycleParticipant tycho = new TychoMavenLifecycleParticipant(new SilentLog()); MavenProject project = createProject(); addTychoPlugin(project, "tycho-packaging-plugin", "0.22.0"); addTychoPlugin(project, "tycho-versions-plugin", "0.22.0"); tycho.validateConsistentTychoVersion(Arrays.asList(project)); }
protected void validateConsistentTychoVersion(List<MavenProject> projects) throws MavenExecutionException { Map<String, Set<MavenProject>> versionToProjectsMap = new HashMap<>(); for (MavenProject project : projects) { for (Plugin plugin : project.getBuild().getPlugins()) { if (TYCHO_GROUPID.equals(plugin.getGroupId()) && TYCHO_PLUGIN_IDS.contains(plugin.getArtifactId())) { String version = plugin.getVersion(); if (version == null) { continue; } log.debug(TYCHO_GROUPID + ":" + plugin.getArtifactId() + ":" + version + " configured in " + project); Set<MavenProject> projectSet = versionToProjectsMap.get(version); if (projectSet == null) { projectSet = new LinkedHashSet<>(); versionToProjectsMap.put(version, projectSet); } projectSet.add(project); } } } if (versionToProjectsMap.size() > 1) { List<String> versions = new ArrayList<>(versionToProjectsMap.keySet()); Collections.sort(versions); log.error("Several versions of tycho plugins are configured " + versions + ":"); for (String version : versions) { log.error(version + ":"); for (MavenProject project : versionToProjectsMap.get(version)) { log.error("\t" + project.toString()); } } throw new MavenExecutionException("All tycho plugins configured in one reactor must use the same version", projects.get(0).getFile()); } }
TychoMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant { protected void validateConsistentTychoVersion(List<MavenProject> projects) throws MavenExecutionException { Map<String, Set<MavenProject>> versionToProjectsMap = new HashMap<>(); for (MavenProject project : projects) { for (Plugin plugin : project.getBuild().getPlugins()) { if (TYCHO_GROUPID.equals(plugin.getGroupId()) && TYCHO_PLUGIN_IDS.contains(plugin.getArtifactId())) { String version = plugin.getVersion(); if (version == null) { continue; } log.debug(TYCHO_GROUPID + ":" + plugin.getArtifactId() + ":" + version + " configured in " + project); Set<MavenProject> projectSet = versionToProjectsMap.get(version); if (projectSet == null) { projectSet = new LinkedHashSet<>(); versionToProjectsMap.put(version, projectSet); } projectSet.add(project); } } } if (versionToProjectsMap.size() > 1) { List<String> versions = new ArrayList<>(versionToProjectsMap.keySet()); Collections.sort(versions); log.error("Several versions of tycho plugins are configured " + versions + ":"); for (String version : versions) { log.error(version + ":"); for (MavenProject project : versionToProjectsMap.get(version)) { log.error("\t" + project.toString()); } } throw new MavenExecutionException("All tycho plugins configured in one reactor must use the same version", projects.get(0).getFile()); } } }
TychoMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant { protected void validateConsistentTychoVersion(List<MavenProject> projects) throws MavenExecutionException { Map<String, Set<MavenProject>> versionToProjectsMap = new HashMap<>(); for (MavenProject project : projects) { for (Plugin plugin : project.getBuild().getPlugins()) { if (TYCHO_GROUPID.equals(plugin.getGroupId()) && TYCHO_PLUGIN_IDS.contains(plugin.getArtifactId())) { String version = plugin.getVersion(); if (version == null) { continue; } log.debug(TYCHO_GROUPID + ":" + plugin.getArtifactId() + ":" + version + " configured in " + project); Set<MavenProject> projectSet = versionToProjectsMap.get(version); if (projectSet == null) { projectSet = new LinkedHashSet<>(); versionToProjectsMap.put(version, projectSet); } projectSet.add(project); } } } if (versionToProjectsMap.size() > 1) { List<String> versions = new ArrayList<>(versionToProjectsMap.keySet()); Collections.sort(versions); log.error("Several versions of tycho plugins are configured " + versions + ":"); for (String version : versions) { log.error(version + ":"); for (MavenProject project : versionToProjectsMap.get(version)) { log.error("\t" + project.toString()); } } throw new MavenExecutionException("All tycho plugins configured in one reactor must use the same version", projects.get(0).getFile()); } } TychoMavenLifecycleParticipant(); protected  TychoMavenLifecycleParticipant(Logger log); }
TychoMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant { protected void validateConsistentTychoVersion(List<MavenProject> projects) throws MavenExecutionException { Map<String, Set<MavenProject>> versionToProjectsMap = new HashMap<>(); for (MavenProject project : projects) { for (Plugin plugin : project.getBuild().getPlugins()) { if (TYCHO_GROUPID.equals(plugin.getGroupId()) && TYCHO_PLUGIN_IDS.contains(plugin.getArtifactId())) { String version = plugin.getVersion(); if (version == null) { continue; } log.debug(TYCHO_GROUPID + ":" + plugin.getArtifactId() + ":" + version + " configured in " + project); Set<MavenProject> projectSet = versionToProjectsMap.get(version); if (projectSet == null) { projectSet = new LinkedHashSet<>(); versionToProjectsMap.put(version, projectSet); } projectSet.add(project); } } } if (versionToProjectsMap.size() > 1) { List<String> versions = new ArrayList<>(versionToProjectsMap.keySet()); Collections.sort(versions); log.error("Several versions of tycho plugins are configured " + versions + ":"); for (String version : versions) { log.error(version + ":"); for (MavenProject project : versionToProjectsMap.get(version)) { log.error("\t" + project.toString()); } } throw new MavenExecutionException("All tycho plugins configured in one reactor must use the same version", projects.get(0).getFile()); } } TychoMavenLifecycleParticipant(); protected  TychoMavenLifecycleParticipant(Logger log); @Override void afterProjectsRead(MavenSession session); }
TychoMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant { protected void validateConsistentTychoVersion(List<MavenProject> projects) throws MavenExecutionException { Map<String, Set<MavenProject>> versionToProjectsMap = new HashMap<>(); for (MavenProject project : projects) { for (Plugin plugin : project.getBuild().getPlugins()) { if (TYCHO_GROUPID.equals(plugin.getGroupId()) && TYCHO_PLUGIN_IDS.contains(plugin.getArtifactId())) { String version = plugin.getVersion(); if (version == null) { continue; } log.debug(TYCHO_GROUPID + ":" + plugin.getArtifactId() + ":" + version + " configured in " + project); Set<MavenProject> projectSet = versionToProjectsMap.get(version); if (projectSet == null) { projectSet = new LinkedHashSet<>(); versionToProjectsMap.put(version, projectSet); } projectSet.add(project); } } } if (versionToProjectsMap.size() > 1) { List<String> versions = new ArrayList<>(versionToProjectsMap.keySet()); Collections.sort(versions); log.error("Several versions of tycho plugins are configured " + versions + ":"); for (String version : versions) { log.error(version + ":"); for (MavenProject project : versionToProjectsMap.get(version)) { log.error("\t" + project.toString()); } } throw new MavenExecutionException("All tycho plugins configured in one reactor must use the same version", projects.get(0).getFile()); } } TychoMavenLifecycleParticipant(); protected  TychoMavenLifecycleParticipant(Logger log); @Override void afterProjectsRead(MavenSession session);  }