@Test public void setVersions() throws IOException { final Path root = BASEDIR.resolve("target/test-classes/MavenSourceTree/set-versions"); final MavenSourceTree t = new Builder(root, StandardCharsets.UTF_8).pomXml(root.resolve("pom.xml")).build(); t.setVersions("2.2.2", ActiveProfiles.of()); final Path expectedRoot = BASEDIR.resolve("target/test-classes/MavenSourceTree/set-versions-expected"); for (String path : t.getModulesByPath().keySet()) { final Path actualPath = root.resolve(path); final Path expectedPath = expectedRoot.resolve(path); Assert.assertEquals(new String(Files.readAllBytes(expectedPath), StandardCharsets.UTF_8), new String(Files.readAllBytes(actualPath), StandardCharsets.UTF_8).replace("\r", "")); } }
public void setVersions(final String newVersion, final Predicate<Profile> isProfileActive) { final DomEdits edits = new DomEdits(); for (Module module : modulesByGa.values()) { final GavExpression parentGav = module.getParentGav(); final Expression moduleVersion = module.getGav().getVersion(); if (parentGav == null || !moduleVersion.equals(module.getParentGav().getVersion())) { edit(newVersion, isProfileActive, edits, module, moduleVersion, xPath("project", "version")); } if (parentGav != null && modulesByGa.containsKey(parentGav.resolveGa(this, isProfileActive))) { final Expression parentVersion = parentGav.getVersion(); edit(newVersion, isProfileActive, edits, module, parentVersion, xPath("project", "parent", "version")); } for (Profile profile : module.getProfiles()) { final String profileId = profile.getId(); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencyManagement(), "dependencyManagement", "dependencies"); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencies(), "dependencies"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPluginManagement(), "build", "pluginManagement", "plugins"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPlugins(), "build", "plugins"); editExtensions(newVersion, isProfileActive, edits, module, profileId, profile.getExtensions(), "build", "extensions"); } } edits.perform(rootDirectory, encoding); }
MavenSourceTree { public void setVersions(final String newVersion, final Predicate<Profile> isProfileActive) { final DomEdits edits = new DomEdits(); for (Module module : modulesByGa.values()) { final GavExpression parentGav = module.getParentGav(); final Expression moduleVersion = module.getGav().getVersion(); if (parentGav == null || !moduleVersion.equals(module.getParentGav().getVersion())) { edit(newVersion, isProfileActive, edits, module, moduleVersion, xPath("project", "version")); } if (parentGav != null && modulesByGa.containsKey(parentGav.resolveGa(this, isProfileActive))) { final Expression parentVersion = parentGav.getVersion(); edit(newVersion, isProfileActive, edits, module, parentVersion, xPath("project", "parent", "version")); } for (Profile profile : module.getProfiles()) { final String profileId = profile.getId(); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencyManagement(), "dependencyManagement", "dependencies"); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencies(), "dependencies"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPluginManagement(), "build", "pluginManagement", "plugins"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPlugins(), "build", "plugins"); editExtensions(newVersion, isProfileActive, edits, module, profileId, profile.getExtensions(), "build", "extensions"); } } edits.perform(rootDirectory, encoding); } }
MavenSourceTree { public void setVersions(final String newVersion, final Predicate<Profile> isProfileActive) { final DomEdits edits = new DomEdits(); for (Module module : modulesByGa.values()) { final GavExpression parentGav = module.getParentGav(); final Expression moduleVersion = module.getGav().getVersion(); if (parentGav == null || !moduleVersion.equals(module.getParentGav().getVersion())) { edit(newVersion, isProfileActive, edits, module, moduleVersion, xPath("project", "version")); } if (parentGav != null && modulesByGa.containsKey(parentGav.resolveGa(this, isProfileActive))) { final Expression parentVersion = parentGav.getVersion(); edit(newVersion, isProfileActive, edits, module, parentVersion, xPath("project", "parent", "version")); } for (Profile profile : module.getProfiles()) { final String profileId = profile.getId(); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencyManagement(), "dependencyManagement", "dependencies"); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencies(), "dependencies"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPluginManagement(), "build", "pluginManagement", "plugins"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPlugins(), "build", "plugins"); editExtensions(newVersion, isProfileActive, edits, module, profileId, profile.getExtensions(), "build", "extensions"); } } edits.perform(rootDirectory, encoding); } MavenSourceTree(Path rootDirectory, Charset encoding, Map<String, Module> modulesByPath,
            Map<Ga, Module> modulesByGa); }
MavenSourceTree { public void setVersions(final String newVersion, final Predicate<Profile> isProfileActive) { final DomEdits edits = new DomEdits(); for (Module module : modulesByGa.values()) { final GavExpression parentGav = module.getParentGav(); final Expression moduleVersion = module.getGav().getVersion(); if (parentGav == null || !moduleVersion.equals(module.getParentGav().getVersion())) { edit(newVersion, isProfileActive, edits, module, moduleVersion, xPath("project", "version")); } if (parentGav != null && modulesByGa.containsKey(parentGav.resolveGa(this, isProfileActive))) { final Expression parentVersion = parentGav.getVersion(); edit(newVersion, isProfileActive, edits, module, parentVersion, xPath("project", "parent", "version")); } for (Profile profile : module.getProfiles()) { final String profileId = profile.getId(); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencyManagement(), "dependencyManagement", "dependencies"); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencies(), "dependencies"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPluginManagement(), "build", "pluginManagement", "plugins"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPlugins(), "build", "plugins"); editExtensions(newVersion, isProfileActive, edits, module, profileId, profile.getExtensions(), "build", "extensions"); } } edits.perform(rootDirectory, encoding); } MavenSourceTree(Path rootDirectory, Charset encoding, Map<String, Module> modulesByPath,
            Map<Ga, Module> modulesByGa); static MavenSourceTree of(Path rootPomXml, Charset encoding); Set<Ga> computeModuleClosure(Collection<Ga> initialModules, Predicate<Profile> isProfileActive); String evaluate(Expression expression, Predicate<Profile> isProfileActive); Set<Ga> filterDependencies(GavSet gavSet, final Predicate<Profile> isProfileActive); Charset getEncoding(); Map<Ga, Module> getModulesByGa(); Map<String, Module> getModulesByPath(); Path getRootDirectory(); Module getRootModule(); void setVersions(final String newVersion, final Predicate<Profile> isProfileActive); void unlinkUneededModules(Set<Ga> includes, Predicate<Profile> isProfileActive); }
MavenSourceTree { public void setVersions(final String newVersion, final Predicate<Profile> isProfileActive) { final DomEdits edits = new DomEdits(); for (Module module : modulesByGa.values()) { final GavExpression parentGav = module.getParentGav(); final Expression moduleVersion = module.getGav().getVersion(); if (parentGav == null || !moduleVersion.equals(module.getParentGav().getVersion())) { edit(newVersion, isProfileActive, edits, module, moduleVersion, xPath("project", "version")); } if (parentGav != null && modulesByGa.containsKey(parentGav.resolveGa(this, isProfileActive))) { final Expression parentVersion = parentGav.getVersion(); edit(newVersion, isProfileActive, edits, module, parentVersion, xPath("project", "parent", "version")); } for (Profile profile : module.getProfiles()) { final String profileId = profile.getId(); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencyManagement(), "dependencyManagement", "dependencies"); editDependencies(newVersion, isProfileActive, edits, module, profileId, profile.getDependencies(), "dependencies"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPluginManagement(), "build", "pluginManagement", "plugins"); editPlugins(newVersion, isProfileActive, edits, module, profileId, profile.getPlugins(), "build", "plugins"); editExtensions(newVersion, isProfileActive, edits, module, profileId, profile.getExtensions(), "build", "extensions"); } } edits.perform(rootDirectory, encoding); } MavenSourceTree(Path rootDirectory, Charset encoding, Map<String, Module> modulesByPath,
            Map<Ga, Module> modulesByGa); static MavenSourceTree of(Path rootPomXml, Charset encoding); Set<Ga> computeModuleClosure(Collection<Ga> initialModules, Predicate<Profile> isProfileActive); String evaluate(Expression expression, Predicate<Profile> isProfileActive); Set<Ga> filterDependencies(GavSet gavSet, final Predicate<Profile> isProfileActive); Charset getEncoding(); Map<Ga, Module> getModulesByGa(); Map<String, Module> getModulesByPath(); Path getRootDirectory(); Module getRootModule(); void setVersions(final String newVersion, final Predicate<Profile> isProfileActive); void unlinkUneededModules(Set<Ga> includes, Predicate<Profile> isProfileActive);  }