SmartSprites

Output is written to Program Files Directory with output.dir.path in build.xml

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.2.3
  • Fix Version/s: 0.2.4
  • Component/s: None
  • Description:
    Hide

    If the build.xml is executed with a current directory different from the directory of the build.xml file, then the output is not written as expected when output.dir.path is set.

    This means that the smartsprites ant task cannot be easily integrated in some major existing build scripts e.g. build scripts of the NetBeans IDE.

    How to reproduce this:

    • Make a copy of the binary distribution
    • In the NetBeans IDE (Version 6.7.1 RC), in the Favorites window, add the directory of the copy
    • In the Favorites Window, expand the web.xml node
    • Right click on the task "process" and select "Run Target"
    • In Windows, go to the folder "C:\Program Files\NetBeans 6.7\bin". You should not see any output there as expected.
      ok.
    • Edit the file smartsprites.properties (right click, Edit), change output.dir.path=css-output-dir, css.file.suffix=
    • Right click on the task "process" and select "Run Target"
    • In Windows, go to the folder "C:\Program Files\NetBeans 6.7\bin". There is a new folder css-output-dir with images and css.

    This is unexpected.

    It is very good that the distribution contains the examples so reporting an issue is really easy. Many thanks!

    Show
    If the build.xml is executed with a current directory different from the directory of the build.xml file, then the output is not written as expected when output.dir.path is set. This means that the smartsprites ant task cannot be easily integrated in some major existing build scripts e.g. build scripts of the NetBeans IDE. How to reproduce this:
    • Make a copy of the binary distribution
    • In the NetBeans IDE (Version 6.7.1 RC), in the Favorites window, add the directory of the copy
    • In the Favorites Window, expand the web.xml node
    • Right click on the task "process" and select "Run Target"
    • In Windows, go to the folder "C:\Program Files\NetBeans 6.7\bin". You should not see any output there as expected. ok.
    • Edit the file smartsprites.properties (right click, Edit), change output.dir.path=css-output-dir, css.file.suffix=
    • Right click on the task "process" and select "Run Target"
    • In Windows, go to the folder "C:\Program Files\NetBeans 6.7\bin". There is a new folder css-output-dir with images and css.
    This is unexpected. It is very good that the distribution contains the examples so reporting an issue is really easy. Many thanks!

Activity

Hide
Stanisław Osiński added a comment - 26/Jul/09 10:12 PM

Thanks for the report and detailed reproduction steps, Bernard! Scheduling for 0.2.4 for investigation.

Show
Stanisław Osiński added a comment - 26/Jul/09 10:12 PM Thanks for the report and detailed reproduction steps, Bernard! Scheduling for 0.2.4 for investigation.
Hide
Stanisław Osiński added a comment - 04/Aug/09 08:47 PM

Hi Bernard,

If you use output.dir.path=css-output-dir, SmartSprites will assume this path is relative to the current directory and generate the output there. SmartSprites does support absolute paths in output.dir.path, which is the simplest solution to your problem.

I'm not too familiar with NetBeans, but maybe it somehow exposes some properties relating to the project the build file is run in? If so, you could modify build.xml to put that property as a prefix in the outputdir attribute of the smartsprites task.

Thanks,

Staszek

Show
Stanisław Osiński added a comment - 04/Aug/09 08:47 PM Hi Bernard, If you use output.dir.path=css-output-dir, SmartSprites will assume this path is relative to the current directory and generate the output there. SmartSprites does support absolute paths in output.dir.path, which is the simplest solution to your problem. I'm not too familiar with NetBeans, but maybe it somehow exposes some properties relating to the project the build file is run in? If so, you could modify build.xml to put that property as a prefix in the outputdir attribute of the smartsprites task. Thanks, Staszek
Hide
Bernard added a comment - 08/Aug/09 10:37 PM

Hi Stanislaw,

We can ignore NetBeans for the moment. I have made a testcase with a simple script as follows. This should make it easier to see the problem.

How to reproduce this without NetBeans:

  • Make a copy of the binary distribution
  • In the same directory as build.xml, create a script that executes build.xml
  • Delete the directory css-output-dir
  • Run the script
  • Search for the folder css-output-dir
    It should not exist. ok.
  • Edit the file smartsprites.properties. Change output.dir.path=css-output-dir, css.file.suffix=
  • Run the script
  • The directory css-output-dir is created in the same directory as the build script.
    This is not consistent with the documentation in build.xml

The Windows script that I execute from an explorer window:

@echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_06
set ANT_HOME=C:\Program Files\ant
set PATH=%PATH%;C:\Program Files\ant\bin
ant

Show
Bernard added a comment - 08/Aug/09 10:37 PM Hi Stanislaw, We can ignore NetBeans for the moment. I have made a testcase with a simple script as follows. This should make it easier to see the problem. How to reproduce this without NetBeans:
  • Make a copy of the binary distribution
  • In the same directory as build.xml, create a script that executes build.xml
  • Delete the directory css-output-dir
  • Run the script
  • Search for the folder css-output-dir It should not exist. ok.
  • Edit the file smartsprites.properties. Change output.dir.path=css-output-dir, css.file.suffix=
  • Run the script
  • The directory css-output-dir is created in the same directory as the build script. This is not consistent with the documentation in build.xml
The Windows script that I execute from an explorer window: @echo off set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_06 set ANT_HOME=C:\Program Files\ant set PATH=%PATH%;C:\Program Files\ant\bin ant
Hide
Stanisław Osiński added a comment - 09/Aug/09 12:46 PM

Hi Bernard,

Based on the documentation (I'm assuming you meant smartsprites.properties rather than build.xml?), where would you expect the css-output-dir to be created if you set output.dir.path=css-output-dir?

S.

Show
Stanisław Osiński added a comment - 09/Aug/09 12:46 PM Hi Bernard, Based on the documentation (I'm assuming you meant smartsprites.properties rather than build.xml?), where would you expect the css-output-dir to be created if you set output.dir.path=css-output-dir? S.
Hide
Bernard added a comment - 09/Aug/09 11:51 PM

Hi Stanislaw,

My apologies, I think the last testcase hides the issue rather than pointing it out. It appears that output.dir.path is relative to the current directory of program execution. However, in ant build environments as used with IDEs etc., it is expected that paths are relative to the location of the build script. I think that ant instructions e.g. fileset work like this and make it really easy to conform with this standard.

Here is a revised test case that shows the dilemma:

  • Make a copy of the binary distribution
  • In the directory above build.xml (outside), create a script that executes build.xml
    ant -buildfile smartsprites\build.xml
  • Delete the directory css-output-dir
    smartsprites\test\css-output-dir
  • Run the script
    New files are created as expected relative to the ant script directory:
    smartsprites\test\real-world-example\css\common-sprite.css
    smartsprites\test\real-world-example\img\sprite-vert.png
    smartsprites\test\real-world-example\img\sprite-horiz.png
  • Search for the folder css-output-dir
    It should not exist. ok.
  • Edit the file smartsprites.properties. Change output.dir.path=css-output-dir, css.file.suffix=
  • Run the script
  • The directory css-output-dir is created in the same directory as the command script not the build script.
    I would like to note that other files are clearly following the rule of being relative to the the directory of the build script - output.dir.path appears to not be following it.

Best regards

Bernard

Show
Bernard added a comment - 09/Aug/09 11:51 PM Hi Stanislaw, My apologies, I think the last testcase hides the issue rather than pointing it out. It appears that output.dir.path is relative to the current directory of program execution. However, in ant build environments as used with IDEs etc., it is expected that paths are relative to the location of the build script. I think that ant instructions e.g. fileset work like this and make it really easy to conform with this standard. Here is a revised test case that shows the dilemma:
  • Make a copy of the binary distribution
  • In the directory above build.xml (outside), create a script that executes build.xml ant -buildfile smartsprites\build.xml
  • Delete the directory css-output-dir smartsprites\test\css-output-dir
  • Run the script New files are created as expected relative to the ant script directory: smartsprites\test\real-world-example\css\common-sprite.css smartsprites\test\real-world-example\img\sprite-vert.png smartsprites\test\real-world-example\img\sprite-horiz.png
  • Search for the folder css-output-dir It should not exist. ok.
  • Edit the file smartsprites.properties. Change output.dir.path=css-output-dir, css.file.suffix=
  • Run the script
  • The directory css-output-dir is created in the same directory as the command script not the build script. I would like to note that other files are clearly following the rule of being relative to the the directory of the build script - output.dir.path appears to not be following it.
Best regards Bernard
Hide
Stanisław Osiński added a comment - 10/Aug/09 07:14 PM

Ok, now I see your point, Bernard. In the short term, you could hack this on build.xml level by prefixing the paths with build.xml file location (see the diffs here: http://fisheye3.atlassian.com/browse/carrot2/labs/smartsprites/build-autonomous.xml?r1=3637&r2=3642). For a long term solution, let me investigate what the Ant's convention is. If it's really that all relative paths are resolved against build.xml location, it would make sense for SmartSprites to follow that convention.

Show
Stanisław Osiński added a comment - 10/Aug/09 07:14 PM Ok, now I see your point, Bernard. In the short term, you could hack this on build.xml level by prefixing the paths with build.xml file location (see the diffs here: http://fisheye3.atlassian.com/browse/carrot2/labs/smartsprites/build-autonomous.xml?r1=3637&r2=3642). For a long term solution, let me investigate what the Ant's convention is. If it's really that all relative paths are resolved against build.xml location, it would make sense for SmartSprites to follow that convention.
Hide
Stanisław Osiński added a comment - 05/Sep/09 07:37 PM

Hi Bernard,

I've made the smartsprites task to follow Ant's convention of resolving relative paths against the location of the build.xml file. Now, SmartSprites should work correctly in NetBeans for you. Please let me know if it does.

Download:

http://download.csssprites.org/smartsprites-0.2.4-dev.zip

Thanks for the report!

S.

Show
Stanisław Osiński added a comment - 05/Sep/09 07:37 PM Hi Bernard, I've made the smartsprites task to follow Ant's convention of resolving relative paths against the location of the build.xml file. Now, SmartSprites should work correctly in NetBeans for you. Please let me know if it does. Download: http://download.csssprites.org/smartsprites-0.2.4-dev.zip Thanks for the report! S.
Hide
Bernard added a comment - 06/Sep/09 04:22 AM

Stanislav,

Many thanks! This works great now. SmartSprites can now be integrated easily into any ant build script where the project can be moved around without having to change any paths.

Show
Bernard added a comment - 06/Sep/09 04:22 AM Stanislav, Many thanks! This works great now. SmartSprites can now be integrated easily into any ant build script where the project can be moved around without having to change any paths.
Hide
Stanisław Osiński added a comment - 06/Sep/09 07:56 PM

Closing for the 0.2.4 release.

Show
Stanisław Osiński added a comment - 06/Sep/09 07:56 PM Closing for the 0.2.4 release.

People

Dates

  • Created:
    25/Jul/09 08:48 AM
    Updated:
    06/Sep/09 07:56 PM
    Resolved:
    05/Sep/09 07:35 PM

Time Tracking

Estimated:
Not Specified
Original Estimate - Not Specified
Remaining:
0h
Remaining Estimate - 0h
Logged:
0.5h
Time Spent - 0.5h