maven


How can I reference a local Mercurial repository in Maven if it is two directories up?


We have been using SCM URLs in POM files like this:
<scm>
<connection>scm:hg:file:///${basedir}</connection>
<developerConnection>scm:hg:file:///${basedir}</developerConnection>
</scm>
It requires us to start the release process with a "mvn release:prepare -DpushChanges=false", but we had to do that anyway (the hg plugin doesn't handle authentication correctly). The big plus for us is that we can "hg strip" if the release process goes wrong at any point -- no one but the local developers will ever see that.
The same process works if we have a directory inside a Mercurial checkout. In that case the following URLs do the trick:
<scm>
<connection>scm:hg:file:///${basedir}/..</connection>
<developerConnection>scm:hg:file:///${basedir}/..</developerConnection>
<tag>HEAD</tag>
</scm>
But: it all goes wrong when there's another level in there. I have tried a number of variations of the file URL, but they all seem to fail.
The naive approach of using "scm:hg:file:///${basedir}/../.." causes both the site plugin as well as the release plugin to fail. The former will tell me this:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.2:site (default-site) on project epik-protocol-spec: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.2:site failed: This SCM url 'scm:hg:file:///../epik-protocol-spec' is invalid due to the following errors:
[ERROR] * An hg 'file' url must be on the form 'file:///' or 'file://localhost/'.
[ERROR] For more information about SCM URL Format, please refer to: http://maven.apache.org/scm/scm-url-format.html
('epik-protocol-spec' is the name of a module in the build that is running)
The release plugin encounters a similar issue: after a release:prepare the release.properties file will have the scm.url set to "file:///..", which will then fail to get a copy of the tagged code during release:perform. The workaround for this is to fix the property manually between the steps. I haven't found a way to make the site build work, yet.
My goals are:
have a build that just works out of the box (i.e. clone the project from IDE and run any target)
be able to generate the site (and run other builds) on a build server
be able to run releases with the release plugin, with all changes being reviewed before pushing
Has anyone a solution for this? And why do the URLs get mangled so badly -- is the approach bad or are we encountering a Maven problem?
Edit
As proposed by Charlee, I checked the output of mvn help:effective-pom. The SCM URLs are mangled in that. It also shows that Maven appends module names to the URLs, which means it will be necessary to define the URLs on each module -- assuming that the odd mangling can be stopped.
A custom property like this:
<properties>
<test.property>scm:hg:file:///${basedir}/../..</test.property>
</properties>
does not get mangled, it gets resolved as expected (also checked using the effective POM).
The Maven SCM provider is shortening URLs based on a "../" and "..\" matching scheme. If one of these character sequences is matched, it will search backwards for a matching slash (past the one just prior), removing everything back to that. This rule meant that my file URLs, which would look something like this:
scm:hg:file:///C:\some\local\path/../..
would trigger the shortening due to the "../" sequence, it would then delete back to the previous forward slash, which means back to the slash before the "C:", thus deleting the whole path.
This behaviour is not triggered if there's no slash behind the dots, so the step up at the end of my URLs caused no harm -- which explains why I had no issues with going up one level.
The solution (workaround?) is to use this:
scm:hg:file:///${basedir}${file.separator}..${file.separator}..
Then the URL shortening will encounter matching slashes no matter the OS and it starts to work again.
Regarding to the SCM Implementation: Mercurial, it mentions at the example as the following: -
scm:hg:http://host/v3
scm:hg:file://C:/dev/project/v3 (windows drive)
<--- only 2 slashes + [os, e.g. drive:/path/...]
scm:hg:file:///home/smorgrav/dev/project/v3 (linux drive)
<--- only 2 slashes + [os, e.g. /home/...]
scm:hg:/home/smorgrav/dev/project/v3 (local directory)
Anyhow the Maven told us as
This SCM url 'scm:hg:file:///../epik-protocol-spec'
is invalid due to the following errors
Please correct me, if I'm wrong. I understand that you're in the Microsoft Windows environment and may use only 2 slashes for achieving your requirement.
Anyhow the another suspected may be the ${basedir} is resolved as ../epik-protocol-spec. If I understand correctly, it should be a full path instead.
I hope this may help.

Related Links

JGitFlow maven plugin release-start from custom branch
Problems uploading jar artifact to hosted maven repository in nexus OSS 3.0.0-03
Auto deploy a Liferay portlet
log4j2 writing in file when testing, not when deploying
Exclude maven dependency by adding it as test scope?
Call source from exec-maven-plugin
Maven command : add classpath directory for Java runtime [closed]
Nexus Pro is fine with staging repository create but fails with 401 Unauthorized on upload
By Default Don't Build A module [duplicate]
Openshift : how to deploy multiple modules?
configure maven to download a dependency parallely
Swagger Dependencies break Spring Boot application
how to get test result status (how many pass, failures, skip) from maven test
Maven Resources Error in JUnit
Unable to run jmeter 3.0 script with JSON path POST-processor with jmeter-maven-plugin
How to make maven fail is 'jar' packaing is not a jar?

Categories

HOME
maven
openlayers
hive
webpack
cookies
gremlin
plot
syntax
read-eval-print-loop
rubygems
jgroups
in-app-purchase
facebook-messenger-bot
dynamics-crm-online
uitypeeditor
workload-scheduler
highlight.js
code-review
crystal-reports-2008
emulator
abi
mps
css-animations
excel-2007
rundeck
numerical-methods
semantic-analysis
url-scheme
pingfederate
greendao
msys2
google-rich-snippets
data-manipulation
scorm2004
asset-pipeline
http-referer
git-merge
lto
libraries
unspecified
bootstrapper
reportingservices-2005
nomethoderror
password-encryption
angular2-meteor
apple-news
cubic-spline
dropbox-php
jxcore
knockout-components
bind9
django-scheduler
google-cdn
visual-c++-2008
gridpane
database-optimization
measures
skobbler-maps
storekit
clang-static-analyzer
jwplayer7
nsviewcontroller
python-stackless
make-install
yaws
associative-array
jfugue
unity-networking
xna-4.0
execute
jms2
eclipse-clp
drawbitmap
ideamart
sysinternals
myo
appfabric-cache
clipperlib
clicktag
fpml
socketexception
reactfx
srs
mcts
ms-project-server-2010
jmapviewer
apc
odata4j
ruby-datamapper
tws
file-locking
wsdl-2.0
browser-detection
funscript
wse3.0
uiviewanimation-curve
netdna-api
vdsp
coercion
xmlspy
file-comparison
iphone-web-app
paster
.nettiers
suppress
perfect-hash
photoshop-cs4
phonon
pascal-fc
project-hosting
thread-local-storage
scripting-languages
private-members
caching-application-block

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App