Enunciate multiple time running with maven - maven-3

I'm using enunciate 1.27 and maven 3.0.4 .
My problem occurs when I run enunciate multiple times :
[INFO]
[INFO] --- maven-enunciate-plugin:1.27:assemble (number2) # yaghut-web ---
[INFO] initializing enunciate.
[INFO] [csharp] C# compilation is disabled, but the source code will still be generated.
[INFO] invoking enunciate:generate step...
An exception has occurred in apt (1.6.0_30). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at com.sun.tools.apt.comp.Apt$AptTreeScanner.visitAnnotation(Apt.java:161)
at com.sun.tools.javac.tree.JCTree$JCAnnotation.accept(JCTree.java:1794)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:33)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:41)
at com.sun.tools.javac.tree.TreeScanner.visitModifiers(TreeScanner.java:266)
at com.sun.tools.javac.tree.JCTree$JCModifiers.accept(JCTree.java:1816)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:33)
at com.sun.tools.javac.tree.TreeScanner.visitClassDef(TreeScanner.java:60)
at com.sun.tools.apt.comp.Apt$AptTreeScanner.visitClassDef(Apt.java:146)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:575)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:33)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:41)
at com.sun.tools.javac.tree.TreeScanner.visitTopLevel(TreeScanner.java:52)
at com.sun.tools.apt.comp.Apt$AptTreeScanner.visitTopLevel(Apt.java:124)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:446)
at com.sun.tools.apt.comp.Apt.main(Apt.java:213)
....
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
I execute enunciate in this way:
<execution>
<id>number1</id>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<configFile>src/main/enunciate_number1.xml</configFile>
<compilationEncoding>UTF-8</compilationEncoding>
<generateDir>${project.build.directory}/enunciate/number1/generate</generateDir>
<compileDir>${project.build.directory}/enunciate/number1/compile</compileDir>
<buildDir>${project.build.directory}/enunciate/number1/build</buildDir>
</configuration>
</execution>
<execution>
<id>number2</id>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<configFile>${project.basedir}/src/main/enunciate_number2.xml</configFile>
<compilationEncoding>UTF-8</compilationEncoding>
<generateDir>${project.build.directory}/enunciate/number2/generate</generateDir>
<compileDir>${project.build.directory}/enunciate/number2/compile</compileDir>
<buildDir>${project.build.directory}/enunciate/number2/build</buildDir>
</configuration>
</execution>
when I executed enunciate one time (I mean omit number2) everything work correctly.
I guessed 'generateDir' in second execution was not set correctly. When I omit it, nothing was generated (message was: everythis appears up-to-date); and with current configuration, NullPointerException is thrown.
any idea?
thanks.

I don't know much about how to configure Maven to get this right, but an alternative approach might be to use the maven-antrun-plugin to invoke Enunciate twice instead of trying to get Maven to do it. The configuration would look kinda like the contents of the "getting-started-examples" target at line 199 in build-site.xml.

Related

fabric8:docker-maven-plugin cannot load the ffi provider when running on Centos7 in Jenkins

After adding fabric8 to a hello world pom, when running maven "clean install" in Jenkins on CentOS7,
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.31.0</version>
<configuration>
<filter>${*}</filter>
<images>
<image>
<name>docker.io/myname/${project.artifactId}:${project.version}</name>
</image>
</images>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
I get the following error
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.31.0:build (default) on project reference-service: Execution default of goal io.fabric8:docker-maven-plugin:0.31.0:build failed: An API incompatibility was encountered while executing io.fabric8:docker-maven-plugin:0.31.0:build: java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>io.fabric8:docker-maven-plugin:0.31.0
...
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: could not get native definition for type: POINTER: java.lang.UnsatisfiedLinkError: /tmp/jffi5159674609596634370.so: /tmp/jffi5159674609596634370.so: failed to map segment from shared object: Operation not permitted
I can't find any install instructions of a .so file for CentOS7 or other instructions.
The GitHub site doesn't provide much guidance;
Docker is listening on 2375 and docker.sock. The user I'm building as is in dockerroot.
Same issue with fuse
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.23.0.fuse-730010-redhat-00001:build (default) on project reference-service: Execution default of goal io.fabric8:docker-maven-plugin:0.23.0.fuse-730010-redhat-00001:build failed: An API incompatibility was encountered while executing io.fabric8:docker-maven-plugin:0.23.0.fuse-730010-redhat-00001:build: java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider
[ERROR] realm = plugin>io.fabric8:docker-maven-plugin:0.23.0.fuse-730010-redhat-00001
There are two options:
Easy one: upgrade to the last version of the plugin. The problem was resolved in release 0.38.1
https://github.com/fabric8io/docker-maven-plugin/releases/tag/v0.38.1
More complex one (If you can upgrade your plugin version): follow this tutorial m1 chip + f8-plugin problem. Is a combination of socat and DOCKER_HOST
In this case, FFI error meant that the plugin could not talk to the docker daemon. Setting DOCKER_HOST to tcp://127.0.0.1:2375 in the global jenkins config resolved my issue.

cargo-maven2-plugin:start fails with "Actually there are no valid types registered for this configuration", regardless of what containerId I enter

I'm trying to run integration tests with the cargo-maven2-plugin and Tomcat 8. I want the Maven build to start the container for me, so I have configured the start and stop goals as documented here. The problem is that regardless of what I enter as containerId, the start goal always fails with a message saying that there are no registered configurations. The error messages always ends in
Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it?
I've tried various configurations, including ones that I found in various tutorials, and ones that user older Tomcat versions, but nothing helps. The error message is always the same.
Other posts here on Stack Overflow recommend to update the Cargo versions, but this doesn't apply to my problem: I already use the latest release version (1.6.5).
So, why do I keep getting this error?
For reference, here is one complete configuration that I tried out:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.5</version>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<artifactInstaller>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>8.5.23</version>
</artifactInstaller>
</container>
<configuration>
<type>standalone</type>
</configuration>
<deployables>
<!-- ... -->
</deployables>
</configuration>
</plugin>
The full error message for this configuration is:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start (start-container) on project domain.db.itest: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [tomcat8x], type = [installed]], configuration type [standalone]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]
The solution was incredibly simple: I had the offline mode enabled. Without offline mode, Cargo downloaded the cargo-core-container-tomcat artifact, and apparently this artifact contains the definition of the tomcat8x configuration. Then, the container start was successful!
I had started the Maven build from Eclipse, so I didn't notice that the offline mode was enabled. I'm aware that this situation is quite special, but maybe someone else still benefits from my insight. It took me a while to solve, so I'm sharing problem and solution here. (After all, this is encouraged :-)
I got the key hint from a mailing list post, where thecargo-core-container-tomcat artifact was not downloaded due to a Nexus repository configuration.
This error is sometimes due to the cargo plugin version. Update your cargo plugin to the higher or latest version.
In my case, I updated from cargo 1.4.8 to cargo 1.7.0.
check this link,its may help:
click here

Neo4j 3.0.x PostingsFormat with name 'BlockTreeOrds' does not exist

I tried updating from Neo4j 2.3 to 3.0.1. I can start up the database as a service, no problem there.
But when I try to build a Neo4j executable and run it, I find a bug which I cannot resolve. Under Neo4j 2.x I can build executables fine. Below is my main method:
public class StartDB {
public static void main(String[] args) {
new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder(Paths.get(args[0]).toFile())
.loadPropertiesFromFile(args[1])
.newGraphDatabase();
}
}
I have a simple POM with 1 dependency:
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
The command line arguments are the paths to my DB and config respectively.
Below is the stacktrace from this graph instantiation error.
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, /home/glemmon/UPDB/data/neo4j-3.0.1/data/databases/graph.db
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:144)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.initFacade(CommunityFacadeFactory.java:40)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:99)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.lambda$createDatabaseCreator$206(GraphDatabaseFactory.java:88)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$$Lambda$1/1313922862.newDatabase(Unknown Source)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:183)
at test.StartDB.main(StartDB.java:11)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine#5483163c' failed to initialize. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:415)
at org.neo4j.kernel.lifecycle.LifeSupport.init(LifeSupport.java:62)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:98)
at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:502)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:433)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107)
at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:99)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:433)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:140)
... 7 more
Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'BlockTreeOrds' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: [Lucene50]
at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:114)
at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
at org.apache.lucene.codecs.perfield.PerFieldPostingsFormat$FieldsReader.<init>(PerFieldPostingsFormat.java:258)
at org.apache.lucene.codecs.perfield.PerFieldPostingsFormat.fieldsProducer(PerFieldPostingsFormat.java:341)
at org.apache.lucene.index.SegmentCoreReaders.<init>(SegmentCoreReaders.java:104)
at org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:65)
at org.apache.lucene.index.ReadersAndUpdates.getReader(ReadersAndUpdates.java:145)
at org.apache.lucene.index.ReadersAndUpdates.getReadOnlyClone(ReadersAndUpdates.java:197)
at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:99)
at org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:435)
at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:100)
at org.apache.lucene.search.SearcherManager.<init>(SearcherManager.java:106)
at org.apache.lucene.search.SearcherManager.<init>(SearcherManager.java:76)
at org.neo4j.kernel.api.impl.index.partition.IndexPartition.<init>(IndexPartition.java:54)
at org.neo4j.kernel.api.impl.index.AbstractLuceneIndex.open(AbstractLuceneIndex.java:101)
at org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider.indexIsOnline(LuceneSchemaIndexProvider.java:178)
at org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider.getInitialState(LuceneSchemaIndexProvider.java:123)
at org.neo4j.kernel.impl.api.index.IndexingService.init(IndexingService.java:200)
at org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.init(RecordStorageEngine.java:403)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:405)
... 16 more
Since I can start the DB as a service using "bin/neo4j", I thought there must be a discrepancy between the files under /neo4j-community/3.0.1/lib and the files Maven is providing. I've tried running my executable with java -cp "/neo4j-community/3.0.1/lib/*" to no avail. Any help would be appreciated.
The most likely reason is that Maven is not including the Lucene jar file's META-INF/services into the compiled artifact:
META-INF/services/org.apache.lucene.codecs.PostingsFormat
org.apache.lucene.codecs.blocktreeords.BlockTreeOrdsPostingsFormat
org.apache.lucene.codecs.bloom.BloomFilteringPostingsFormat
org.apache.lucene.codecs.memory.DirectPostingsFormat
org.apache.lucene.codecs.memory.FSTOrdPostingsFormat
org.apache.lucene.codecs.memory.FSTPostingsFormat
org.apache.lucene.codecs.memory.MemoryPostingsFormat
org.apache.lucene.codecs.simpletext.SimpleTextPostingsFormat
org.apache.lucene.codecs.autoprefix.AutoPrefixPostingsFormat
As you can see, this is where the BlockTreeOrdsPostingsFormat is defined.
You can work round the problem by creating a shaded jar with a ServicesResourceTransformer, which will merge all the various META-INF/services from all the included jar files together.
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>...</mainClass>
</transformer>
<!-- merge META-INF/services -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
Your maven dependency is not sufficient, change it to
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-community</artifactId>
<version>3.0.1</version>
<type>pom</type>
</dependency>
update
maybe adding this one solves it:
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-codecs</artifactId>
<version>5.5.0</version>
</dependency>
could this be an encoding issue?
my build currently shows the exact same behavior.
it runs perfectly fine in eclipse but building a jar file drops this error.
my src files are encoded in utf8 as well as all the resources.
I noticed that the db itself and the compilations and jar will be ANSI though.
while creating the database works fine. using transactions on it will utterly fail.
I further noticed that using eclipse i have no charset issues but executing the jar from power shell will display faulty characters.
I also found a nullpointer exception where there shouldn't have been one when looking up a node in the db.
all strong indicators that this might be an encoding issue as the build file itself looks flawless.
sadly it would be quite an effort to convert all my files to ansi just to see if my hunch was correct but maybe this was of help.

Jenkins fails build but on local machine everething is ok

[INFO] Fork Value is true
[java] The following errors occurred during analysis:
[java] Aug 09, 2013 3:16:04 PM edu.umd.cs.findbugs.TextUIBugReporter reportAnalysisError
[java] SEVERE: Unable to get XClass for java/lang/StringBuilder
...
After these messages Jenkins ends build with failure. On local machine i got these messages too, but nothing interrupts, and findbugs, pmd and checkstyle finish correctly.
Also on Jenkins i got
[PMD] No report found for mojo check
[FINDBUGS] No report found for mojo check
, but on local machine i don't. Seems like these two stranges are linked, how can i fix them?
I run mvn verify.
SCA included in pom.xml in build section like
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<skip>false</skip>
<failOnViolation>false</failOnViolation>
<failOnError>false</failOnError>
<xmlOutput>true</xmlOutput>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>findbugs</goal>
</goals>
</execution>
</executions>
</plugin>
The problem was in different jdks. On local machine i have 1.7, but on Jenkins - 1.8, so i simply changed version. And seems like roots of this bug are in jdk 1.8.
apparently, the class structure changed in Java 8. Therefore, FindBugs version 2.0.3 (latest release as of 1. Mai 2014) and earlier fail on classes compiled on JDK 1.8 (or later). They already fixed this in the FindBugs development version (not released as of 4. May 2014). The latest maven plugin (findbugs-maven-plugin:2.5.3) uses FindBugs 2.0.2.
I decided to generate the maven reports with Java 7, until the fix (and a new FindBugs maven plugin version using it) is released.
to generate the reports with Java 7 (linux):
JAVA_HOME=${HOME}/Software/jdk1.7 mvn site
related FindBugs bug reports:
http://sourceforge.net/p/findbugs/bugs/1271/
http://sourceforge.net/p/findbugs/bugs/1264/

Maven Antrun and Dependencies

(See edits below.)
The reason I can't just use the classpath, is because I need to manage some non-java libraries, and I'm compiling a non-java project.
I'm trying to use maven dependencies in an antrun call, following the documentation on the maven site:
http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html
At the bottom of the page:
<property name="mvn.dependency.jar"
refid="maven.dependency.my.group.id:my.artifact.id:classifier:jar.path"/>
<echo message="My Dependency JAR-Path: ${mvn.dependency.jar}"/>
I can't make this work no matter how I try. I've tried ${} around the refid contents, I've tried colons, periods, etc.. as separators in every way I can think of.
Can anyone tell me what that refid should really look like for some common dependency?
EDIT:
Thanks for your reply.
Using your example SingleShot, I have the following:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>create-messages</id>
<phase>compile</phase>
<configuration>
<tasks>
<property name="build.compiler" value="extJavac"/>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<property name="log4j.jar" refid="log4j:log4j:jar"/>
<echo message="Where is the Log4J JAR?: ${log4j.jar}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
</plugin>
And here's what I get when run mvn compile:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Chat Component
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
Downloading: http://<redacted>/content/groups/public/log4j/log4j/1.2.14/log4j-1.2.14.pom
2K downloaded
Downloading: http://<redacted>/content/groups/public/log4j/log4j/1.2.14/log4j-1.2.14.jar
358K downloaded
[INFO] [antrun:run {execution: create-messages}]
[INFO] Executing tasks
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing ant tasks
Embedded error: Reference log4j:log4j:jar not found.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Fri Oct 16 14:54:19 PDT 2009
[INFO] Final Memory: 7M/80M
[INFO] ------------------------------------------------------------------------
EDIT (2):
Looking at the sourcecode linked I decided to run "mvn -X compile" and grep for "Storing", which turns up a bunch of log output where things are getting stored.
Of interest are the facts that the dependency I'm explicitly specifying isn't showing in the list, and, that when I switch to a key based on one of the entries I do see, I still get the error.
Based on the code that SingleShot linked to, and random poking until it worked, here's how I got this problem "working", (I say in quotes because it feels very tenuous.)
Here's the way to make it properly work:
<property name="log4j_location"
value="${maven.dependency.log4j.log4j.jar.path}"/>
<echo message="${log4j_location}"/>
Some important things to note: You cannot use the maven dependency as a refid in setting the ant property. You have to use ${} to get the maven var value.
It appears that the dependency must be in the top-level dependency list, making log4j a dependency of the antrun plugin does not expose it to the plugin in anyway that I can see.
All of the path separators are dots (.), no colons (:) which is why I ultimately checked my own answer as correct.
Soapbox:
I would highly recommend anyone considering Maven use Ant with maven plugins or, even better, use Ant with Ivy instead.
This particular problem is a shining example of the utterly absurd level of difficulty associated with doing anything out of the norm with maven.
I say this having implemented an entire build system based on Maven2, and having also implemented several build systems in Ant. I've used both Maven2 and Ant with complex builds involving Java, Flex/AS3, C# and C++. Maven makes sense for Java projects that have no external dependencies on projects in other languages.
Maven does address some things that aren't addressed implicitly by Ant, but with some up front planning, Ant is the much more flexible, better documented, and the less buggy tool.
If you decide to go the ant route, make sure to define a structure for your projects, figure out your dependency system (Use one).
I think you will ultimately be much happier than with Maven, as you won't spend crunch time trying to fix your build system.
As an addendum to Aaron H.'s answer above, I had to set the plugin's version to 1.3 for that to actually work. I was using it without a specific version and was getting 1.1 (where nothing seems to work).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
...
</plugin>
Without an example of what you typed into your POM its hard to say, but consider a concrete example. Let's say your POM references log4j (groupId=log4j, artifactId=log4j). I believe this is how you would reference that JAR in your Ant file:
<property name="log4j.jar" refid="maven.dependency.log4j:log4j:jar.path"/>
<echo message="Where is the Log4J JAR?: ${log4j.jar}"/>
Ideally you shouldn't have to reference specific JARs, but rather, reference the entire classpath for the appropriate scope, as the somewhat sparse documentation for the plug-in indicates.
If you still have trouble, please post the <dependency> tag for a Maven POM dependency you are using and I can try to be more specific.
I looked at the plugin's code to confirm.
This works for me.
<copy file="${javax.mail:javax.mail-api:jar}" todir="tomcat/lib" />
<copy file="${org.springframework:spring-instrument-tomcat:jar}" todir="tomcat/lib" />
<copy file="${postgresql:postgresql:jar}" todir="tomcat/lib"/>
http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html has the explanation of how to reference dependencies form the ant classpath.
There is a bug in the documentation. The path should be of the form:
<property name="mvn.dependency.jar"
value="${maven.dependency.my.group.id.my.artifact.id.classifier.jar.path}"/>
So the correct key for your log4j dependency would be:
maven.dependency.log4j.log4j.jar.path
Also note that it should be value= rather than refid=, so the full property would be:
<property name="log4j.jar"
value="${maven.dependency.log4j.log4j.jar.path}"/>
<echo message="My Dependency JAR-Path: ${log4j.jar}"/>
I have an existing ant and we planned to use (new) maven to call it. I encountered problems that I may not remember clear, but it is related to class pathes, maybe just like yours.
The problem is, the "ant" we are using daily is a shell script that sets class pathes, both on XNIX and Windows. I have not compared class pathes set by it and those available to maven, but my test showed they dont match and ant won't run with some pathes passed to it from maven.
What I am using is "exec-maven-plugin" and run ant as an external program with some arguments applied. This is sure to work but adds extra dependencies, though.

Resources