0

I'm using the maven-antrun-plugin to do several things to a single deployable artifact after packaging. However, the package I'm using makes several assumptions about the class path of its own plugins which are not in any repository. I've tried adding the plugin files to the jar, with no success. My next step is to let the plugins reside in a folder next to the jar file with the following structure:

    .
    nutch2handler.jar
    plugins/
        plugin1/plugin1.jar
        plugin2/plugin2.jar
        plugin3/plugin3.jar
        etcetcetc

After antrun is done packaging the various artifacts(jar, plugins, www, shell scripts etc), it adds some configuration to the root of the jar for the same reason as above, and this works in this case. I know I can create a property hold a string containing a path I want to add to the classpath, but I don't want to type in all of these 20+ plugins into that property, as the plugin content may vary. How do I recursively add these jar files to that class-path?

I currently have

    <property name="jar.class.path" value="" />

In my target configuration, and want to insert something like this with

    <attribute name="Class-Path" value="${jar.class.path}"/>

Inside the jar tag.

RushTea
  • 15
  • 4
  • Just to understand it right: your resulting artifact is one jar, containing other jars? – sorencito Aug 05 '14 at 13:51
  • My resulting artifact is my own classes, and the library dependencies of my project. Unfortunately, as mentioned, there are no repository artifacts for the plugins, so I have to add these either to the jar(which didn't seem to work for plugins, but did for the configuration. I assume this is because the plugins are nested in folders), so I believe the logical next step is to make sure all their jars are added to the classpath of the jar's manifest – RushTea Aug 05 '14 at 13:55
  • You could try to upload the plugins to your own mvn repo. Try your local repo to check out of that works. – sorencito Aug 05 '14 at 13:57
  • i think this will help - http://stackoverflow.com/questions/858766/generate-manifest-class-path-from-classpath-in-ant – ing8ar Aug 05 '14 at 14:23

1 Answers1

0

If your nutch2handler.jar and all other pluigns are in folder named "lib":

you can define something like below to add all recursive jars to your classpath:

<path id="jar.class.path">
  <fileset dir="lib">
    <include name="**/*.jar" />
  </fileset>
</path>

and then you can use <classpath refid="jar.class.path" /> to refer to the property where ever necessary.

user3487063
  • 3,672
  • 1
  • 17
  • 24