I have two questions regarding dependencies:
Q1: I have a j2ee.jar on my unix box (provided by Websphere Library). This is how I refer it in ANT:
<path id="was.lib">
<fileset dir="${was.home}/lib">
<include name="**/j2ee.jar" />
</fileset>
</path>
<property name="was.lib" refid="was.lib" />
<path id="myProj.lib">
<!-- path to my project's JAR's -->
</path>
<property name="myProj.lib" refid="myProj.lib" />
<path id="myProj.classpath">
<path refid="myProj.lib" />
<path refid="was.lib" />
</path>
I am not sure, how to define this dependency in Maven so that it refers to the system path?
Q2: I have a jar castor-1.3.1.jar and castor-1.3.1-core.jar in my project. When I define the dependency for both of them, Maven only picks one, since only the version is different. But I want both of them to be included.
This is how I have defined them:
<dependency>
<groupId>org.codehaus.castor</groupId>
<artifactId>castor</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.castor</groupId>
<artifactId>castor</artifactId>
<version>1.3.1-core</version>
</dependency>
Please help me regarding the same.
For j2ee.jar, you have two options. One is to install the jar to your local repository using mvn install:install-file. The other is to specify it as a system dependency.
As for castor-core, you can add the classifier tag
<dependency>
<groupId>org.codehaus.castor</groupId>
<artifactId>castor</artifactId>
<version>1.3.1</version>
<classifier>core</classifier>
</dependency>
Related
Hi Spring Boot Experts -
I am trying to create a spring boot uber jar that needs to be deployed to a apache storm cluster. But, the catch is that Storm is expecting all the class files in the root of the jar while the packaged app files are under "BOOT-INF/classes" when packaged using the "spring-boot-maven-plugin".
Is there a way I can have my app classes packaged directly under the root instead of "BOOT-INF/classes"?
I tried using the "maven-assembly-plugin" with the "spring-boot-maven-plugin" as shown below which creates the Uber jar with all the class files from the dependency jars packaged at the root of the uber jar, but the app classes are still at BOOT-INF/classes.
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
</exclude>
</excludes>
<requiresUnpack>
<dependency>
<groupId>com.myorg</groupId>
<artifactId>my-app-artifact</artifactId> <!-- This does not help! :( -->
</dependency>
</requiresUnpack>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
So, for my future self or for anyone who is trying to find an answer for a similar question. Here are the different things that I realized during my research for this -
Storm wants an executable java jar file
Spring Boot provides a custom jar packaging. While it confirms with java jar packaging, Spring Boot loads the classes from the BOOT-INF/classes
So, to make a Spring Boot jar work on the storm cluster while behaving as Spring Boot - we would need to create a copy of all the classes from BOOT-INF/classes to the root of the jar file.
Is this possible? and the answer is yes.
Using the approach describe here, I was able to create a Spring Boot jar with the BOOT-INF/classes copied to the root of the Spring Boot jar. This approach requires ant build.xml, ivy settings and an ivy.xml as shown below. (disclaimer: config tested only till packaging on not on the storm cluster)
Since we are able to create a Spring Boot Jar hacked with classes at the root -
Should we do it? NO.
Here are the reasons -
Spring strongly advises not taking this approach to not end up with unwanted class overwrite and class versioning issues for classes with same names across jar files and with different versions.
Spring Boot Jar packaging is not a format intended for using as a dependency jar. Read the first line here. Hence for dependency use cases, you need to stick with your plain old java modules. Spring Boot is for more of standalone executables or for deployment on containers like tomcat.
Good luck!
build.xml
<project
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:spring-boot="antlib:org.springframework.boot.ant"
name="spring-boot-sample-ant"
default="build">
<description>
Sample ANT build script for a Spring Boot executable JAR project. Uses ivy for
dependency management and spring-boot-antlib for additional tasks. Run with
'$ ant -lib ivy-2.2.jar spring-boot-antlib.jar' (substitute the location of your
actual jars). Run with '$ java -jar target/*.jar'.
</description>
<property name="spring-boot.version" value="1.4.2.RELEASE" />
<property name="lib.dir" location="${basedir}/target/lib" />
<property name="start-class" value="com.my.main.class" />
<target name="resolve" description="--> retrieve dependencies with ivy">
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" />
</target>
<target name="classpaths" depends="resolve">
<path id="compile.classpath">
<fileset dir="${lib.dir}/compile" includes="*.jar" />
</path>
</target>
<target name="init" depends="classpaths">
<mkdir dir="target/classes" />
</target>
<target name="compile" depends="init" description="compile">
<javac srcdir="src/main/java" destdir="target/classes" classpathref="compile.classpath" />
</target>
<target name="clean" description="cleans all created files/dirs">
<delete dir="target" />
</target>
<target name="build" depends="compile">
<spring-boot:exejar destfile="target/${ant.project.name}-${spring-boot.version}.jar" classes="target/classes">
<spring-boot:lib>
<fileset dir="${lib.dir}/runtime" />
</spring-boot:lib>
</spring-boot:exejar>
</target>
<target name="unjar_dependencies" depends="compile">
<unzip dest="target/classes">
<fileset dir="${lib.dir}/compile">
<include name="my-app-common-0.1-SNAPSHOT.jar" />
</fileset>
</unzip>
</target>
<!-- Manual equivalent of the build target -->
<target name="manual" depends="compile, unjar_dependencies">
<jar destfile="target/manual/${ant.project.name}-${spring-boot.version}.jar" compress="false">
<mappedresources>
<fileset dir="target/classes" />
<globmapper from="*" to="BOOT-INF/classes/*"/>
</mappedresources>
<mappedresources> <!-- **** this mapped resources block does what I was looking for **** -->
<fileset dir="target/classes" />
<globmapper from="*" to="/*"/>
</mappedresources>
<mappedresources>
<fileset dir="src/main/resources" erroronmissingdir="false"/>
<globmapper from="*" to="BOOT-INF/classes/*"/>
</mappedresources>
<mappedresources>
<fileset dir="${lib.dir}/runtime" />
<globmapper from="*" to="BOOT-INF/lib/*"/>
</mappedresources>
<zipfileset src="${lib.dir}/loader/spring-boot-loader-jar-${spring-boot.version}.jar" />
<manifest>
<attribute name="Main-Class" value="org.springframework.boot.loader.JarLauncher" />
<attribute name="Start-Class" value="${start-class}" />
</manifest>
</jar>
</target>
</project>
ivysettings.xml
<ivysettings>
<settings defaultResolver="chain" />
<resolvers>
<chain name="chain" returnFirst="true">
<!-- NOTE: You should declare only repositories that you need here -->
<filesystem name="local" local="true" m2compatible="true">
<artifact pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
<ivy pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].pom" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/release" />
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/milestone" />
<ibiblio name="spring-snapshots" m2compatible="true" root="http://repo.spring.io/snapshot" />
</chain>
</resolvers>
</ivysettings>
ivy.xml
<ivy-module version="2.0">
<info organisation="org.springframework.boot" module="spring-boot-sample-ant" />
<configurations>
<conf name="compile" description="everything needed to compile this module" />
<conf name="runtime" extends="compile" description="everything needed to run this module" />
<conf name="loader" description="Spring Boot loader used when manually building an executable archive" />
</configurations>
<dependencies>
<dependency org="org.springframework.boot" name="spring-boot-starter" rev="${spring-boot.version}" conf="compile">
<exclude org="ch.qos.logback" name="logback-classic"/>
</dependency>
<dependency org="org.springframework.boot" name="spring-boot-loader" rev="${spring-boot.version}" conf="loader->default" />
<dependency org="org.apache.storm" name="storm-core" rev="1.0.2">
<exclude org="org.apache.logging.log4j" name="log4j-slf4j-impl"/>
<exclude org="org.apache.logging.log4j" name="log4j-core"/>
</dependency>
<dependency org="com.mycompany" name="app-common" rev="0.1-SNAPSHOT"/>
<dependency org="org.apache.storm" name="storm-kafka" rev="1.0.2"/>
<dependency org="org.apache.kafka" name="kafka_2.10" rev="0.10.1.0"/>
<dependency org="org.apache.kafka" name="kafka_2.10" rev="0.10.1.0"/>
<dependency org="org.apache.httpcomponents" name="httpcomponents-client" rev="4.5.2"/>
<dependency org="org.eclipse.paho" name="org.eclipse.paho.client.mqttv3" rev="1.1.0"/>
<dependency org="com.amazonaws" name="aws-java-sdk-s3" rev="1.11.53"/>
<dependency org="com.jcraft" name="jsch" rev="0.1.54"/>
<dependency org="io.netty" name="netty-handler" rev="3.7.0.Final"/>
</dependencies>
</ivy-module>
Is there a way I can have my app classes packaged directly under the root instead of "BOOT-INF/classes"?
Yes, you just need to use Spring Boot 1.3. Back to maven... in your pom.xml if you declare your parent like this:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
then your classes (and other files) will be placed at the root level. This is the "old way" for spring boot.
In version 1.4 they changed the spring boot jar structure to use the BOOT-INF directory. So, if you use <version>1.4.1.RELEASE</version> for example, then your classes will be under BOOT-INF/classes. An undesirable side effect is that your configuration files (e.g., application.properties, application-myprofile.properties, etc.) will also be under BOOT-INF/classes, even though they are not Java classes.
I'm attempting to add a build task into a Maven pom file so that I can transfer a jar file as well as some xml files to an SFTP server (it's a VM with Tomcat installed) but I have been unable to so far.
I've had a look at a few links, but they either don't quite match the requirements, have missing steps, or don't work. I'm basically a beginner with Maven so I'm not sure if I'm doing it correctly.
The requirement is that I want to invoke a Maven build, with command line arguments for the hostname, username, and password (which I have working) which then will upload a jar file and the xml files to a VM with Tomcat running in it via SFTP (FTP doesn't work, and I don't think SCP will work as I don't have a passfile). I also don't want to mess with the main Maven settings.xml file to add the connection details in, which some of the links I found seem to be reliant upon.
I have the following profile so far, using FTP, but it doesn't work due to not using SFTP.
<profiles>
<profile>
<!-- maven antrun:run -Pdeploy -->
<id>deploy</id>
<build>
<plugins>
<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<configuration>
<target>
<!-- <loadproperties srcFile="deploy.properties" /> -->
<ftp action="send" server="${server-url}"
remotedir="/usr/share/myappserver/webapps/myapp/WEB-INF/lib"
userid="${user-id}" password="${user-password}" depends="no"
verbose="yes" binary="yes">
<fileset dir="target">
<include name="artifact.jar" />
</fileset>
</ftp>
<ftp action="send" server="${server-url}"
remotedir="/var/lib/myappserver/myapp/spring"
userid="${user-id}" password="${user-password}" depends="no"
verbose="yes" binary="yes">
<fileset dir="src/main/resource/spring">
<include name="*.xml" />
</fileset>
</ftp>
<!-- calls deploy script -->
<!-- <sshexec host="host" trust="yes" username="usr" password="pw"
command="sh /my/script.sh" /> -->
<!-- SSH -->
<taskdef name="sshexec" classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
classpathref="maven.plugin.classpath" />
<taskdef name="ftp"
classname="org.apache.tools.ant.taskdefs.optional.net.FTP"
classpathref="maven.plugin.classpath" />
</target>
</configuration>
<dependencies>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.1.29</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I tried swapping ftp for sftp, and using org.apache.tools.ant.taskdefs.optional.ssh.SFTP instead, but it didn't seem to work.
So to summarize, the SFTP config needs to be self contained within the pom file as much as possible, with stuff like the host url, username and password being passed in when invoked.
I'd use the Wagon Maven plugin with its goals upload-single and upload instead of antrun:
wagon:upload-single uploads the specified file to a remote location.
wagon:upload uploads the specified set of files to a remote location.
I was eventually able to get this working using PuTTy pcsp
<PUTTY_DIRECTORY>/pscp.exe" -l <USERNAME> -pw <PASSWORD> ./fileToTransfer.file <PUTTY_SESSION_ID>:/destination-directory/fileToTransfer.file
I could also run scripts using plink
<PUTTY_DIRECTORY>/plink.exe" <PUTTY_SESSION> -l <USERNAME> -pw <PASSWORD> -m ./myScriptToRunRemotely.sh
It wasn't the cleanest of solutions, but it still allows me to use it on Jenkins for deployment testing purposes.
I'm using ant-ivy to resolve dependencies from the maven repository. And i'm using the same ant-ivy to publish new artifacts into that repository, so i'm generating .pom file in ant too.
The generated .pom file is very simple and looks like this(PROJECT_A):
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>COMPANY</groupId>
<artifactId>PROJECT_A</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
So it just has some dependencies in compile scope and some in test scope. Now my ivy.xml file for that project(and the source of that .pom above) looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="COMPANY" module="PROJECT_A" revision="1.0" />
<configurations defaultconf="default,sources" defaultconfmapping="sources->sources;%->default">
<conf name="test" visibility="private"/>
<conf name="default" description="list of dependencies"/>
<conf name="sources" description="source files for all dependencies" />
</configurations>
<publications>
<artifact type="jar" conf="default" />
<artifact type="sources" ext="jar" m:classifier="sources" conf="sources" />
<artifact type="pom" ext="pom" conf="default" />
</publications>
<dependencies>
<!-- General -->
<dependency org="commons-collections" name="commons-collections" rev="3.2.1" transitive="false"/>
<dependency org="commons-configuration" name="commons-configuration" rev="1.7" transitive="false"/>
<dependency org="commons-lang" name="commons-lang" rev="2.6" transitive="false"/>
<dependency org="log4j" name="log4j" rev="1.2.16" transitive="false"/>
<!-- dependencies for junit testing -->
<dependency org="junit" name="junit" rev="latest.release" conf="test" />
<dependency org="org.mockito" name="mockito-all" rev="latest.release" conf="test" /> <!-- it's useful by itself, plus it has hamcrest in it which junit needs -->
</dependencies>
</ivy-module>
Again, very simple - 3 configurations, the default has all the dependencies, test is for testing dependencies and sources to publish sources.
And it all works quite well, apart of one thing - i'm declaring my dependencies as not transitive in the PROJECT_A, then when i'm pushing the pom to the repository those dependencies are listed there in the scope compile. Therefore the other project(PROJECT_B) which will have PROJECT_A as a dependency, will have all the transitive dependencies of the PROJECT_A as well, and i don't want that at all i just want those which are explicitly declared in the ivy.xml of PROJECT_A.
I've tried playing with the scopes and mappings, but it seems i really don't understand what i'm doing there as it doesn't make any sense. I would like to modify that scheme somehow so that when i include the PROJECT_A as a dependency, it'll only include the actual dependencies of the PROJECT_A declared in the ivy.xml, so transitive flag will be taken into account.
One more thing, i'm creating that .pom file like that:
<ivy:makepom ivyfile="generated-ivy.xml" pomfile="${ant.project.name}.pom" templatefile="${template.pom}" artifactPackaging="jar">
<mapping conf="default" scope="compile" />
<mapping conf="test" scope="test" />
</ivy:makepom>
Mark the dependency as <optional> to make it non-transitive.
Dirty hack, but that's maven.
I'm getting an unexpected version of a dependency (1.5.8) when I use the assembly plugin, but nowhere else. In my pom I have:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.0</version>
</dependency>
When I run dependency:tree or dependency:list, I see the correct version and only the correct version. When I check in Eclipse I see only the correct version.
In my assembly.xml I have:
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
In the resulting zip, I get slf4j-log4j12-1.5.8.jar. No idea where this is coming from. Any help?
Using maven 3.0.4.
This was due to a 'bad' assembly plugin version (2.2-beta-5). My pom.xml did not specify the plugin version. When I explicitly marked it as 2.4 (or the latest version when you read this!), the plugin pulled the correct dependency.
Lesson learned - If you get the following warning in your build:
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-whatever-plugin is missing
It is highly recommended to fix these problems because they threaten the stability of your build.
.. fix it!
You may try to delete the bad JAR (slf4j-log4j12-1.5.8.jar) from your maven repository and add the correct one there (slf4j-log4j12-1.6.0.jar). Then run your build with the --offline switch. In the moment that maven tries to get the wrong JAR, the build will fail and maven will show you from what transitive dependency it is trying to get it. Then you exclude it from the transistive dependencies with this:
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>slf4j-log4j12</groupId>
</exclusion>
</exclusions>
Check if it the JAR that you got has the correct groupId. Some people creates duplicates of common JARs for stupid and evil special purposes that may confuse maven. In special, check if you are not getting org.jboss.resteasy:slf4j-log4j12 instead. You may ban undesired dependencies using the maven-enforcer-plugin, like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>enforce-banned-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<exclude>org.slf4j:slf4j-log4j12:1.5.8</exclude> <!-- Wrong version, dude! -->
<exclude>commons-logging:*</exclude> <!-- Worst, stupidest, lamest logging framework ever! -->
<exclude>org.jboss.resteasy:slf4j-simple</exclude> <!-- Evil JAR duplication. -->
<exclude>org.jboss.resteasy:slf4j-api</exclude> <!-- Evil JAR duplication. -->
<exclude>org.jboss.resteasy:slf4j-log4j12</exclude> <!-- Evil JAR duplication. -->
<exclude>org.jboss.resteasy:jackson-core-asl</exclude> <!-- Evil JAR duplication. -->
<exclude>org.jboss.resteasy:jackson-mapper-asl</exclude> <!-- Evil JAR duplication. -->
<exclude>org.jboss.resteasy:jackson-core-lgpl</exclude> <!-- Evil JAR duplication. -->
<exclude>org.jboss.resteasy:jackson-mapper-lgpl</exclude> <!-- Evil JAR duplication. -->
<exclude>org.codehaus.jackson:jackson-core-lgpl</exclude> <!-- Two distinct packages for the exact same thing always creates conflicts. We want the ASL one. -->
<exclude>org.codehaus.jackson:jackson-mapper-lgpl</exclude> <!-- Two distinct packages for the exact same thing always creates conflicts. We want the ASL one. -->
<exclude>velocity-tools:velocity-tools</exclude> <!-- Was renamed. -->
<exclude>velocity:velocity</exclude> <!-- Was renamed. -->
<exclude>struts:struts</exclude> <!-- Was renamed. -->
<exclude>javassist:javassist</exclude> <!-- Was renamed. -->
<exclude>axis:*</exclude> <!-- Was renamed to org.apache.axis:* and wsdl4j:wsdl4j . -->
<exclude>commons-beanutils:commons-beanutils-core</exclude> <!-- Redundant package. -->
<exclude>xpp3:xpp3_min</exclude> <!-- Redundant package. -->
<exclude>xml-apis:xml-apis:2.0.0</exclude> <!-- Bad package, for some strange reason 2.0.x is inferior to 1.4.x. -->
<exclude>xml-apis:xml-apis:2.0.2</exclude> <!-- Bad package, for some strange reason 2.0.x is inferior to 1.4.x. -->
<exclude>quartz:quartz</exclude> <!-- Was renamed. -->
</excludes>
</bannedDependencies>
</rules>
</configuration>
</execution>
</executions>
</plugin>
I'm working on a plugin for Talend Open Studio; the component architecture of that platform needs that all external JARs are declared in a component-descriptor XML file in a form like:
<IMPORT MODULE="commons-collections-3.2.1.jar" NAME="commons-collections-3.2.1"
REQUIRED="true"/>
I use the Maven dependency plugins to manage all these external JARs
Is there a way to get all the dependency names in a list or something? This way can I be able to build the required strings (using an antcontrib task, perhaps), fill a ${parameter} and finally add it to XML file using maven-replacer-plugin?
The simplest solution is to use the maven-dependency-plugin via the buld-classpath goal. This goal can be given supplemental parameters to put the result into a file like:
mvn dependency:build-classpath -Dmdep.outputFile=classpath.out
Ok, I partly resolved this way that should works with some limitations:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
<id>copy-resources</id>
<configuration>
<exportAntProperties>true</exportAntProperties>
<tasks>
<!-- add the ant tasks from ant-contrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="maven.plugin.classpath"/>
<var name="import.set" value=""/>
<for param="file">
<path>
<fileset dir="${project.build.directory}" includes="*.jar"/>
</path>
<sequential>
<var name="basename" unset="true"/>
<basename file="#{file}" property="basename"/>
<var name="filenames" value="${basename}"/>
<var name="import.clause" value='<IMPORT MODULE="${filenames}" NAME="${filenames}" REQUIRED="true"/>'/>
<var name="import.set" value="${import.clause}${line.separator}${import.set}" />
</sequential>
</for>
<property name="import.jar" value="${import.set}"/>
<echo>${import.jar}</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Still some problems: even if exportAntProperties is set to true, the property ${import.jar} is still not available outside ant taska in other maven goals, while if i switch to maven-antrun-plugin 1.7 version, a "Error executing ant tasks: org.apache.tools.ant.launch.Locator.fromJarURI(Ljava/lang/String;)Ljava/lang/String;" exception is thrown. Still no clues...