-
-
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.
Merge pull request #170 from adamretter/feature/license-sets
License Sets feature - allows one execution to check different licenses
- Loading branch information
Showing
60 changed files
with
1,336 additions
and
342 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
1 change: 1 addition & 0 deletions
1
license-maven-plugin/src/it/legacy-config-and-license-set/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 |
2 changes: 2 additions & 0 deletions
2
license-maven-plugin/src/it/legacy-config-and-license-set/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/legacy-config-and-license-set/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 |
53 changes: 53 additions & 0 deletions
53
license-maven-plugin/src/it/legacy-config-and-license-set/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,53 @@ | ||
<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>legacy-config-and-license-set</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<name>Check Legacy Configuration mixed with LicenseSet Configuration</name> | ||
<description>Integration Test for checking legacy configuration when used with license set configuration</description> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.mycila</groupId> | ||
<artifactId>license-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
|
||
<!-- legacy config --> | ||
<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> | ||
</excludes> | ||
|
||
<!-- license sets config --> | ||
<licenseSets> | ||
<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> | ||
</excludes> | ||
</licenseSet> | ||
</licenseSets> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
25 changes: 25 additions & 0 deletions
25
license-maven-plugin/src/it/legacy-config-and-license-set/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,25 @@ | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import java.util.Arrays | ||
import java.util.List | ||
|
||
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") | ||
|
||
for (final String filename : ALL_FILES) { | ||
final Path unformattedJavaFile = base.resolve("src/main/java/com/mycilla/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
...lugin/src/it/legacy-config-and-license-set/src/main/java/com/mycilla/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
...lugin/src/it/legacy-config-and-license-set/src/main/java/com/mycilla/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 { | ||
} |
53 changes: 53 additions & 0 deletions
53
license-maven-plugin/src/it/legacy-config-and-license-set/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,53 @@ | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import java.util.Arrays | ||
import java.util.List | ||
|
||
import static org.junit.Assert.* | ||
|
||
|
||
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 <= 2; 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/mycilla/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/mycilla/it/" + filename) | ||
if (!Files.exists(formattedJavaFile)) { | ||
System.err.println(formattedJavaFile.getFileName() + " file is missing.") | ||
return false | ||
} | ||
|
||
final StringBuilder expected = new StringBuilder(); | ||
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 |
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 |
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 a | ||
mock license |
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,33 @@ | ||
<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>legacy-config</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<name>Check Legacy Configuration</name> | ||
<description>Integration Test for checking legacy configuration</description> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.mycila</groupId> | ||
<artifactId>license-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<header>mock-license.txt</header> | ||
<excludes> | ||
<exclude>invoker.properties</exclude> | ||
<exclude>pom.xml</exclude> | ||
<exclude>*.groovy</exclude> | ||
<exclude>**/*.bak</exclude> | ||
<exclude>*.log</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
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,19 @@ | ||
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 Path unformattedJavaFile = base.resolve("src/main/java/com/mycilla/it/Unformatted1.java") | ||
if (!Files.exists(unformattedJavaFile)) { | ||
System.err.println("Unformatted1.java file is missing.") | ||
return false | ||
} | ||
|
||
Files.copy(unformattedJavaFile, unformattedJavaFile.resolveSibling("Unformatted1.java.bak")) | ||
|
||
return true; |
4 changes: 4 additions & 0 deletions
4
license-maven-plugin/src/it/legacy-config/src/main/java/com/mycilla/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 { | ||
} |
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,46 @@ | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
|
||
import static org.junit.Assert.* | ||
|
||
|
||
final Path base = basedir.toPath() | ||
|
||
if (!Files.exists(base) || !Files.isDirectory(base)) { | ||
System.err.println("base directory is missing.") | ||
return false | ||
} | ||
|
||
final Path license = base.resolve("mock-license.txt") | ||
if (!Files.exists(license)) { | ||
System.err.println("license file is missing.") | ||
return false | ||
} | ||
|
||
final Path unformattedJavaFile = base.resolve("src/main/java/com/mycilla/it/Unformatted1.java.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/mycilla/it/Unformatted1.java") | ||
if (!Files.exists(formattedJavaFile)) { | ||
System.err.println(formattedJavaFile.getFileName() + " file is missing.") | ||
return false | ||
} | ||
|
||
final StringBuilder expected = new StringBuilder(); | ||
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 |
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 |
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 |
Oops, something went wrong.