Skip to content

Commit d5f22c4

Browse files
committed
#6 Fixed overwriting of packageNames
1 parent 2a010c6 commit d5f22c4

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/main/java/de/codecentric/cxf/BootCxfMojo.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,17 @@ protected String generatePackageNameFromTargetNamespaceInWsdl(String targetNames
280280
}
281281

282282
protected void writeSeiAndWebServiceClientPackageToCxfSpringBootMavenPropterties(String outputDirectory, String packageName) throws MojoExecutionException {
283-
writeCxfSpringBootMavenProperties(outputDirectory, packageName, SEI_AND_WEB_SERVICE_CLIENT_PACKAGE_NAME_KEY);
283+
writeCxfSpringBootMavenProperties(outputDirectory, SEI_AND_WEB_SERVICE_CLIENT_PACKAGE_NAME_KEY, packageName);
284284
}
285285

286286
protected void writeSeiImplementationPackageToCxfSpringBootMavenPropterties(String outputDirectory, String packageName) throws MojoExecutionException {
287-
writeCxfSpringBootMavenProperties(outputDirectory, packageName, SEI_IMPLEMENTATION_PACKAGE_NAME_KEY);
287+
writeCxfSpringBootMavenProperties(outputDirectory, SEI_IMPLEMENTATION_PACKAGE_NAME_KEY, packageName);
288288
}
289289

290-
protected void writeCxfSpringBootMavenProperties(String outputDirectory, String packageName, String propertyKey) throws MojoExecutionException {
290+
protected void writeCxfSpringBootMavenProperties(String outputDirectory, String propertyKey, String packageName) throws MojoExecutionException {
291291
try {
292292
File cxfSpringBootMavenProperties = new File(outputDirectory + "/" + CXF_SPRING_BOOT_MAVEN_PROPERTIES_FILE_NAME);
293-
FileUtils.writeStringToFile(cxfSpringBootMavenProperties, propertyKey + "=" + packageName, Charset.defaultCharset());
293+
FileUtils.writeStringToFile(cxfSpringBootMavenProperties, propertyKey + "=" + packageName + "\n", Charset.defaultCharset(), true);
294294

295295
} catch (IOException ioExc) {
296296
throw new MojoExecutionException("Could not inject packageName into " + CXF_SPRING_BOOT_MAVEN_PROPERTIES_FILE_NAME + "." +

src/test/java/de/codecentric/cxf/BootCxfMojoTest.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class BootCxfMojoTest {
5757
@Test public void
5858
does_write_cxfSpringBootMavenProperties() throws MojoExecutionException, IOException {
5959

60-
bootCxfMojo.writeCxfSpringBootMavenProperties(buildDirectory, "foo.bar", "foo.key");
60+
bootCxfMojo.writeCxfSpringBootMavenProperties(buildDirectory, "foo.key", "foo.bar");
6161

6262
File cxfSpringBootMavenProperties = findCxfSpringBootMavenPropertiesInClasspath();
6363
assertThat(cxfSpringBootMavenProperties.getName(), is(equalTo(BootCxfMojo.CXF_SPRING_BOOT_MAVEN_PROPERTIES_FILE_NAME)));
@@ -87,6 +87,16 @@ public class BootCxfMojoTest {
8787
assertThat(content, containsString(BootCxfMojo.SEI_IMPLEMENTATION_PACKAGE_NAME_KEY + "=" + seiImplementationPackageName));
8888
}
8989

90+
@Test public void
91+
does_not_overwrite_packages_in_cxfSpringBootMavenProperties_file() throws MojoExecutionException, IOException {
92+
bootCxfMojo.writeCxfSpringBootMavenProperties(buildDirectory, "foo.key", "foo.bar");
93+
bootCxfMojo.writeCxfSpringBootMavenProperties(buildDirectory, "bar.key", "bar.boar");
94+
95+
String content = FileUtils.readFileToString(findCxfSpringBootMavenPropertiesInClasspath(), Charset.defaultCharset());
96+
assertThat(content, containsString("foo.key" + "=" + "foo.bar"));
97+
assertThat(content, containsString("bar.key" + "=" + "bar.boar"));
98+
}
99+
90100
private File findCxfSpringBootMavenPropertiesInClasspath() throws IOException {
91101
return findInClasspath("classpath*:**/" + BootCxfMojo.CXF_SPRING_BOOT_MAVEN_PROPERTIES_FILE_NAME).getFile();
92102
}

0 commit comments

Comments
 (0)