Skip to content

Commit

Permalink
Added support for loading rules from the classpath. See mojohaus#193
Browse files Browse the repository at this point in the history
…fore more details.
  • Loading branch information
obfischer committed Aug 14, 2017
1 parent f27c546 commit 28fae83
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 108 deletions.
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>
Loading

0 comments on commit 28fae83

Please sign in to comment.