maven


org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2 error


I have the following Maven project structure:
xyz
|
-props
| |
| - root.properties
|
-module_a
| |
| -pom.xml
|
-pom.xml
My root artifact defines a child module (module_a) and this is referencing the parent artifact.
In the root pom.xml I am reading a property file from the common props folder using the
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2 plugin.
When I issue the
mvn clean package
command I get the following putput:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] my_artifact
[INFO] module_a
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my_artifact 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # my_artifact ---
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) # my_artifact ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building module_a 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # module_a ---
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) # module_a ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] my_artifact ....................................... SUCCESS [0.234s]
[INFO] module_a .......................................... FAILURE [0.000s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.344s
[INFO] Finished at: Thu Aug 09 15:37:46 CEST 2012
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (default) on project module_a: Properties file not found: G:\java\xyz\module_a\props\root.properties -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :module_a
In the child module Maven tries to read the property file from an inexistetnt subfolder. Can anybody help me solve this?
Thank you
When maven evaluates the pom files and creates the effective poms ( aggregated with inheritance) some properties are excluded from being inherited. These are the ones starting with project.* and therefore also the project.basedir. Thats why you cannot define the property from where the property file is being loaded in the parent.
The reason for this behaviour is isolation. Every module should be isolated from everything but the maven repository. Even using the settings.xml profiles violates this invariant and you loose the portability of builds.
This invariant is not necessary in many cases so if you have many modules and you want to use one property file, what you can do is:
define a property e.g. "filters.dir" in your root pom to ${project.basedir}/src/main/filters
configure the plugin to load a property file from ${filters.dir}/my.properties
in any submodule you can now override filters.dir to ../src/main/filters
if you have many submodules you can define a wrong path "../src/main/filters" for filters.dir in the root and then you don't need to define the property in any submodule. To prevent the build from failing you need to set the plugin to ignore failures.
An alternative would be to write a maven extension by extending AbstractMavenLifecycleParticipant and load the property file there using the maven api to determine the root directory of your project.

Related Links

System.Diagnostics.Debug.WriteLine() Does Not Work Under NUnit Console
how to use maven with intellij 13
Automatically download missing artifacts if missing in Artifactory
How to package up a leiningen project for recompilation with all the libraries included? [for users without an internet connection]
How to fail when maven profile does not exist?
Sharing dependencies not in central repo with the project
license issue in mule when building with junit test cases
Change Maven repository that NetBeans uses
Maven release-plugin doesn't update LATEST version
How to configure pom.xml so deploy custom artifact to remote repo (archiva)
Making sure all dependency versions are specified in dependencyManagement in maven
How to update archetype-catalog in Nexus repository
deployment of an ejb maven project from eclipse
Maven gwt:compile produces no hosted html file
Grails 2.3.7 repository issues
excluding spring jars from spring-data maven dependency

Categories

HOME
compiler-construction
zeromq
fluentd
tizen
push-notification
tinymce
hashmap
spring-cloud-stream
maven-3
sqlite3
umd
ckeditor
acquia
virtualization
tomcat6
row
modx-revolution
apache-cayenne
n-gram
dtrace
quickfix
iolanguage
apache-metamodel
beyondcompare
karma-jasmine
opencover
tokenize
intentfilter
excel-2007
cultureinfo
jndi
info.plist
social-media
assistant
procdump
tinymce-4
yadcf
normal-distribution
catalog
fusionpbx
angularjs-factory
dynamic-reports
isbn
keydown
http-redirect
smartcontracts
zip4j
prolog-setof
worksheet
gabor-filter
mako
bind9
or-tools
eventkit
pycaffe
time-and-attendance
jquery-filter
wdf
removechild
elements
firebaseui
lua-5.1
qgraphicsview
python-stackless
bluemix-app-scan
iad
teamcity-8.0
django-unittest
pundit
unity3d-gui
sortedlist
mmc
iiviewdeckcontroller
bridge.net
truevault
lustre
operator-precedence
tablelayout
file-copying
markers
onactivityresult
sgen
kgdb
c18
ms-project-server-2010
apc
batterylevel
sqlperformance
typoscript2
mhtml
coderush
transactionscope
doh
deobfuscation
genshi
hamachi
disclosure
floating
remember-me
cxxtest
modelstate
routedevent
anti-piracy
sector
spec#

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