Skip to content

Ant XML imports break the "List Targets" feature #15

@ZaLiTHkA

Description

@ZaLiTHkA

I'm running ST3 x86 build 3065 under Windows 8.1 Pro x64, having issues trying to get this extension to read a Netbeans-generated Ant build script correctly. And fair warning: I don't do Python very well, I know enough to get by with debugging, but that's about it.

I hate Netbeans with the fire of a thousand burning suns, but other devs at work use it, so I'm trying to get this to work with Netbeans-generated Ant build scripts.

The specific problem I'm having is with regards to opening imported files.. Netbeans starts off with a build.xml file in the root of the project, which imports build-impl.xml from the nbprojects folder. For web app projects, this last file also imports a ant-deploy.xml file.

First I had an issue with the fact that Netbeans stores all paths Unix-style (separators are forward slashes), so I included a step to replace / with os.sep. The idea here is that if it's Unix, / will be replaced with /, if it's NT based, / becomes \. All good there.

Then I had an issue getting SuperAnt to grab the correct path for the imported file. After reading the line nbprojects/build-impl.xml from my build script, it would try and open that as an absolute path and fail. I got around this with os.path.join(self-working_dir, importFile) after my separator replacement line above.

To clarify, this is where I stand currently with SuperAnt_exec.py, lines 131-146:

if followImports:
    imports = dom.getElementsByTagName('import');
    for imp in imports:

        importFile = imp.getAttributeNode("file").nodeValue;
        print("Debug - importFile: initial string: " + importFile)

        # Windows-specific use case, Ant files use unix-style path formatting by default
        importFile = importFile.replace('/',os.sep);
        print("Debug - importFile: after string.replace: " + importFile)

        importFile = os.path.join(self.working_dir, importFile);
        print("Debug - importFile: self.working_dir: " + self.working_dir)
        print("Debug - importFile: string.join: " + importFile)

        projects = projects + self._get_projects_from_file(importFile, followImports);

The issue I have now is that build-impl.xml imports ant-deploy.xml from the same dir. Looking at the console output, when I run the "List Targets" task, I see the following:

Project detected searching folders for buildfile
Project folder search found buildfile at "D:\Dev Stuff\Java\Tests\My Project\build.xml".
Opening D:\Dev Stuff\Java\Tests\My Project\build.xml
Debug - importFile: initial string: nbproject/build-impl.xml
Debug - importFile: after string.replace: nbproject\build-impl.xml
Debug - importFile: self.working_dir: D:\Dev Stuff\Java\Tests\My Project
Debug - importFile: string.join: D:\Dev Stuff\Java\Tests\My Project\nbproject\build-impl.xml
Opening D:\Dev Stuff\Java\Tests\My Project\nbproject\build-impl.xml
Debug - importFile: initial string: ant-deploy.xml
Debug - importFile: after string.replace: ant-deploy.xml
Debug - importFile: self.working_dir: D:\Dev Stuff\Java\Tests\My Project
Debug - importFile: string.join: D:\Dev Stuff\Java\Tests\My Project\ant-deploy.xml
Opening D:\Dev Stuff\Java\Tests\My Project\ant-deploy.xml
The file: "D:\Dev Stuff\Java\Tests\My Project\ant-deploy.xml" could not be opened

Thing is, my ant-deploy.xml is inside the nbproject folder, so I actually need the followImports loop to remember the directory of the currently processed xml file. Basically the last import needs to be D:\Dev Stuff\Java\Tests\My Project\nbproject\ant-deploy.xml.

Any advice on how to fix this? Not knowing very much about Python leaves me a bit stuck here..

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