Skip to content

Commit adf54ca

Browse files
committed
Make sure no extra line breaks are introduced
1 parent 6b249f9 commit adf54ca

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>jhlite-test-maven-project</artifactId>
6+
<version>0.0.1</version>
7+
<name>Test project</name>
8+
<packaging>pom</packaging>
9+
10+
<properties>
11+
<json-web-token.version>0.11.5</json-web-token.version>
12+
<logstash-logback-encoder.version>7.2</logstash-logback-encoder.version>
13+
<spring-boot.version>2.7.1</spring-boot.version>
14+
</properties>
15+
16+
<dependencyManagement>
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.springdoc</groupId>
20+
<artifactId>springdoc-openapi-ui</artifactId>
21+
<version>${springdoc-openapi.version}</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-dependencies</artifactId>
26+
<version>${spring-boot.version}</version>
27+
<scope>import</scope>
28+
<type>pom</type>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-dependencies</artifactId>
33+
<version>${spring-boot.version}</version>
34+
<scope>import</scope>
35+
</dependency>
36+
</dependencies>
37+
</dependencyManagement>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>net.logstash.logback</groupId>
42+
<artifactId>logstash-logback-encoder</artifactId>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>io.jsonwebtoken</groupId>
47+
<artifactId>jjwt-api</artifactId>
48+
<version>${json-web-token.version}</version>
49+
<classifier>classif</classifier>
50+
<scope>test</scope>
51+
<optional>true</optional>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<plugins>
57+
<plugin>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-maven-plugin</artifactId>
60+
</plugin>
61+
</plugins>
62+
<pluginManagement>
63+
<plugins>
64+
<plugin>
65+
<groupId>org.springframework.boot</groupId>
66+
<artifactId>spring-boot-maven-plugin</artifactId>
67+
<version>${spring-boot.version}</version>
68+
<executions>
69+
<execution>
70+
<goals>
71+
<goal>repackage</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
<configuration>
76+
<mainClass>${start-class}</mainClass>
77+
</configuration>
78+
</plugin>
79+
</plugins>
80+
</pluginManagement>
81+
</build>
82+
</project>

src/test/java/io/fabric8/maven/MavenTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.stream.IntStream;
1818

1919
import org.apache.maven.model.Dependency;
20+
import org.apache.maven.model.DependencyManagement;
2021
import org.apache.maven.model.Model;
2122
import org.apache.maven.model.Scm;
2223
import org.approvaltests.Approvals;
@@ -333,4 +334,20 @@ void should_write_attributes() throws Exception {
333334
Approvals.verify(sw.toString());
334335
}
335336

337+
@Test
338+
void should_not_add_extra_line_break() throws Exception {
339+
Path pom = Paths.get(getClass().getResource("extra-line-pom.xml").toURI());
340+
Model model = Maven.readModel(pom);
341+
DependencyManagement dependencyManagement = model.getDependencyManagement();
342+
Dependency dep = new Dependency();
343+
dep.setGroupId("org.springframework.boot");
344+
dep.setArtifactId("spring-boot-dependencies");
345+
dep.setVersion("${spring-boot.version}");
346+
dep.setScope("import");
347+
dependencyManagement.addDependency(dep);
348+
StringWriter sw = new StringWriter();
349+
Maven.writeModel(model, sw);
350+
Approvals.verify(sw.toString());
351+
}
352+
336353
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>jhlite-test-maven-project</artifactId>
6+
<version>0.0.1</version>
7+
<name>Test project</name>
8+
<packaging>pom</packaging>
9+
10+
<properties>
11+
<json-web-token.version>0.11.5</json-web-token.version>
12+
<logstash-logback-encoder.version>7.2</logstash-logback-encoder.version>
13+
<spring-boot.version>2.7.1</spring-boot.version>
14+
</properties>
15+
16+
<dependencyManagement>
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.springdoc</groupId>
20+
<artifactId>springdoc-openapi-ui</artifactId>
21+
<version>${springdoc-openapi.version}</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-dependencies</artifactId>
26+
<version>${spring-boot.version}</version>
27+
<scope>import</scope>
28+
<type>pom</type>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>net.logstash.logback</groupId>
36+
<artifactId>logstash-logback-encoder</artifactId>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>io.jsonwebtoken</groupId>
41+
<artifactId>jjwt-api</artifactId>
42+
<version>${json-web-token.version}</version>
43+
<classifier>classif</classifier>
44+
<scope>test</scope>
45+
<optional>true</optional>
46+
</dependency>
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-maven-plugin</artifactId>
54+
</plugin>
55+
</plugins>
56+
<pluginManagement>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-maven-plugin</artifactId>
61+
<version>${spring-boot.version}</version>
62+
<executions>
63+
<execution>
64+
<goals>
65+
<goal>repackage</goal>
66+
</goals>
67+
</execution>
68+
</executions>
69+
<configuration>
70+
<mainClass>${start-class}</mainClass>
71+
</configuration>
72+
</plugin>
73+
</plugins>
74+
</pluginManagement>
75+
</build>
76+
</project>

0 commit comments

Comments
 (0)