You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/08/02 21:57:29 UTC
svn commit: r1368675 - in /maven/plugins/trunk/maven-rar-plugin/src:
it/filtered/pom.xml it/filtered/verify.bsh
main/java/org/apache/maven/plugin/rar/RarMojo.java
Author: olamy
Date: Thu Aug 2 19:57:29 2012
New Revision: 1368675
URL: http://svn.apache.org/viewvc?rev=1368675&view=rev
Log:
[MRAR-15] Allow more customizations of resources to be included
Modified:
maven/plugins/trunk/maven-rar-plugin/src/it/filtered/pom.xml
maven/plugins/trunk/maven-rar-plugin/src/it/filtered/verify.bsh
maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
Modified: maven/plugins/trunk/maven-rar-plugin/src/it/filtered/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-rar-plugin/src/it/filtered/pom.xml?rev=1368675&r1=1368674&r2=1368675&view=diff
==============================================================================
--- maven/plugins/trunk/maven-rar-plugin/src/it/filtered/pom.xml (original)
+++ maven/plugins/trunk/maven-rar-plugin/src/it/filtered/pom.xml Thu Aug 2 19:57:29 2012
@@ -30,6 +30,10 @@ under the License.
<name>Maven Integration Test :: it0070</name>
<description>Test a RAR generation.</description>
+ <properties>
+ <bestwine>bordeaux</bestwine>
+ </properties>
+
<build>
<plugins>
<plugin>
@@ -40,6 +44,17 @@ under the License.
<includeJar>false</includeJar>
<raXmlFile>src/main/custom/ra.xml</raXmlFile>
<filterRarSourceDirectory>true</filterRarSourceDirectory>
+ <rarResources>
+ <rarResource>
+ <directory>${basedir}/src/main/ext</directory>
+ <targetPath>ext</targetPath>
+ </rarResource>
+ <rarResource>
+ <directory>${basedir}/src/main/ext-filtered</directory>
+ <targetPath>ext-filtered</targetPath>
+ <filtering>true</filtering>
+ </rarResource>
+ </rarResources>
</configuration>
</plugin>
</plugins>
Modified: maven/plugins/trunk/maven-rar-plugin/src/it/filtered/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-rar-plugin/src/it/filtered/verify.bsh?rev=1368675&r1=1368674&r2=1368675&view=diff
==============================================================================
--- maven/plugins/trunk/maven-rar-plugin/src/it/filtered/verify.bsh (original)
+++ maven/plugins/trunk/maven-rar-plugin/src/it/filtered/verify.bsh Thu Aug 2 19:57:29 2012
@@ -19,6 +19,8 @@ try
String[] includedEntries = {
"META-INF/ra.xml",
"SomeResource.txt",
+ "ext/wine.txt",
+ "ext-filtered/wine.txt"
};
for ( String included : includedEntries )
{
@@ -41,6 +43,28 @@ try
return false;
}
+ stream = jar.getInputStream( jar.getEntry("ext/wine.txt") );
+
+ content = new String(IOUtil.toByteArray( stream ));
+
+ idx = content.indexOf("${bestwine}");
+
+ if (idx<1) {
+ System.out.println("ext/wine.txt filtered:"+content);
+ return false;
+ }
+
+ stream = jar.getInputStream( jar.getEntry("ext-filtered/wine.txt") );
+
+ content = new String(IOUtil.toByteArray( stream ));
+
+ idx = content.indexOf("bordeaux");
+
+ if (idx<1) {
+ System.out.println("ext-filtered/wine.txt filtered:"+content);
+ return false;
+ }
+
jar.close();
}
catch( Throwable t )
Modified: maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java?rev=1368675&r1=1368674&r2=1368675&view=diff
==============================================================================
--- maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java (original)
+++ maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java Thu Aug 2 19:57:29 2012
@@ -42,6 +42,7 @@ import org.codehaus.plexus.util.FileUtil
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -127,9 +128,10 @@ public class RarMojo
/**
* allow filtering of link{rarSourceDirectory}
+ *
* @since 2.3
*/
- @Parameter(property = "rar.filterRarSourceDirectory", defaultValue = "false")
+ @Parameter( property = "rar.filterRarSourceDirectory", defaultValue = "false" )
private boolean filterRarSourceDirectory;
@@ -231,6 +233,7 @@ public class RarMojo
* <code>default-testResources</code> to supply different configurations for the two
* different types of resources. By supplying <code>extraFilters</code> configurations, you
* can separate which filters are used for which type of resource.
+ *
* @since 2.3
*/
@Parameter
@@ -244,6 +247,14 @@ public class RarMojo
@Parameter
protected List<String> nonFilteredFileExtensions;
+ /**
+ * extra resource to include in rar archive
+ *
+ * @since 2.3
+ */
+ @Parameter
+ protected List<RarResource> rarResources;
+
private File buildDir;
@@ -304,9 +315,17 @@ public class RarMojo
resource.setTargetPath( getBuildDir().getAbsolutePath() );
resource.setFiltering( filterRarSourceDirectory );
+ List<Resource> resources = new ArrayList<Resource>();
+ resources.add( resource );
+
+ if ( rarResources != null && !rarResources.isEmpty() )
+ {
+ resources.addAll( rarResources );
+ }
+
MavenResourcesExecution mavenResourcesExecution =
- new MavenResourcesExecution( Collections.singletonList( resource ), getBuildDir(), project, encoding,
- filters, Collections.<String>emptyList(), session );
+ new MavenResourcesExecution( resources, getBuildDir(), project, encoding, filters,
+ Collections.<String>emptyList(), session );
mavenResourcesExecution.setEscapeWindowsPaths( escapeWindowsPaths );