Skip to content

Issue with sub folder #7

Open
Open

Description

@cbou

Some folders are not found in ${watched.file}.

When I change the file /home/foo/bar/baz/MyResource.java.

it displays A file has changed! /home/foo/MyResource.java and avoid bar/baz.

I started ant from /home/foo.

<watch>
   <when>
      <target>
         <echo>Something has happened.</echo>
         <echo>A file has changed! ${watched.file}</echo>
      </target>
      <fileset dir="${dir.bar}" includes="**/*"/>
   </when>
</watch>

Activity

  1. chubbard commented on Jul 11, 2017

    @chubbard
    Owner

    I'm sorry I don't understand the problem. You changed MyResource.java and it ran the target which is expected. What did it not do that you expected it to do?

  2. cbou commented on Jul 11, 2017

    @cbou
    Author

    Please consider this setup:

    mkdir test-ant-watch
    touch build.xml
    mkdir -p src/folder
    touch src/folder/File.java
    cp /foo/bar/watch-task-1.0.jar .
    

    build.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <project basedir="." default="deploy" name="RapidRabbit">
       <taskdef name="watch" 
          classname="org.apache.tools.ant.taskdefs.optional.watch.WatchTask"
          classpath="watch-task-1.0.jar" />
       <target name="init">
          <watch>
             <when>
                <target>
                   <echo>Something has happened.</echo>
                   <echo>A file has changed! ${watched.file}</echo>
                </target>
                <fileset dir="src" includes="**/*" />
             </when>
          </watch>
       </target>
    </project>
    

    When I run ant init I get A file has changed! /foo/bar/test-ant-watch/File.java and not A file has changed! /foo/bar/test-ant-watch/src/folder/File.java.

    Apache Ant(TM) version 1.9.2 compiled on July 8 2013
    
    java version "1.8.0_131"
    Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
    
  3. chubbard commented on Jul 14, 2017

    @chubbard
    Owner

    Ok so the sub-directories under the directory you are watching aren't triggering the target? I can try and take a look at that. This going to be operating system sensitive. What OS are you using?

  4. cbou commented on Jul 15, 2017

    @cbou
    Author

    Yes, I'm using macOS 10.12.5

  5. cbou commented on Jul 28, 2017

    @cbou
    Author

    Did you had time to look at the issue? Do you have any tips where I can look at?

  6. cbou commented on Nov 4, 2018

    @cbou
    Author

    You are using the WatchService and it does not do it work recursively by default.
    This class could be used to watch directory and sub items: https://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions