Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2005

Tip: Looking for answers? Try searching our database.

Ant:  the file attribute is required

Thread view: 
hawat.thufir@gmail.com - 16 Mar 2005 03:52 GMT
package1 task is all wrong, but I can't figure out the error message.
what's meant by "the file attribute is required"?

D:\>
D:\>ant
Buildfile: build.xml

clean:
  [delete] Deleting directory D:\java\classes

prepare:
   [mkdir] Created dir: D:\java\classes

compile:
   [javac] Compiling 2 source files to D:\java\classes

manifest1:

manifest2:

package1:

BUILD FAILED
D:\build.xml:44: the file attribute is required

Total time: 4 seconds
D:\>type build.xml
<project name="XHTML" default="package2">

       <property name="outputDir" value="java\classes\" />
       <property name="dummyDir" value="java\classes\" />
       <property name="sourceDir" value="java\src\atreides\xhtml\" />
       <property name="javadocDir" value="java\src\atreides\xhtml\" />
       <property name="mainClass1" value="HelloWorldSwing" />
       <property name="mainClass2" value="Test16" />
       <property name="pkgPath" value="atreides.xhtml." />
       <property name="jarPath" value="java\src\org\w3c\tidy\Tidy.jar"
/>

       <target name="clean">
               <delete dir="${outputDir}" />
       </target>

       <target name="prepare" depends="clean">
               <mkdir dir="${outputDir}" />
       </target>

       <target name="compile" depends="prepare">
               <javac srcdir="${sourceDir}"
                       destdir="${outputDir}"
                       classpath="${jarPath}"
               />
       </target>

       <target name="manifest1" depends="compile">
               <manifest file="${outputDir}/MANIFEST.MF">
                       <attribute name="Main-Class"
value="${pkgPath}${mainClass1}" />
               </manifest>
       </target>

       <target name="manifest2" depends="manifest1">
               <manifest file="${outputDir}/MANIFEST.MF">
                       <attribute name="Main-Class"
value="${pkgPath}${mainClass2}" />
               </manifest>
       </target>

       <target name="package1" depends="manifest2">
               <jar
                       destfile="${mainClass1}.jar"
                       basedir="${sourceDir}"
                />
               <manifest>
               </manifest>
       </target>

       <target name="package2" depends="package1">
               <jar jarfile="${outputDir}/${mainClass2}.jar"
               basedir="${outputDir}"
               manifest="${outputDir}/MANIFEST.MF" />
       </target>
</project>

D:\>

thanks,

Thufir
Jouko Johansson - 16 Mar 2005 11:59 GMT
I have noticed that jar-tag is easier to use if you use fileset-tag

for example

<jar destfile="nameofjar.jar" >
   <fileset dir="dir_where_the_classes_are">
       <include name="which_files_are_included" />
   </fileset>
</jar>

Hopefully this helps.

- Jouko
> package1 task is all wrong, but I can't figure out the error message.
> what's meant by "the file attribute is required"?
[quoted text clipped - 85 lines]
>
> Thufir
hawat.thufir@gmail.com - 16 Mar 2005 13:01 GMT
> I have noticed that jar-tag is easier to use if you use fileset-tag
>
[quoted text clipped - 9 lines]
>
> - Jouko
[..]

closer, I think:

       <target name="package1" depends="manifest2">
               <jar
                       destfile="${outputDir}/${mainClass1}.jar"
                       <fileset dir="${sourceDir}">
                               <include name="${mainClass1}" />
                       </fileset>
                       manifest="${outputDir}/MANIFEST.MF"
                />
       </target>

       <target name="package2" depends="package1">
               <jar
                       destfile="${outputDir}/${mainClass2}.jar"
                       basedir="${outputDir}"
                       manifest="${outputDir}/MANIFEST.MF"
               />
       </target>
</project>

D:\>ant
Buildfile: build.xml

BUILD FAILED
D:\build.xml:35: Element type "jar" must be followed by either
attribute specifications, ">" or "/>".

Total time: 0 seconds
D:\>

thanks,

Thufir


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.