Menu

Ant task from command line

Help
sunireddy
2006-12-07
2016-08-06
  • sunireddy

    sunireddy - 2006-12-07

    Hi All,

    I am using Eclipse 3.2.1 and onejar version 0.24 and jdk version 1.4.2_13.

    I exported the ant script from eclipse and trying to run from command line. I am getting the following error,
    The <fatjar.build> type doesn't support the nested "fatjar.manifest" element.
    If i run the same from eclipse it is okay.

    I tried to look for log in .metadata/log but i did not find anything specific to one jar. Please advise on what i am doing wrong.

    Thanks for the help
    Sunitha

     
    • sunireddy

      sunireddy - 2006-12-07

      After looking around i found the solution to this problem,
      With every taskdef in the ant script, use the loaderRef element with the same name. This would make the fatjar.build to recognize fatjar.manifest and other elements.

      Well now i have another problem. :(
      From the script I am trying to exclude some files and using using the following,
      <fatjar.exclude relpath="com/simontuffs/onejar/services/english/HelloService.class"/>

      and i get the following,
      C:\Projects\WorkSpace\demorun\build.xml:19: The <fatjar.build> type doesn't support the nested "fatjar.exclude" element.

      Did anybody previously excluded any files. If so, how did you do?

      Thanks
      Sunitha

       
      • joerg04

        joerg04 - 2008-07-05

        The solution already stated does it not for me. Got the same problem on running
        the build.xml by ant on the terminal.

        It seems, that the inner type implementation like it's already done does not work,
        the addConfigured(Type) gets not called by ant. (Winxp and Leopard, both Java 6)

        Were reading the ant tutorial [1] and another page [2] about nested elements
        I found a little different solution, where a task has to define its
        *nested elements*  this way:

        public void addConfiguredInner(NestedElement anInner)  [1]
        public void addConfigured<elementNAME>(<elementTYPE> element) {} [2]

        Unfortunately, for an element like "fatjar.manifest" this would not work, because the period is not allowed in member names.

        If the manifest names would go to fjmanifest like
        <fatjar.build ..>
          <fjmanifest ..>
        </fatjar.build>

        AND

        the FJBuildTask would provide a method like

        public void addConfiguredFjmanifest(FJManifestType manifestType) {
          this.manifestType = manifestType;
        }

        for manifest and all other attributes accordingly,
        it work. At least for me :)

        [1] http://ant.apache.org/manual/develop.html#nested-elements
        [2] http://www.developer.com/java/ent/print.php/10933_3636196_2

         
        • Ferenc Hechler

          Ferenc Hechler - 2008-07-22

          Hello Joerg,

          could you please explain what exactly does not work?
          The build files do run without problems on my PC (using ANT 1.7).

          Best regards,

              feri

           
      • Ferenc Hechler

        Ferenc Hechler - 2008-07-22

        Hello Sunitha,

        the "fatjar.exclude" tag has to be beyond a "fatjar.filesource" or "fatjar.jarsource" tag.
        See the following example:

        <target name="main">
        <fatjar.build output="fat.jar">
          <fatjar.manifest mainclass="pkg.MainClass" classpath="."/>
           <fatjar.filesource path="U:\workspace\Prj\bin" relpath="">
            <fatjar.exclude relpath="ignore/"/>
           </fatjar.filesource>
          <fatjar.jarsource file="U:\opt\workspace35\MailPOC\lib\mail.jar" relpath=""/>
        </fatjar.build>
        </target>

        This way al files beyond the folder ignore/ are exclude from the file-source "U:\workspace\Prj\bin"

        Best regards,

             feri

         
      • Chris Scheuble

        Chris Scheuble - 2016-08-06

        Add attribute loaderRef with the same value to the taskdef tag and typedef tags that define the fat jar task and types. The value is arbitrary but it needs to be the same value for each tag.
        See http://ant.apache.org/manual/Tasks/typedef.html for more inforation about the loaderRef attribute.

         

Log in to post a comment.