Question

I am trying to create tar and exclude file from directory roopendra but its not seems to work. When I am trying to untar file I am getting error gzip: stdin: not in gzip format. my file exclude also not working. After running build.xml its creating tar but when I am trying to untar as below. I am using Ant version 1.9.3

Command :

$ tar -xvzf projecttar.tar.gz

Getting Error :

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

build.xml :

<?xml version="1.0"?>
<project name="testdir" default="all_task" basedir=".">
  <property name="src"   value="src"/>
    <property name="build" value="build"/>
      <property name="lib"   value="lib"/>
      <property name="project.dir" value="${project}/testdir" />

        <target name="all_task">
           <antcall target="create_directory"/>
           <antcall target="create_tar"/>
        </target>

        <target name="create_directory">
          <mkdir dir="${dist}" />
          <echo message=" ${dist} directory created successfully" />
        </target>

        <target name="create_tar">
          <tar destfile="${project}/build/projecttar.tar.gz" compression="gzip"
                       basedir="${project.dir}"
                                   excludes="${project.dir}/roopendra/**"/>
         </target>

</project>

Build Command :-

ant -buildfile build.xml -Ddist=/home/pathto/roop/projectRv/ -Dproject=/home/pathto/roop/   

Output :-

Buildfile: /opt/apache-ant-1.9.3/build.xml

all_task:

create_directory:
     [echo]  /home/pathto/roop/projectRv/ directory created successfully

create_tar:
      [tar] Building tar: /home/pathto/roop/build/projecttar.tar.gz

BUILD SUCCESSFUL
Total time: 0 seconds

I have already tried : Ant not creating tar files

After run

ant -v

Output:

Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Trying the default build file: build.xml
Buildfile: /opt/apache-ant-1.9.3/build.xml
Detected Java version: 1.7 in: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/jre
Detected OS: Linux
parsing buildfile /opt/apache-ant-1.9.3/build.xml with URI = file:/opt/apache-ant-1.9.3/build.xml
Project base dir set to: /opt/apache-ant-1.9.3
parsing buildfile jar:file:/opt/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/opt/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Property "project" has not been set
Build sequence for target(s) `all_task' is [all_task]
Complete build sequence is [all_task, create_tar, create_directory, ]

all_task:
Project base dir set to: /opt/apache-ant-1.9.3
  [antcall] calling target(s) [create_directory] in build file /opt/apache-ant-1.9.3/build.xml
parsing buildfile /opt/apache-ant-1.9.3/build.xml with URI = file:/opt/apache-ant-1.9.3/build.xml
Project base dir set to: /opt/apache-ant-1.9.3
Override ignored for property "src"
Override ignored for property "build"
Override ignored for property "lib"
Property "project" has not been set
Override ignored for property "project.dir"
Build sequence for target(s) `create_directory' is [create_directory]
Complete build sequence is [create_directory, create_tar, all_task, ]
  [antcall] Entering /opt/apache-ant-1.9.3/build.xml...
Build sequence for target(s) `create_directory' is [create_directory]
Complete build sequence is [create_directory, create_tar, all_task, ]

create_directory:
Property "dist" has not been set
    [mkdir] Skipping /opt/apache-ant-1.9.3/${dist} because it already exists.
Property "dist" has not been set
     [echo]  ${dist} directory created successfully
  [antcall] Exiting /opt/apache-ant-1.9.3/build.xml.
Project base dir set to: /opt/apache-ant-1.9.3
  [antcall] calling target(s) [create_tar] in build file /opt/apache-ant-1.9.3/build.xml
parsing buildfile /opt/apache-ant-1.9.3/build.xml with URI = file:/opt/apache-ant-1.9.3/build.xml
Project base dir set to: /opt/apache-ant-1.9.3
Override ignored for property "src"
Override ignored for property "build"
Override ignored for property "lib"
Property "project" has not been set
Override ignored for property "project.dir"
Build sequence for target(s) `create_tar' is [create_tar]
Complete build sequence is [create_tar, create_directory, all_task, ]
  [antcall] Entering /opt/apache-ant-1.9.3/build.xml...
Build sequence for target(s) `create_tar' is [create_tar]
Complete build sequence is [create_tar, create_directory, all_task, ]

create_tar:
Property "project" has not been set
Property "project" has not been set
  [antcall] Exiting /opt/apache-ant-1.9.3/build.xml.

BUILD FAILED
/opt/apache-ant-1.9.3/build.xml:28: The following error occurred while executing this line:
/opt/apache-ant-1.9.3/build.xml:42: basedir does not exist!
    at org.apache.tools.ant.taskdefs.Tar.execute(Tar.java:249)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:440)
    at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    at org.apache.tools.ant.Main.runBuild(Main.java:851)
    at org.apache.tools.ant.Main.startAnt(Main.java:235)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Was it helpful?

Solution

Finally, I have got solution here http://www.donaldsimpson.co.uk/?p=122 . file permissions were not being preserved when Taring up a build with Ant

<target name="create_tar">
    <tar destfile="${project}/build/projecttar.tar.gz" basedir="${project.dir}" longfile="gnu" compression="gzip">

      <tarfileset dir="${project}/build/" filemode="755">
            <include name="**/*roopendra/*.sh" />
      </tarfileset>

    </tar>
</target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top