-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow indentation in target POM (#113)
* Add indent test (failing) * Fix indentation issues * Filter out shaded content * Remove unused method * Fix assertion --------- Co-authored-by: George Gastaldi <[email protected]>
- Loading branch information
Showing
9 changed files
with
170 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URISyntaxException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
|
||
import org.apache.maven.model.Dependency; | ||
|
@@ -10,6 +13,8 @@ | |
import org.apache.maven.model.merge.ModelMerger; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.fabric8.maven.Maven; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">George Gastaldi</a> | ||
*/ | ||
|
@@ -58,7 +63,7 @@ public void should_copy_profiles() { | |
|
||
merger.merge(target, source, false, null); | ||
|
||
assertThat(target.getProfiles().contains(profile)); | ||
assertThat(target.getProfiles()).contains(profile); | ||
} | ||
|
||
@Test | ||
|
@@ -89,4 +94,26 @@ public void should_merge_profiles() { | |
assertThat(target.getProfiles().get(0).getModules()).containsExactly("A", "B", "C", "D", "E", "F"); | ||
} | ||
|
||
@Test | ||
void should_keep_target_indent_2() throws URISyntaxException { | ||
ModelMerger merger = new SmartModelMerger(); | ||
final Model source = Maven.readModel(Paths.get(getClass().getResource("indent/source-pom.xml").toURI())); | ||
final Path targetFile = Paths.get(getClass().getResource("indent/pom-2.xml").toURI()); | ||
final Model target = Maven.readModel(targetFile); | ||
merger.merge(target, source, false, null); | ||
Maven.writeModel(target, targetFile); | ||
assertThat(targetFile).hasSameTextualContentAs(Paths.get(getClass().getResource("indent/result-pom-2.xml").toURI())); | ||
} | ||
|
||
@Test | ||
void should_keep_target_indent_4() throws URISyntaxException { | ||
ModelMerger merger = new SmartModelMerger(); | ||
final Model source = Maven.readModel(Paths.get(getClass().getResource("indent/source-pom.xml").toURI())); | ||
final Path targetFile = Paths.get(getClass().getResource("indent/pom-4.xml").toURI()); | ||
final Model target = Maven.readModel(targetFile); | ||
merger.merge(target, source, true, null); | ||
Maven.writeModel(target, targetFile); | ||
assertThat(targetFile).hasSameTextualContentAs(Paths.get(getClass().getResource("indent/result-pom-4.xml").toURI())); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/test/resources/io/fabric8/maven/merge/indent/pom-2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss</groupId> | ||
<artifactId>jboss-parent</artifactId> | ||
<version>29</version> | ||
</parent> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>maven-model-interpreter</artifactId> | ||
<version>2-SNAPSHOT</version> | ||
<dependencies> | ||
<!-- Maven model --> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
src/test/resources/io/fabric8/maven/merge/indent/pom-4.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss</groupId> | ||
<artifactId>jboss-parent</artifactId> | ||
<version>29</version> | ||
</parent> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>maven-model-interpreter</artifactId> | ||
<version>2-SNAPSHOT</version> | ||
<dependencies> | ||
<!-- Maven model --> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
25 changes: 25 additions & 0 deletions
25
src/test/resources/io/fabric8/maven/merge/indent/result-pom-2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss</groupId> | ||
<artifactId>jboss-parent</artifactId> | ||
<version>29</version> | ||
</parent> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>maven-model-interpreter</artifactId> | ||
<version>2-SNAPSHOT</version> | ||
<dependencies> | ||
<!-- Maven model --> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model-builder</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
25 changes: 25 additions & 0 deletions
25
src/test/resources/io/fabric8/maven/merge/indent/result-pom-4.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss</groupId> | ||
<artifactId>jboss-parent</artifactId> | ||
<version>29</version> | ||
</parent> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>maven-model-interpreter</artifactId> | ||
<version>2-SNAPSHOT</version> | ||
<dependencies> | ||
<!-- Maven model --> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model-builder</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
15 changes: 15 additions & 0 deletions
15
src/test/resources/io/fabric8/maven/merge/indent/source-pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model-builder</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>3.5.4</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |