gpt4 book ai didi

linux - 无法使用 ANT 创建 tar

转载 作者:太空宇宙 更新时间:2023-11-04 04:05:30 24 4
gpt4 key购买 nike

我正在尝试创建 tar 并从目录 roopendra 中排除文件但它似乎不起作用。当我尝试解压文件时,出现错误 gzip: stdin: not in gzip format。我的文件排除也不起作用。运行 build.xml 后,它会创建 tar,但是当我尝试按如下方式解压时。我正在使用 Ant 版本 1.9.3

命令:

$ tar -xvzf projecttar.tar.gz

出现错误:

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>

构建命令:-

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

输出:-

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

我已经尝试过: Ant not creating tar files

运行后

ant -v

输出:

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)

最佳答案

最后,我在这里找到了解决方案 http://www.donaldsimpson.co.uk/?p=122 。使用 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>

关于linux - 无法使用 ANT 创建 tar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21328869/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com