Luca Ferrari wrote:
Hi guys,
I've got a problem creating a buildfile for a project of mine, where I'd like also to build a jar as final step. This is source tree:

projectRoot
  +src                  // java sources
  +srcTest                      // junit sources
  +img                  // icons
  +lib                          // jar required by the project
  +conf                 // configuration files

I've created a build file that creates a build directory that compiles the sources and copies the resource (images and configuration), producing a tree like the following:

build
 +classes
 +conf
 +img
 +lib
 +deploy

where deploy should contain the jar created. The problem is that the jar is created but without the directory I'd like to include (classes, conf, img), but with the resources in a flat space. For example, instead of having img/ I've got all the images in the root of the jar, the same happens for the conf directory. I didn't find a solution, can anyone please explain me how to include the resource in the jar? My jar target is the following:

<target name="dist" depends="compile" >
                <jar destfile="${build.jar.name}" update="false" >
                        
                        <!-- include the compiled files (classes directory)-->
                        <fileset dir="${build.dir}">
                        </fileset>
                        

                        <!-- include the images (img directory)-->
                        <fileset dir="${build.img.dir}">
                        </fileset>

                        
                        
                        <!-- the manifest of this jar -->
                        <manifest>
                                <attribute name="Built-By"    value="${user.name}" 
         />
                                <attribute name="Main-Class"  
value="${runtime.mainclass}"  />
                                
                                <!-- a section with a few notes -->
                                <section name="additional-info">
                                      <attribute name="Project-Name"    
value="${ant.project.name}"/>
                                      <attribute name="Project-Version" 
value="${build.version}"   />
                                          <attribute name="Project-Build"   
value="${build.number}"    />
                            </section>
                                
                        </manifest>

                </jar>
                
        </target>


Thanks,
Luca

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

A quick and dirty solution is to create a directory with the exact structure you want in the jar file (use the copy task for this). Then use jar with the basedir attribute. Maybe someone else could come up with a better answer?

Also, I think it's better (and seems to be commonplace) to use /dist as the directory to place your files for distribution (jar's, war's, ear's etc)

So for example you create:
/dist
  tmp/
     classes/
     img/
     lib/

and then you <jar destfile="${dist.dir}/${build.jar.name}" basedir="${dist.dir}/tmp/"> etc.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to