Ant忽略了复制任务文件?

时间:2015-10-07 08:53:26

标签: ant copy task

我有以下内容:

 <mkdir dir="${build.dir}/serverNIO" />
   <copy todir="${build.dir}/serverNIO" overwrite="true" verbose="true">
    <fileset dir="resources/serverresources">
        <include name="*.properties" />
    </fileset>
</copy>

我想将属性文件从一个文件夹复制到另一个文件夹,除此之外,所有其他任务都可以正常工作。 为什么会这样?我甚至没有收到任何错误消息,文件位于提到的位置。

所以当我尝试运行我的服务器时:

MacBook-Pro:ClientServerNio ramapriyasridharan$ ant run_server
Buildfile: /Users/ramapriyasridharan/Downloads/ClientServerNio/build.xml

init:
    [mkdir] Created dir: /Users/ramapriyasridharan/Downloads/ClientServerNio/bin
    [mkdir] Created dir: /Users/ramapriyasridharan/Downloads/ClientServerNio/dist

compile_server:
    [mkdir] Created dir: /Users/ramapriyasridharan/Downloads/ClientServerNio/bin/serverNIO
     [copy] Copying 1 file to /Users/ramapriyasridharan/Downloads/ClientServerNio/bin/serverNIO
     [copy] Copying /Users/ramapriyasridharan/Downloads/ClientServerNio/resources/serverresources/server.properties to /Users/ramapriyasridharan/Downloads/ClientServerNio/bin/serverNIO/server.properties

init:

compile_common_server:
    [javac] Compiling 3 source files to /Users/ramapriyasridharan/Downloads/ClientServerNio/bin/serverNIO

init:

compile_database_api:
    [javac] Compiling 1 source file to /Users/ramapriyasridharan/Downloads/ClientServerNio/bin/serverNIO
    [javac] Compiling 5 source files to /Users/ramapriyasridharan/Downloads/ClientServerNio/bin/serverNIO

jar_server:
      [jar] Building jar: /Users/ramapriyasridharan/Downloads/ClientServerNio/dist/server.jar

run_server:
     [java] Exception in thread "main" java.io.FileNotFoundException: /ClientServerNio/bin/serverNIO/server.properties (No such file or directory)
     [java]     at java.io.FileInputStream.open(Native Method)
     [java]     at java.io.FileInputStream.<init>(FileInputStream.java:146)
     [java]     at java.io.FileInputStream.<init>(FileInputStream.java:101)
     [java]     at ch.ethz.rama.asl.server.MessageServer.main(Unknown Source)
     [java] Java Result: 1

编辑:

现在它似乎突然复制文件,只有我的服务器程序无法找到属性文件,即使它在同一目录下,我该怎么办?

1 个答案:

答案 0 :(得分:1)

Ant脚本将server.properties复制到...

# ...
    def __call__(self, func):
        arg_names = getargspec(func).args
        self.param_index = arg_names.index(self.param_name)

        @wraps(func)
        def decorated(*args, **kwargs):
            new_args = list(args)
            new_kwargs = kwargs

            try:
                v = new_args.pop(self.param_index)
            except IndexError:
                v = new_kwargs.pop(self.param_name) 
            new_kwargs[self.param_name] = v + 1
            return func(*new_args, **new_kwargs)
        return decorated

...但在/Users/ramapriyasridharan/Downloads/ClientServerNio/bin/serverNIO/server.properties 目标中启动的Java程序正在...

中查找文件
run_server

要解决此问题,请:

    Ant脚本中的
  • /ClientServerNio/bin/serverNIO/server.properties 需要将server.properties复制到<copy>
  • /ClientServerNio/bin/serverNIO需要更改,以便在MessageServer.main
  • 下查找server.properties