Skip to content

Commit

Permalink
Fixed mojohaus#193
Browse files Browse the repository at this point in the history
 o Added support for loading rules from the classpath.
 o Mentioned support for loading the rules file from the classpath in JavaDoc.
 o Update the documentation with an example how to load a rules files from the classpath.
  • Loading branch information
obfischer committed Aug 16, 2017
1 parent 3557933 commit c46539b
Show file tree
Hide file tree
Showing 18 changed files with 422 additions and 110 deletions.
6 changes: 6 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 2.5 (NOT YET RELEASED)

* [Fixed Issue 187][issue-187]

create target directory when run dependency update report.
Thanks to Ilja Dubinin.

* [Pull Request #189][pull-189]

Fixed inccorect links. Thanks to Anton Johansson.
Expand Down Expand Up @@ -68,4 +73,5 @@
[issue-167]: https://github.com/mojohaus/versions-maven-plugin/issues/167
[issue-168]: https://github.com/mojohaus/versions-maven-plugin/issues/168
[issue-177]: https://github.com/mojohaus/versions-maven-plugin/issues/177
[issue-187]: https://github.com/mojohaus/versions-maven-plugin/issues/187
[pull-189]: https://github.com/mojohaus/versions-maven-plugin/pull/189
2 changes: 2 additions & 0 deletions src/it/it-rules-via-classpath-001/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases
invoker.buildResult = failure
32 changes: 32 additions & 0 deletions src/it/it-rules-via-classpath-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<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>localhost</groupId>
<artifactId>it-rules-via-classpath-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>GH-193: Fail if resource is not found</name>

<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>version-rules</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<rulesUri>classpath:///package/foo/bar/rule-set.xml</rulesUri>
</configuration>
</plugin>
</plugins>
</build>

</project>
22 changes: 22 additions & 0 deletions src/it/it-rules-via-classpath-001/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "build.log" );
String buf = FileUtils.fileRead( file, "UTF-8" );
String expectedMessage = "Resource \"classpath:///package/foo/bar/rule-set.xml\" not found in classpath.";

if ( buf.indexOf( expectedMessage ) < 0 )
{
System.err.println( "Build should have failed as the requested resource is not present." );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
2 changes: 2 additions & 0 deletions src/it/it-rules-via-classpath-002/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=clean install ${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases
invoker.buildResult = success
46 changes: 46 additions & 0 deletions src/it/it-rules-via-classpath-002/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<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>localhost</groupId>
<artifactId>it-rules-via-classpath-002</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>GH-193: Succeed if resource is found</name>

<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>version-rules</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>localhost</groupId>
<artifactId>setup-provide-rules-in-jar</artifactId>
<version>1.0</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<rulesUri>classpath:///package/foo/bar/rules.xml</rulesUri>
</configuration>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>setup-provide-rules-in-jar</artifactId>
<version>1.0</version>
</dependency>

</dependencies>
</plugin>
</plugins>
</build>

</project>
22 changes: 22 additions & 0 deletions src/it/it-rules-via-classpath-002/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "build.log" );
String buf = FileUtils.fileRead( file, "UTF-8" );
String expectedMessage = "Resource \"classpath:///package/foo/bar/rules.xml\" not found in classpath.";

if ( buf.indexOf( expectedMessage ) >= 0 )
{
System.err.println( "File resource rules.xml should have been found in the classpath." );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
2 changes: 2 additions & 0 deletions src/it/it-rules-via-classpath-003/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=clean install ${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases
invoker.buildResult = success
45 changes: 45 additions & 0 deletions src/it/it-rules-via-classpath-003/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<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>localhost</groupId>
<artifactId>it-rules-via-classpath-003</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>GH-193: Found rules file is used by the plugin</name>

<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>version-rules</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>localhost</groupId>
<artifactId>setup-provide-rules-in-jar</artifactId>
<version>1.0</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<rulesUri>classpath:///package/foo/bar/rules.xml</rulesUri>
</configuration>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>setup-provide-rules-in-jar</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

</project>
21 changes: 21 additions & 0 deletions src/it/it-rules-via-classpath-003/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "pom.xml" );
String buf = FileUtils.fileRead( file, "UTF-8" );

if ( buf.indexOf( "<version>3.0.1-1.1</version>" ) < 0 )
{
System.err.println( "Version of version-rules not bumped to 3.0.1-1.1" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
1 change: 1 addition & 0 deletions src/it/setup-provide-rules-in-jar/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=clean install
12 changes: 12 additions & 0 deletions src/it/setup-provide-rules-in-jar/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<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>localhost</groupId>
<artifactId>setup-provide-rules-in-jar</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>GH-193: Provide a rules file within a jar</name>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ruleset comparisonMethod="maven">
<rules>
<rule groupId="localhost" artifactId="version-rules" comparisonMethod="mercury"/>
</rules>
</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ public abstract class AbstractVersionsReport
private String serverId;

/**
* The Wagon URI of a ruleSet file containing the rules that control how to compare version numbers.
* URI of a ruleSet file containing the rules that control how to compare
* version numbers. The URI could be either a Wagon URI or a classpath URI
* (e.g. <code>classpath:///package/sub/package/rules.xml</code>).
*
* @since 1.0-alpha-3
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ public abstract class AbstractVersionsUpdaterMojo
private String serverId;

/**
* The Wagon URI of a ruleSet file containing the rules that control how to compare version numbers.
* URI of a ruleSet file containing the rules that control how to compare
* version numbers. The URI could be either a Wagon URI or a classpath URI
* (e.g. <code>classpath:///package/sub/package/rules.xml</code>).
*
* @since 1.0-alpha-3
*/
Expand Down
Loading

0 comments on commit c46539b

Please sign in to comment.