Display name
Display name

Reputation: 658

executable jar using ant and ivy - CLASSPATH issues

I'm trying to build an executable jar file using ant managed by ivy but am stuck. Our original build-script assembles the jar file more or less okay. The dependencies are in the manifest.mf but not under Class-Path but rather Compile-Class-Path entry.

I can simply set the Main-Class entry in the menifest file but having an impossible foe in trying to get the ivy dependencies in the Class-Path. While this seems simple enough using gradle I can't find any solution for ivy dependencies.

Is there a way of getting the resolves ivy dependencies and put them in the manifest? These dependencies are just paths to a network location where the jar files are.

Upvotes: 1

Views: 387

Answers (1)

smoothed9
smoothed9

Reputation: 66

I'm giving a standard way to do this. If you can provide your actual build file, I can be more specific in the answer.

You can do this in the ant target for jar creation. For ex:

<!-- create a classpath variable with all the jars needed for runtime -->
<path id="cls.path">
   <!-- declare all the paths that you need. For ex: all resolved jars in "runtime" conf --> 
</path>
<!-- If your path has folder prefix, you'll have to do <pathconvert> -->
<jar jarfile="${jar_name}" basedir="${classes.dir}">
   <manifest>
      <attribute name="Class-Path" value="${cls.path}"/>
      ...
      <!-- You can add standard jar properties and any custom property here -->
   </manifest>
</jar>

Upvotes: 0

Related Questions