You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2017/12/03 23:46:00 UTC

[Bug 61853] New: ReplaceRegExp task does not work in java

https://bz.apache.org/bugzilla/show_bug.cgi?id=61853

            Bug ID: 61853
           Summary: ReplaceRegExp task does not work in java
           Product: Ant
           Version: 1.10.1
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
          Assignee: notifications@ant.apache.org
          Reporter: chen8002014@163.com
  Target Milestone: ---

ReplaceRegExp task works fine when I am using it in build.xml. However, when I
call it in JAVA code, exception will be thrown. I am sure that Project is not
empty for this task.
JAVA code:
    ReplaceRegExp replaceTask = new ReplaceRegExp();
    replaceTask.setProject(getProject());
    replaceTask.setTaskName(getTaskName());
    FileSet fs1 = new FileSet();
    fs1.setDir(new File(destDir.getPath() + "/tmp/wsdlc/generated"));
    fs1.setIncludes("**/*.java");
    replaceTask.addFileset(fs1);
    replaceTask.setMatch("public class (\\w+) implements java.io.Serializable
\\{");
    replaceTask.setReplace("public class \\1 implements java.io.Serializable
{
    public \\1\\(\\)\\{\\}");
    replaceTask.setByLine(false);
    replaceTask.execute();

Exception:
java.lang.NullPointerException
        at org.apache.tools.ant.types.AbstractFileSet.setupDirectoryScanner(
)
        at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(Ab

        at org.apache.tools.ant.types.FileSet.iterator(FileSet.java:70)
        at org.apache.tools.ant.types.resources.Union.getAllResources(Union.

        at org.apache.tools.ant.types.resources.Union.getCollection(Union.ja

        at org.apache.tools.ant.types.resources.BaseResourceCollectionContai
ResourceCollectionContainer.java:263)
        at org.apache.tools.ant.types.resources.BaseResourceCollectionContai
eCollectionContainer.java:142)
        at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.execute(Repl

        at com.bea.wlcp.wlng.ant.MyTask.modifySource(MyTask.java:464)

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 61853] ReplaceRegExp task does not work in java

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61853

max <ch...@163.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #3 from max <ch...@163.com> ---
Problem solved by setting project to FileSet.
FileSet fs1 = new FileSet();
fs1.setProject(getProject());

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 61853] ReplaceRegExp task does not work in java

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61853

--- Comment #2 from max <ch...@163.com> ---
Similar copy task can be run successfully. However, ReplaceRegExp task fail.
copy = new Copy();
copy.setTaskName(getTaskName());
copy.setProject(getProject());
FileSet fs = new FileSet();
fs.setDir(new File(destDir.getPath() + "/aaa/"));
fs.setIncludes("*.wsdl");
copy.addFileset(fs);
copy.setTodir(new File(destDir.getPath() + "/tmp/wars/" + name + "/wsdls"));
copy.execute();

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 61853] ReplaceRegExp task does not work in java

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61853

--- Comment #1 from max <ch...@163.com> ---
Complete exception:
java.lang.NullPointerException
at org.apache.tools.ant.types.AbstractFileSet.setupDirectoryScanner(
AbstractFileSet.java:541)
at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(Ab
stractFileSet.java:504)
at org.apache.tools.ant.types.FileSet.iterator(FileSet.java:70)
at org.apache.tools.ant.types.resources.Union.getAllResources(Union.
java:148)
at org.apache.tools.ant.types.resources.Union.getCollection(Union.ja
va:108)
at org.apache.tools.ant.types.resources.BaseResourceCollectionContai
ner.cacheCollection(BaseResourceCollectionContainer.java:263)
at org.apache.tools.ant.types.resources.BaseResourceCollectionContai
ner.iterator(BaseResourceCollectionContainer.java:142)
at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.execute(Repl
aceRegExp.java:494)
at com.bea.wlcp.wlng.ant.MyTask.modifySource(MyTask.java:464)

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 61853] ReplaceRegExp task does not work in java

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61853

max <ch...@163.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
                 CC|                            |chen8002014@163.com

-- 
You are receiving this mail because:
You are the assignee for the bug.