Skip to content

Commit

Permalink
Make ConcatenationType required file. Add debug logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarrenForsythe committed Jan 27, 2018
1 parent b89f2b2 commit 318d0d4
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 123 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,10 @@ Project uses semantic versioning.

### 1.1.3 ###

* Remove final from `ConcatenationType` in mojo.
* Remove final from `ConcatenationType` in mojo.

### 1.2.0 ###

* Make `concatenationType` required.
* Add debug logger for the parmas if enable.
* Move verification to CI profile
145 changes: 76 additions & 69 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.flaw101</groupId>
<artifactId>concat-maven-plugin</artifactId>
<version>1.1.3</version>
<version>1.2.0</version>
<packaging>maven-plugin</packaging>
<name>Concat Maven Plugin</name>
<description>Maven plugin that can concatenate several files into one new file.</description>
Expand Down Expand Up @@ -160,77 +160,84 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>2.8.0</version>
<executions>
<execution>
<id>verify-pom-order</id>
<phase>process-sources</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<failBuildOnCVSS>0</failBuildOnCVSS>
<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
</configuration>
</plugin>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
<configuration>
<excludedClasses>
<excludedClasse>*HelpMojo*</excludedClasse>
</excludedClasses>
<threads>4</threads>
<coverageThreshold>86</coverageThreshold>
<mutationThreshold>90</mutationThreshold>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
<configuration>
<configFile>/.formatter.xml</configFile>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ci</id>
<build>
<plugins>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>2.8.0</version>
<executions>
<execution>
<id>verify-pom-order</id>
<phase>process-sources</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<failBuildOnCVSS>0</failBuildOnCVSS>
<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
</configuration>
</plugin>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
<configuration>
<excludedClasses>
<excludedClasse>*HelpMojo*</excludedClasse>
</excludedClasses>
<threads>4</threads>
<coverageThreshold>86</coverageThreshold>
<mutationThreshold>90</mutationThreshold>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
<configuration>
<configFile>/.formatter.xml</configFile>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploy</id>
<build>
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/io/github/flaw101/concat/ConcatMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public class ConcatMojo extends AbstractMojo {
* Type of concatenation to perform
*
* @parameter
* @required
*/
private ConcantenationType concatenationType = ConcantenationType.FILE_LIST;
private ConcantenationType concatenationType;

/**
* The resulting file
Expand Down Expand Up @@ -84,16 +85,16 @@ public class ConcatMojo extends AbstractMojo {
/**
* Append newline after each concatenation
*
* @parameter
* @parameter default-value="false"
*/
private boolean appendNewline = false;
private boolean appendNewline;

/**
* Deletes the target file before concatenation
*
* @parameter
* @parameter default-value="false"
*/
private boolean deleteTargetFile = false;
private boolean deleteTargetFile;

/*
* (non-Javadoc)
Expand All @@ -104,7 +105,9 @@ public class ConcatMojo extends AbstractMojo {
public void execute() throws MojoExecutionException {
final ConcatParams params = new ConcatParams(directory, concatFiles, outputFile,
deleteTargetFile, appendNewline, concatenationType);

if (getLog().isDebugEnabled()) {
getLog().debug("Concatenating with params" + params.toString());
}
final Injector injector = Guice.createInjector(new ConcatModule());
final ConcatService concatService = injector.getInstance(ConcatService.class);
try {
Expand Down
71 changes: 71 additions & 0 deletions src/main/java/io/github/flaw101/concat/ConcatParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,75 @@ public void addAll(final Collection<File> files) {
public String getDirectory() {
return directory;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (appendNewline ? 1231 : 1237);
result = prime * result
+ ((concatenationType == null) ? 0 : concatenationType.hashCode());
result = prime * result + (deleteTargetFile ? 1231 : 1237);
result = prime * result + ((directory == null) ? 0 : directory.hashCode());
result = prime * result + (files.hashCode());
result = prime * result + ((outputFile == null) ? 0 : outputFile.hashCode());
return result;
}

@Override
public boolean equals(Object obj) { // NOSONAR
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ConcatParams)) {
return false;
}
final ConcatParams other = (ConcatParams) obj;
if (appendNewline != other.appendNewline) {
return false;
}
if (concatenationType != other.concatenationType) {
return false;
}
if (deleteTargetFile != other.deleteTargetFile) {
return false;
}
if (directory == null) {
if (other.directory != null) {
return false;
}
}
else if (!directory.equals(other.directory)) {
return false;
}
if (other.files != null) {
return false;
}
else if (!files.equals(other.files)) {
return false;
}
if (outputFile == null) {
if (other.outputFile != null) {
return false;
}
}
else if (!outputFile.equals(other.outputFile)) {
return false;
}
return true;
}

@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("ConcatParams [directory=").append(directory)
.append(", outputFile=").append(outputFile).append(", deleteTargetFile=")
.append(deleteTargetFile).append(", appendNewline=").append(appendNewline)
.append(", files=").append(files).append(", concatenationType=")
.append(concatenationType).append("]");
return builder.toString();
}
}
11 changes: 4 additions & 7 deletions src/test/resources/test-delete-target-file-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@
<artifactId>concat-maven-plugin</artifactId>
<configuration>
<deleteTargetFile>true</deleteTargetFile>
<concatenationType>FILE_LIST</concatenationType>
<outputFile>target/concatfile.output</outputFile>
<concatFiles>
<param>src/test/resources/testfiles/file_1.input</param>
<param>src/test/resources/testfiles/file_2.input</param>
<param>src/test/resources/testfiles/file_3.input</param>
<concatFile>src/test/resources/testfiles/file_1.input</concatFile>
<concatFile>src/test/resources/testfiles/file_2.input</concatFile>
<concatFile>src/test/resources/testfiles/file_3.input</concatFile>
</concatFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>



</project>
11 changes: 4 additions & 7 deletions src/test/resources/test-missing-output-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@
<plugin>
<artifactId>concat-maven-plugin</artifactId>
<configuration>
<concatenationType>FILE_LIST</concatenationType>
<concatFiles>
<param>src/test/resources/testfiles/file_1.input</param>
<param>src/test/resources/testfiles/file_2.input</param>
<param>src/test/resources/testfiles/file_3.input</param>
<concatFile>src/test/resources/testfiles/file_1.input</concatFile>
<concatFile>src/test/resources/testfiles/file_2.input</concatFile>
<concatFile>src/test/resources/testfiles/file_3.input</concatFile>
</concatFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>



</project>
11 changes: 4 additions & 7 deletions src/test/resources/test-newline-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@
<plugin>
<artifactId>concat-maven-plugin</artifactId>
<configuration>
<concatenationType>FILE_LIST</concatenationType>
<appendNewline>true</appendNewline>
<outputFile>target/concatfile.output</outputFile>
<concatFiles>
<param>src/test/resources/testfiles/file_1.input</param>
<param>src/test/resources/testfiles/file_2.input</param>
<param>src/test/resources/testfiles/file_3.input</param>
<concatFile>src/test/resources/testfiles/file_1.input</concatFile>
<concatFile>src/test/resources/testfiles/file_2.input</concatFile>
<concatFile>src/test/resources/testfiles/file_3.input</concatFile>
</concatFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>



</project>
10 changes: 3 additions & 7 deletions src/test/resources/test-pom-directory-competing-args.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@
DIRECTORY
</concatenationType>
<concatFiles>
<param>src/test/resources/testfiles/file_1.input</param>
<param>src/test/resources/testfiles/file_2.input</param>
<param>src/test/resources/testfiles/file_3.input</param>
<concatFile>src/test/resources/testfiles/file_1.input</concatFile>
<concatFile>src/test/resources/testfiles/file_2.input</concatFile>
<concatFile>src/test/resources/testfiles/file_3.input</concatFile>
</concatFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>



</project>
4 changes: 0 additions & 4 deletions src/test/resources/test-pom-directory-missing-directory.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@
</plugin>
</plugins>
</build>
</project>



</project>
Loading

0 comments on commit 318d0d4

Please sign in to comment.