Skip to content

Commit

Permalink
https://github.com/mojohaus/flatten-maven-plugin/runs/5890341535?chec…
Browse files Browse the repository at this point in the history
…k_suite_focus=true#step:4:181
  • Loading branch information
ca-stefan-cordes committed Aug 8, 2022
1 parent 9aabd0c commit 948df1c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
Expand Up @@ -44,6 +44,10 @@ public class KeepCommentsInPomTest {
private static final String TEST_TARGET_PATH = "target/test/resources/keep-comments-in-pom/";
private static final String FLATTENED_POM = TEST_TARGET_PATH + ".flattened-pom.xml";
private static final String EXPECTED_FLATTENED_POM = PATH + "expected-flattened-pom.xml";
/**
* Expected result since jdk11 with updated xml header and properties sequence.
*/
private static final String EXPECTED_FLATTENED_POM_JDK11 = PATH + "expected-flattened-pom-jdk11.xml";

@Rule
public MojoRule rule = new MojoRule();
Expand All @@ -70,13 +74,31 @@ public void keepsProfileActivationFile() throws Exception {
// execute writes new FLATTENED_POM
flattenMojo.execute();

String tempExpectedContent = getContent(EXPECTED_FLATTENED_POM);
String tempExpectedContent;
if (isJdk8()) {
tempExpectedContent = getContent(EXPECTED_FLATTENED_POM);
} else {
tempExpectedContent = getContent(EXPECTED_FLATTENED_POM_JDK11);
}
String tempActualContent = getContent(FLATTENED_POM);
assertEquals("Expected POM does not match, see "+FLATTENED_POM, tempExpectedContent,tempActualContent);

}

/**
* Check runtime version.
*
* @return true when runtime is JDK11
*/
private boolean isJdk8() {
// With Java 9 can be switched to java.lang.Runtime.version()
String tempPropertyVersion = System.getProperty("java.version");
if (tempPropertyVersion.startsWith("1.8.")) {
return true;
}
return false;
}
/**
*
*/
private String getContent(String aPomFile) throws IOException {
Expand Down
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?><project 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>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>resolve-properties-ci-do-not-interpolate-profile-activation-file</artifactId>
<version>1.2.3.4</version>
<properties>
<propertyWithoutComment>test-propertyWithoutComment</propertyWithoutComment>
<!-- comment1 for propertyWithTwoComments -->
<!-- comment2 for propertyWithTwoComments -->
<propertyWithTwoComments>test-propertyWithTwoComments</propertyWithTwoComments>
<!-- some nice comment -->
<revision>1.2.3.4</revision>
</properties>
<build>
<defaultGoal>verify</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
</plugin>
<plugin>
<!-- plugin with multiple same node names -->
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/TestCircle.java</exclude>
<exclude>**/TestCircle2.java</exclude>
<!-- special info for TestSquare -->
<exclude>**/TestSquare.java</exclude>
<!-- special info for TestSquare2 -->
<exclude>**/TestSquare2.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- another comment what the profile is doing -->
<activation>
<file>
<exists>file.txt</exists>
</file>
</activation>
</profile>
<profile>
<id>multiline-profile</id>
<!-- comment with
multiple lines
in a profile -->
<activation/>
</profile>
</profiles>
</project>

0 comments on commit 948df1c

Please sign in to comment.