Closed cdelmas closed 7 years ago
You're absolutely correct, but this behaviour is intentional.
A correct base URI can be generated in Maven using ${project.baseUri}
instead of ${project.basedir}
(there's an example of that in the Jenkins integration test pom)
If we have the user specify a valid URI in the configuration, we can avoid all sorts of issues with the old java.io.File
implementation. For example some really annoying bugs around converting a path to a URI, especially when used together with Windows UNC paths:
Having said that, the documentation might need to be extended to add a tutorial on how to use Release Candidate on Windows. What do you think?
I tried using project.baseUri, but this is not defined. Trying this:
mvn -o help:evaluate -Dexpression=project.baseUri
leads to: "null object or invalid expression", with Maven 3.3.9 at least. So I don't know how to work around this problem without using a String instead of a URI in the code.
Moreover, my patch won't work with valid URIs of course, but I assume that users will either save to a local file or to stdout, which I think is a decent assumption.
If you know another way, I would use it :)
EDIT: in fact, this works if I configure the plugin directly in the pom, but doesn't work if I try to pass the value from the command line.
Interesting, looks like a bug in the help plugin? I didn't expect it to struggle with that...
Anyway, I just tested on windows and ${project.baseUri}
is resolved correctly and it works as expected when the Release Candidate is configured in the pom
.
You're saying that there's a problem with passing the value for the command line though? Could you please give me an example of how you're invoking it?
Thanks! J
Sure:
mvn release-candidate:version -DoutputUri=${project.baseUri}/version.properties
leads to the following trace: [ERROR] Failed to execute goal com.smartcodeltd:release-candidate-maven-plugin:1.0.0-201601120029.6e3772b:version (default-cli) on project cloud-parent: Unable to parse configuration of mojo com.smartcodeltd:release-candidate-maven-plugin:1.0.0-201601120029.6e3772b:version for parameter outputUri: Cannot convert '${project.baseUri}/version.properties' to URI: Illegal character in path at index 1: ${project.baseUri}/version.properties -> [Help 1]
Seems like it is not expanded, whereas ${project.basedir} is (which leads to a path error).
Interesting, it looks like the problem might be caused by a bug in Maven preventing the project.baseUri
from being evaluated :-/ I'll see if I can work around the problem (it hasn't been fixed in 5 years...) or if we should just go with representing the path as a File
... Meh, sad face.
When setting outputUri to ${project.basedir}/project.properties on Windows, the plugin fails with an URISyntaxException.