diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/invoker.properties b/license-maven-plugin/src/it/tri-license-set-with-includes/invoker.properties new file mode 100644 index 000000000..a18fd80da --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/invoker.properties @@ -0,0 +1 @@ +invoker.goals=license:format -Dlicense.licenseSets.licenseSet=src/main/java/com/mycila/it/Unformatted2.java diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-1.txt b/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-1.txt new file mode 100644 index 000000000..cd4a9d5f0 --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-1.txt @@ -0,0 +1,2 @@ +This is the 1st +mock license \ No newline at end of file diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-2.txt b/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-2.txt new file mode 100644 index 000000000..891e9697e --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-2.txt @@ -0,0 +1,2 @@ +This is the 2nd +mock license \ No newline at end of file diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-3.txt b/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-3.txt new file mode 100644 index 000000000..4a01d0771 --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-3.txt @@ -0,0 +1,2 @@ +This is the 3rd +mock license \ No newline at end of file diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/pom.xml b/license-maven-plugin/src/it/tri-license-set-with-includes/pom.xml new file mode 100644 index 000000000..6a3f5e9df --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + + com.mycila.license-maven-plugin.it + tri-license-set + 1.0.0 + + Check a Triple License Set + Integration Test for checking a triple license set + + + + + com.mycila + license-maven-plugin + @project.version@ + + + +
mock-license-1.txt
+ + invoker.properties + pom.xml + *.groovy + **/*.bak + *.log + mock-license-* + **/Unformatted2.java + **/Unformatted3.java + +
+ +
mock-license-2.txt
+ + invoker.properties + pom.xml + *.groovy + **/*.bak + *.log + mock-license-* + **/Unformatted1.java + **/Unformatted3.java + +
+ +
mock-license-3.txt
+ + **/Unformatted3.java + +
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/setup.groovy b/license-maven-plugin/src/it/tri-license-set-with-includes/setup.groovy new file mode 100644 index 000000000..43586ed3f --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/setup.groovy @@ -0,0 +1,23 @@ +import java.nio.file.Files +import java.nio.file.Path + +final Path base = basedir.toPath() + +if (!Files.exists(base) || !Files.isDirectory(base)) { + System.err.println("base directory is missing.") + return false +} + +final List ALL_FILES = Arrays.asList("Unformatted1.java", "Unformatted2.java", "Unformatted3.java") + +for (final String filename : ALL_FILES) { + final Path unformattedJavaFile = base.resolve("src/main/java/com/mycila/it/" + filename) + if (!Files.exists(unformattedJavaFile)) { + System.err.println(filename + " file is missing.") + return false + } + + Files.copy(unformattedJavaFile, unformattedJavaFile.resolveSibling(filename + ".bak")) +} + +return true; diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted1.java b/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted1.java new file mode 100644 index 000000000..53c628eba --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted1.java @@ -0,0 +1,4 @@ +package com.mycila.it; + +public class Unformatted1 { +} diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted2.java b/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted2.java new file mode 100644 index 000000000..2c4311d3c --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted2.java @@ -0,0 +1,4 @@ +package com.mycila.it; + +public class Unformatted2 { +} diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted3.java b/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted3.java new file mode 100644 index 000000000..d24e2823e --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted3.java @@ -0,0 +1,4 @@ +package com.mycila.it; + +public class Unformatted3 { +} diff --git a/license-maven-plugin/src/it/tri-license-set-with-includes/verify.groovy b/license-maven-plugin/src/it/tri-license-set-with-includes/verify.groovy new file mode 100644 index 000000000..4e4904938 --- /dev/null +++ b/license-maven-plugin/src/it/tri-license-set-with-includes/verify.groovy @@ -0,0 +1,54 @@ +import java.nio.file.Files +import java.nio.file.Path + +import static org.junit.jupiter.api.Assertions.assertEquals + + +final Path base = basedir.toPath() + +if (!Files.exists(base) || !Files.isDirectory(base)) { + System.err.println("base directory is missing.") + return false +} + +for (int i = 1; i <= 3; i++) { + + final Path license = base.resolve("mock-license-" + i + ".txt") + if (!Files.exists(license)) { + System.err.println(license.getFileName() + " file is missing.") + return false + } + + final String filename = "Unformatted" + i + ".java" + + final Path unformattedJavaFile = base.resolve("src/main/java/com/mycila/it/" + filename + ".bak") + if (!Files.exists(unformattedJavaFile)) { + System.err.println(unformattedJavaFile.getFileName() + " file is missing (should have been created by setup.groovy).") + return false + } + + final Path formattedJavaFile = base.resolve("src/main/java/com/mycila/it/" + filename) + if (!Files.exists(formattedJavaFile)) { + System.err.println(formattedJavaFile.getFileName() + " file is missing.") + return false + } + + final StringBuilder expected = new StringBuilder(); + if (i == 2) { + expected.append("/*\n"); + license.withReader { reader -> + while ((line = reader.readLine()) != null) { + expected.append(" * ").append(line).append('\n') + } + } + expected.append(" */\n") + } + + expected.append(new String(Files.readAllBytes(unformattedJavaFile))) + + final String actual = new String(Files.readAllBytes(formattedJavaFile)) + + assertEquals(expected.toString(), actual) +} + +return true