Details
Description
I have to make a distribution that contains SWT jars (win & linux). One way would be to include in template explicitly with according 'os' attribute:
template.vm
<resources>
<j2se version="1.6+" initial-heap-size="32m" max-heap-size="128m" />
<property name="jnlp.versionEnabled" value="true"/>
<property name="jnlp.packEnabled" value="true"/>
$dependencies
</resources>
<resources os="Windows">
<jar href="win32-x86-3.6.1.jar"/>
</resources>
<resources os="Linux">
<jar href="gtk-linux-x86-3.6.1.jar"/>
</resources>
But now I have to filter out both dependencies so that these won't appear in dependencies list when $dependencies will be replaced.
If I use exclusion for dependencies these will be excluded from list but also from the zip archive.
pom.xml
<dependencies>
<excludes>
<exclude>org.eclipse.swt:gtk-linux-x86</exclude>
<exclude>org.eclipse.swt:win32-x86</exclude>
</excludes>
</dependencies>
It would be nice to have a filter just for $dependencies variable.
I ended up filtering the dependencies in Velocity template. Quite ugly but solves the problem:
<resources> <j2se version="1.6+" initial-heap-size="32m" max-heap-size="512m" /> <property name="jnlp.versionEnabled" value="true"/> <property name="jnlp.packEnabled" value="true"/> #foreach( $dependency in $dependencies.split("\n") ) #set($dependency = $dependency.trim()) #if ( $dependency.indexOf("win32-x86") == -1 && $dependency.indexOf("gtk-linux-x86") == -1 ) $dependency #end #end </resources> <resources os="Windows"> #foreach( $dependency in $dependencies.split("\n") ) #set($dependency = $dependency.trim()) #if ( $dependency.indexOf("win32-x86") >= 0 ) $dependency.replace("<jar", "<nativelib") #end #end </resources> <resources os="Linux"> #foreach( $dependency in $dependencies.split("\n") ) #set($dependency = $dependency.trim()) #if ( $dependency.indexOf("gtk-linux-x86") >= 0 ) $dependency.replace("<jar", "<nativelib") #end #end </resources>