Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow having walkmod.xml outside of sources #48

Open
tomasol opened this issue Jan 18, 2016 · 3 comments
Open

Allow having walkmod.xml outside of sources #48

tomasol opened this issue Jan 18, 2016 · 3 comments

Comments

@tomasol
Copy link

tomasol commented Jan 18, 2016

Not a big deal but I would like to keep one walkmod.xml for several projects and be able to specify path to it using WALKMOD_OPTS. I would submit a pull request but don't really understand all those getting/setting of user.dir, also new File(System.getProperty("user.dir")) found on several places - this I believe is equal to new File("")

@rpau
Copy link
Collaborator

rpau commented Jan 18, 2016

Any suggestion to improve walkmod is always welcome!

When you are creating a file with a relative path in java using 'new File("foo")', java resolves the absolute path with the value of the execution dir ("user.dir") and the value of the relative path. In order to conserve correct paths when walkmod is executed recursively (e.g for maven modules), walkmod modifies the value of the "user.dir".

Yes, you can do it with WALKMOD_OPTS checking if the environment variable exists and there is a value for it.

However, walkmod can be executed from a maven plugin or embedded in another system (e.g Eclipse IDE or forge) and people that participate into the project probably want to have the configuration file in another place (e.g a subdirectory). For that reason, I think that this feature would also be implemented with a new optional parameter into all the commands (e.g -f).

Anyway, let's start from just modifying WALKMOD_OPTS 👍

Please, in order to do so, use the dev branch (at this moment is in the same commit than master).

Thanks again for your contributions :)

@abelsromero
Copy link
Contributor

I am not sure I understand the use of "user.dir" because I am getting some weird behaviour, and maybe this it is expected. I created a project to demo it.

  1. I have a folder with what would be a normal walkmod project in it under test/resources: https://github.com/abelsromero/walkmod-tests/tree/master/src/test/resources.
  2. Then I execute Walkmod using the Java interface and I set user.dir to the previous folder here: https://github.com/abelsromero/walkmod-tests/blob/master/src/main/java/org/abelsromero/walkmod/WalkmodRunner.java#L32-L34.
  3. I set my walkmod.xml to take into consideration user.dir: https://github.com/abelsromero/walkmod-tests/blob/master/src/test/resources/walkmod.xml#L18

But debugging I see that the initialisation in the Facade works properly, but If I check the ScriptProcessor (here: https://github.com/rpau/walkmod-core/blob/master/src/main/java/org/walkmod/scripting/ScriptProcessor.java#L108) I see that it searches from the root path of the project, and I access to user.dir it points to the root of the project and not the value I set previously.
So, I don't know If I should be setting it i another way or is some bug?

@abelsromero
Copy link
Contributor

Btw, when the script is not found no error or message is shown.

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

No branches or pull requests

3 participants