Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Added support for excluding lines containing some specific string.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewins committed Jan 25, 2012
1 parent 7cd1eb2 commit 6f34abe
Show file tree
Hide file tree
Showing 16 changed files with 312 additions and 78 deletions.
20 changes: 9 additions & 11 deletions src/functionaltest/testprojects/combineProject/build.log
Expand Up @@ -11,8 +11,6 @@
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/combineProject/src/main/resources
[INFO] [changes:attach-changelog {execution: default}]
[INFO] snapshot it.sandbox:firstProject:1.0-SNAPSHOT: checking for updates from neo4j-repo
[INFO] snapshot it.sandbox:secondProject:1.0-SNAPSHOT: checking for updates from neo4j-repo
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
[INFO] [changes:extract-changelog {execution: default}]
Expand All @@ -34,18 +32,18 @@
T E S T S
-------------------------------------------------------
Running org.neo4j.ChangelogAttachedTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.016 sec
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Tue Jan 24 11:43:32 CET 2012
[INFO] Final Memory: 14M/213M
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Jan 25 13:54:00 CET 2012
[INFO] Final Memory: 14M/211M
[INFO] ------------------------------------------------------------------------
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
Expand Down Expand Up @@ -79,18 +77,18 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
T E S T S
-------------------------------------------------------
Running org.neo4j.ChangelogAttachedTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.015 sec
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jan 24 11:43:33 CET 2012
[INFO] Final Memory: 9M/149M
[INFO] Finished at: Wed Jan 25 13:54:02 CET 2012
[INFO] Final Memory: 10M/211M
[INFO] ------------------------------------------------------------------------
Running post-build script in: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/combineProject/validate.groovy
Finished post-build script in: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/combineProject/validate.groovy
3 changes: 3 additions & 0 deletions src/functionaltest/testprojects/combineProject/pom.xml
Expand Up @@ -68,6 +68,9 @@
<artifactId>secondProject</artifactId>
</changelogArtifact>
</changelogArtifacts>
<excludeLinesContaining>
<entry>[minor]</entry>
</excludeLinesContaining>
</configuration>
</plugin>
</plugins>
Expand Down
Expand Up @@ -11,28 +11,37 @@
import org.junit.Test;

public class ChangelogAttachedTest {

private static final String OUTPUT_CHANGELOG = "CHANGES.txt";

private static final String EXPECTED_CHANGELOG_CONTENT =
"1.0 (2012-01-19)\n"+
"----------------\n"+
"o Fixes issues #173, #118, #138, #103\n\n";
"1.0-SNAPSHOT (2012-1-25)\n" +
"-------------------------\n" +
"\n" +
"it.sandbox.combineProject:\n" +
"o Fixes issues #173, #118, #138, #103\n" +
"\n" +
"\n" +
"it.sandbox.firstProject:\n" +
"o Fixes issues #173, #118, #138, #103\n" +
// This line is in the firstProject changelog,
// but we are expecting it to be excluded here.
//"o Made some changes [minor]\n" +
"\n" +
"\n" +
"it.sandbox.secondProject:\n" +
"o Fixes issues #173, #118, #138, #103\n\n\n";

private File output = new File("target/classes");
private File output = new File("target/CHANGES.txt");

@Test
@Ignore
public void outputFilesShouldExist() throws Exception
{
assertExists(new File(output, OUTPUT_CHANGELOG));
assertExists(output);
}

@Test
@Ignore
public void outputFileShouldContainExpectedContent() throws Exception
{
File changelog = new File(output, OUTPUT_CHANGELOG);
assertContains(changelog, EXPECTED_CHANGELOG_CONTENT);
assertContains(output, EXPECTED_CHANGELOG_CONTENT);
}

private static void assertExists(File file) throws Exception
Expand Down
1 change: 1 addition & 0 deletions src/functionaltest/testprojects/firstProject/CHANGES.txt
@@ -1,6 +1,7 @@
1.0 (2012-01-19)
----------------
o Fixes issues #173, #118, #138, #103
o Made some changes [minor]

1.0.M02 (2011-11-24)
--------------------
Expand Down
16 changes: 8 additions & 8 deletions src/functionaltest/testprojects/firstProject/build.log
Expand Up @@ -32,17 +32,17 @@
T E S T S
-------------------------------------------------------
Running org.neo4j.ChangelogAttachedTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.019 sec
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jan 24 11:43:22 CET 2012
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Jan 25 13:53:55 CET 2012
[INFO] Final Memory: 14M/214M
[INFO] ------------------------------------------------------------------------
+ Error stacktraces are turned on.
Expand Down Expand Up @@ -77,11 +77,11 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
T E S T S
-------------------------------------------------------
Running org.neo4j.ChangelogAttachedTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.016 sec
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/firstProject/target/singleChangelogTest.jar
Expand All @@ -92,8 +92,8 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jan 24 11:43:24 CET 2012
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Jan 25 13:53:57 CET 2012
[INFO] Final Memory: 14M/215M
[INFO] ------------------------------------------------------------------------
Running post-build script in: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/firstProject/validate.groovy
Expand Down
Expand Up @@ -12,27 +12,28 @@

public class ChangelogAttachedTest {

private static final String OUTPUT_CHANGELOG = "CHANGES.txt";
private static final String EXPECTED_CHANGELOG_CONTENT =
"1.0 (2012-01-19)\n"+
"----------------\n"+
"o Fixes issues #173, #118, #138, #103\n\n";
"1.0-SNAPSHOT (2012-1-25)\n" +
"-------------------------\n" +
"\n" +
"it.sandbox.firstProject:\n" +
"o Fixes issues #173, #118, #138, #103\n" +
"o Made some changes [minor]\n" +
"\n" +
"\n";

private File output = new File("target/classes");
private File output = new File("target/CHANGES.txt");

@Test
@Ignore
public void outputFilesShouldExist() throws Exception
{
assertExists(new File(output, OUTPUT_CHANGELOG));
assertExists(output);
}

@Test
@Ignore
public void outputFileShouldContainExpectedContent() throws Exception
{
File changelog = new File(output, OUTPUT_CHANGELOG);
assertContains(changelog, EXPECTED_CHANGELOG_CONTENT);
assertContains(output, EXPECTED_CHANGELOG_CONTENT);
}

private static void assertExists(File file) throws Exception
Expand Down
14 changes: 7 additions & 7 deletions src/functionaltest/testprojects/secondProject/build.log
Expand Up @@ -32,7 +32,7 @@
T E S T S
-------------------------------------------------------
Running org.neo4j.ChangelogAttachedTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.016 sec
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.018 sec

Results :

Expand All @@ -41,9 +41,9 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jan 24 11:43:17 CET 2012
[INFO] Final Memory: 14M/214M
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Jan 25 13:53:50 CET 2012
[INFO] Final Memory: 14M/213M
[INFO] ------------------------------------------------------------------------
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
Expand Down Expand Up @@ -77,7 +77,7 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
T E S T S
-------------------------------------------------------
Running org.neo4j.ChangelogAttachedTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.015 sec
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.017 sec

Results :

Expand All @@ -93,8 +93,8 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jan 24 11:43:20 CET 2012
[INFO] Final Memory: 14M/215M
[INFO] Finished at: Wed Jan 25 13:53:53 CET 2012
[INFO] Final Memory: 14M/211M
[INFO] ------------------------------------------------------------------------
Running post-build script in: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/secondProject/validate.groovy
Finished post-build script in: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/secondProject/validate.groovy
10 changes: 5 additions & 5 deletions src/functionaltest/testprojects/singleChangelogTest/build.log
Expand Up @@ -39,8 +39,8 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jan 24 11:43:13 CET 2012
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Jan 25 13:53:46 CET 2012
[INFO] Final Memory: 14M/213M
[INFO] ------------------------------------------------------------------------
+ Error stacktraces are turned on.
Expand Down Expand Up @@ -73,7 +73,7 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
T E S T S
-------------------------------------------------------
Running org.neo4j.ChangelogDeployedTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 sec
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 sec

Results :

Expand All @@ -83,8 +83,8 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jan 24 11:43:15 CET 2012
[INFO] Final Memory: 10M/149M
[INFO] Finished at: Wed Jan 25 13:53:48 CET 2012
[INFO] Final Memory: 9M/149M
[INFO] ------------------------------------------------------------------------
Running post-build script in: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/singleChangelogTest/validate.groovy
Finished post-build script in: /home/jake/Workspaces/Neo4j/changes-maven-plugin/src/functionaltest/testprojects/singleChangelogTest/validate.groovy
Expand Up @@ -61,12 +61,21 @@ public class ChangeLogExtractorMojo extends AbstractMojo {
*/
private List<String> includeVersions;

/**
* List of strings. Any entry in a change log
* that contains any of the listed lines will be
* ignored.
*
* @parameter
*/
private List<String> excludeLinesContaining;

public void execute() throws MojoExecutionException, MojoFailureException {
try {

Changelog changelog = new Changelog(changelogPath);

List<String> extractedSections = changelog.extractSectionForVersion(createVersionMatcher());
List<String> extractedSections = changelog.extractSectionForVersion(createVersionMatcher(), createLineEvaluator());

FileUtils.writeLines(extractedChangelogOutputFile, extractedSections);

Expand All @@ -81,6 +90,15 @@ private VersionMatcher createVersionMatcher()
{
return new VersionMatcher(createVersionRegexes());
}

private LineEvaluator createLineEvaluator()
{
LineEvaluator evaluator = new LineEvaluator();
if(excludeLinesContaining != null) {
evaluator.excludeLinesContaining(excludeLinesContaining.toArray(new String[excludeLinesContaining.size()]));
}
return evaluator;
}

private String [] createVersionRegexes()
{
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/neo4j/build/plugins/changes/Changelog.java
Expand Up @@ -42,18 +42,18 @@ protected Changelog(InputStream changesInput) throws IOException

public List<String> extractSectionForVersion(String version)
{
return extractSectionForVersion(new VersionMatcher(version));
return extractSectionForVersion(new VersionMatcher(version), LineEvaluator.ALL);
}

public List<String> extractSectionForVersion(VersionMatcher versionMatcher)
public List<String> extractSectionForVersion(VersionMatcher versionMatcher, LineEvaluator lineEvaluator)
{
ChangelogSectionExtractor extractor = new ChangelogSectionExtractor(logLines, versionMatcher);
ChangelogExtractor extractor = new ChangelogExtractor(logLines, versionMatcher, lineEvaluator);
return extractor.runExtraction(true);
}

public List<String> extractAllEntriesWithoutHeadlines()
public List<String> extractAllEntriesWithoutHeadlines(VersionMatcher versionMatcher, LineEvaluator lineEvaluator)
{
ChangelogSectionExtractor extractor = new ChangelogSectionExtractor(logLines, VersionMatcher.ANY);
ChangelogExtractor extractor = new ChangelogExtractor(logLines, versionMatcher, lineEvaluator);
return extractor.runExtraction(false);
}
}

0 comments on commit 6f34abe

Please sign in to comment.