Question

How exactly should I specify the location of all the properties files inside the ant manifest?

My jar is not working because it can't find the log4j, Spring, etc properties.

These files are all contained within a folder called "server-config" that sits at the same level as the source code, ie:

  • META-INF
  • com
  • server-config

Essentially, I want to know what I need to add to the Class-Path property for the jar to be aware of all these properties files inside the server-config folder.

Here's my current task:

<jar destfile="${root.home}/onejar/build/main/main.jar" basedir="${build.home}">
        <manifest>
            <attribute name="Class-Path" value=".;server-config" />
        </manifest>
        <include name="com/mycompany/client/*"/>
        <include name="com/mycompany/portable/util/*"/>
        <include name="com/mycompany/request/*"/>
        <include name="com/mycompany/model/*"/>
        <include name="com/mycompany/controller/*"/>
        <include name="com/mycompany/helpers/*"/>
        <include name="server-config/*"/>
    </jar>

I've tried a few things and none of them are working, I keep on getting errors due to the file not being found.

Any help would be greatly appreciated!

Was it helpful?

Solution

You can remove the entire <manifest... part - that's not what the Class-Path manifest attribute does. It's for things external to the JAR.

The line <include name="server-config/*"/> should work - if the server-config directory exists inside your ${build.home} directory. You probably need a task to copy them there - you mention that the source code sits at the same level, but you don't mention where they are compiled to.

An example -

<mkdir dir="${build.dir}/server-config"
<copy todir="${build.dir}/server-config">
  <fileset dir="${src.dir}/server-config">
    <include name="*"/>
  </fileset>
</copy>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top