@Test public void testPomGeneration() throws IOException { File pomFile = createDestinationFile(); Set<Dependency> dependencies = generateDependencies(); PomWriter.writePom(pomFile, GROUP_ID, ARTIFACT_ID, VERSION, dependencies); Scanner scanner = new Scanner(pomFile); StringWriter writer = new StringWriter(); String generatedFileContent = scanner.useDelimiter(DELIMITER).next(); IOUtils.copy(getClass().getResourceAsStream(POM_CMP_XML), writer); String expectedFileContent = writer.toString(); scanner.close(); assertThat(generatedFileContent.replaceAll("\\s+", ""), equalTo(expectedFileContent.replaceAll("\\s+", ""))); pomFile.delete(); }
static void writePom(File file, String groupId, String artifactId, String version, Set<Dependency> dependencies) { Model model = new Model(); model.setModelVersion(MAVEN_MODEL_VERSION); model.setArtifactId(artifactId); model.setGroupId(groupId); model.setVersion(version); model.setPackaging(PACKAGING_TYPE); model.setDependencies(new ArrayList<>(dependencies)); DefaultModelWriter writer = new DefaultModelWriter(); try { writer.write(file, (Map<String, Object>) null, model); } catch (IOException e) { LoggingSupport.logErrorMessage(e.getMessage(), e); } }
PomWriter { static void writePom(File file, String groupId, String artifactId, String version, Set<Dependency> dependencies) { Model model = new Model(); model.setModelVersion(MAVEN_MODEL_VERSION); model.setArtifactId(artifactId); model.setGroupId(groupId); model.setVersion(version); model.setPackaging(PACKAGING_TYPE); model.setDependencies(new ArrayList<>(dependencies)); DefaultModelWriter writer = new DefaultModelWriter(); try { writer.write(file, (Map<String, Object>) null, model); } catch (IOException e) { LoggingSupport.logErrorMessage(e.getMessage(), e); } } }
PomWriter { static void writePom(File file, String groupId, String artifactId, String version, Set<Dependency> dependencies) { Model model = new Model(); model.setModelVersion(MAVEN_MODEL_VERSION); model.setArtifactId(artifactId); model.setGroupId(groupId); model.setVersion(version); model.setPackaging(PACKAGING_TYPE); model.setDependencies(new ArrayList<>(dependencies)); DefaultModelWriter writer = new DefaultModelWriter(); try { writer.write(file, (Map<String, Object>) null, model); } catch (IOException e) { LoggingSupport.logErrorMessage(e.getMessage(), e); } }  }
PomWriter { static void writePom(File file, String groupId, String artifactId, String version, Set<Dependency> dependencies) { Model model = new Model(); model.setModelVersion(MAVEN_MODEL_VERSION); model.setArtifactId(artifactId); model.setGroupId(groupId); model.setVersion(version); model.setPackaging(PACKAGING_TYPE); model.setDependencies(new ArrayList<>(dependencies)); DefaultModelWriter writer = new DefaultModelWriter(); try { writer.write(file, (Map<String, Object>) null, model); } catch (IOException e) { LoggingSupport.logErrorMessage(e.getMessage(), e); } }   }
PomWriter { static void writePom(File file, String groupId, String artifactId, String version, Set<Dependency> dependencies) { Model model = new Model(); model.setModelVersion(MAVEN_MODEL_VERSION); model.setArtifactId(artifactId); model.setGroupId(groupId); model.setVersion(version); model.setPackaging(PACKAGING_TYPE); model.setDependencies(new ArrayList<>(dependencies)); DefaultModelWriter writer = new DefaultModelWriter(); try { writer.write(file, (Map<String, Object>) null, model); } catch (IOException e) { LoggingSupport.logErrorMessage(e.getMessage(), e); } }    }