You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Sebastian Zarnekow (JIRA)" <ji...@apache.org> on 2007/10/04 14:38:50 UTC

[jira] Created: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Generator.parse fails, if the outputfile points to a directory, that does not exist.
------------------------------------------------------------------------------------

                 Key: TEXEN-13
                 URL: https://issues.apache.org/jira/browse/TEXEN-13
             Project: Texen
          Issue Type: Bug
            Reporter: Sebastian Zarnekow


The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:

# control.vm
$generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")

So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent (2).

(1)
line 486:
Generator generator = createGenerator();

protected Generator createGenerator() {
  return Generator.getInstance();
}

(2)
public Writer getWriter(final String path, final String encoding) throws Exception {
  final File f = new File(path).getParentFile();
  if (!f.exists()) {
    f.mkdirs();
  }
  ..
}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Resolved: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain resolved TEXEN-13.
------------------------------------

    Resolution: Fixed

patch applied, thanks again.

> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Sebastian Zarnekow
>             Fix For: 1.1
>
>         Attachments: GeneratorNotReallyASingleton.patch
>
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533753 ] 

Will Glass-Husain commented on TEXEN-13:
----------------------------------------

Thanks for contributing.  Nice idea.  Does "ant test" work?

By the way, please take a look at the code style guidelines on our wiki when you have a chance.  It's much easier to update the code if the patch follows them.  (4 spaces, not tabs, and the bodies of all if statements need matching braces on their own lines).  I'll fix the code this time.


> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Sebastian Zarnekow
>             Fix For: 1.1
>
>         Attachments: GeneratorNotReallyASingleton.patch
>
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Updated: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Sebastian Zarnekow (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebastian Zarnekow updated TEXEN-13:
------------------------------------

    Description: 
The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:

# control.vm
$generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")

So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).

(1)
line 486:
Generator generator = createGenerator();

protected Generator createGenerator() {
  return Generator.getInstance();
}

(2)
public Writer getWriter(final String path, final String encoding) throws Exception {
  final File f = new File(path).getParentFile();
  if (!f.exists()) {
    f.mkdirs();
  }
  ..
}

  was:
The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:

# control.vm
$generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")

So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent (2).

(1)
line 486:
Generator generator = createGenerator();

protected Generator createGenerator() {
  return Generator.getInstance();
}

(2)
public Writer getWriter(final String path, final String encoding) throws Exception {
  final File f = new File(path).getParentFile();
  if (!f.exists()) {
    f.mkdirs();
  }
  ..
}


> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>            Reporter: Sebastian Zarnekow
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Updated: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain updated TEXEN-13:
-----------------------------------

        Fix Version/s: 1.1
    Affects Version/s: 1.0

> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Sebastian Zarnekow
>             Fix For: 1.1
>
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Sebastian Zarnekow (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534983 ] 

Sebastian Zarnekow commented on TEXEN-13:
-----------------------------------------

Thanks for the pointer to the code style guidelines.
The patch contains a new test that uses a custom generator. 
"ant test" works.


> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Sebastian Zarnekow
>             Fix For: 1.1
>
>         Attachments: GeneratorNotReallyASingleton.patch
>
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Updated: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Sebastian Zarnekow (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebastian Zarnekow updated TEXEN-13:
------------------------------------

    Attachment: GeneratorNotReallyASingleton.patch

Thanks for extracting createGenerator. 
However the actual implementation of Generator as a singleton makes it impossible to successfully work with a subclass.
I attached a patch that allows to inherit from Generator and will not break existing code. Tests included.

> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Sebastian Zarnekow
>             Fix For: 1.1
>
>         Attachments: GeneratorNotReallyASingleton.patch
>
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Resolved: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain resolved TEXEN-13.
------------------------------------

    Resolution: Fixed

Hi,

I added your first suggestion -- move the creation of the generator into a protected method, allowing it to be overridden.

I'm not sure about the idea of creating directories.  For one thing, this only creates one level -- what if multiple parts of the path are invalid.

I'm going to resolve the issue.  If you want to reopen and discuss, that's fine.  It'd be useful if you could point to other libraries which do this (create parent directories or trees of directories) when trying to write a file.  Most ant tasks I've called don't.  (they give an error that the path doesn't exist).

> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>            Reporter: Sebastian Zarnekow
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Reopened: (TEXEN-13) Generator.parse fails, if the outputfile points to a directory, that does not exist.

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TEXEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain reopened TEXEN-13:
------------------------------------


> Generator.parse fails, if the outputfile points to a directory, that does not exist.
> ------------------------------------------------------------------------------------
>
>                 Key: TEXEN-13
>                 URL: https://issues.apache.org/jira/browse/TEXEN-13
>             Project: Texen
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Sebastian Zarnekow
>             Fix For: 1.1
>
>         Attachments: GeneratorNotReallyASingleton.patch
>
>
> The Texentask generates the outputdirectory, if it does not exist, but the Generator-Implementation lacks this feature for control templates like the following:
> # control.vm
> $generator.parse("myTemplate.vm", "subdirectory/myTemplate.out")
> So either allow subclasses of TexenTask to use another Generator (1), or change the implementation of getWriter to allow the Generator to create absent directories(2).
> (1)
> line 486:
> Generator generator = createGenerator();
> protected Generator createGenerator() {
>   return Generator.getInstance();
> }
> (2)
> public Writer getWriter(final String path, final String encoding) throws Exception {
>   final File f = new File(path).getParentFile();
>   if (!f.exists()) {
>     f.mkdirs();
>   }
>   ..
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org