-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added a test to specify licenseSet includes from CLI
This one fails
- Loading branch information
Showing
10 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
license-maven-plugin/src/it/tri-license-set-with-includes/invoker.properties
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 @@ | ||
invoker.goals=license:format -Dlicense.licenseSets.licenseSet=src/main/java/com/mycila/it/Unformatted2.java |
2 changes: 2 additions & 0 deletions
2
license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-1.txt
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,2 @@ | ||
This is the 1st | ||
mock license |
2 changes: 2 additions & 0 deletions
2
license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-2.txt
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,2 @@ | ||
This is the 2nd | ||
mock license |
2 changes: 2 additions & 0 deletions
2
license-maven-plugin/src/it/tri-license-set-with-includes/mock-license-3.txt
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,2 @@ | ||
This is the 3rd | ||
mock license |
59 changes: 59 additions & 0 deletions
59
license-maven-plugin/src/it/tri-license-set-with-includes/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,59 @@ | ||
<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> | ||
|
||
<groupId>com.mycila.license-maven-plugin.it</groupId> | ||
<artifactId>tri-license-set</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<name>Check a Triple License Set</name> | ||
<description>Integration Test for checking a triple license set</description> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.mycila</groupId> | ||
<artifactId>license-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<licenseSets> | ||
<licenseSet> | ||
<header>mock-license-1.txt</header> | ||
<excludes> | ||
<exclude>invoker.properties</exclude> | ||
<exclude>pom.xml</exclude> | ||
<exclude>*.groovy</exclude> | ||
<exclude>**/*.bak</exclude> | ||
<exclude>*.log</exclude> | ||
<exclude>mock-license-*</exclude> | ||
<exclude>**/Unformatted2.java</exclude> | ||
<exclude>**/Unformatted3.java</exclude> | ||
</excludes> | ||
</licenseSet> | ||
<licenseSet> | ||
<header>mock-license-2.txt</header> | ||
<excludes> | ||
<exclude>invoker.properties</exclude> | ||
<exclude>pom.xml</exclude> | ||
<exclude>*.groovy</exclude> | ||
<exclude>**/*.bak</exclude> | ||
<exclude>*.log</exclude> | ||
<exclude>mock-license-*</exclude> | ||
<exclude>**/Unformatted1.java</exclude> | ||
<exclude>**/Unformatted3.java</exclude> | ||
</excludes> | ||
</licenseSet> | ||
<licenseSet> | ||
<header>mock-license-3.txt</header> | ||
<includes> | ||
<include>**/Unformatted3.java</include> | ||
</includes> | ||
</licenseSet> | ||
</licenseSets> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
23 changes: 23 additions & 0 deletions
23
license-maven-plugin/src/it/tri-license-set-with-includes/setup.groovy
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,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<String> 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; |
4 changes: 4 additions & 0 deletions
4
...plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted1.java
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,4 @@ | ||
package com.mycila.it; | ||
|
||
public class Unformatted1 { | ||
} |
4 changes: 4 additions & 0 deletions
4
...plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted2.java
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,4 @@ | ||
package com.mycila.it; | ||
|
||
public class Unformatted2 { | ||
} |
4 changes: 4 additions & 0 deletions
4
...plugin/src/it/tri-license-set-with-includes/src/main/java/com/mycila/it/Unformatted3.java
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,4 @@ | ||
package com.mycila.it; | ||
|
||
public class Unformatted3 { | ||
} |
54 changes: 54 additions & 0 deletions
54
license-maven-plugin/src/it/tri-license-set-with-includes/verify.groovy
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,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 |