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

How to Integrate BIRT Chart Engine 4.6.0 into maven project
Maven dependency plugin downloads POM instead of tar.gz
Maven get from Wrong repository
Artifactory Dependency Declaration does not match maven-metadata.xml or pom
Jenkins is not showing all executed Tests / Test Results in Build Overview
jBCrypt dependency not working
Maven not importing External Library into project after adding to .pom file in Intellij
docker-maven-plugin build assembly fail
Maven - How to override version?
Dependencies and Repositories?
DriverManager.getConnection never been executen in my maven project
Maven projects - how to read a property that is defined in the pom file of a project that is added as a dependency
Travis CI: Maven fails to get Kotlin 1.1.1 dependency on Linux
How to tell versions-maven plugin to act on non-child modules?
Can soapui maven plugin execute multiple projects parallel?
log4j conflict with Apache Storm 1.0.1 and Elasticsearch 5.3.1

Categories

HOME
maven
bpmn
alfresco
xmpp
kalman-filter
amortized-analysis
malloc
echarts
podio
ios-charts
directx
upload
row
circular-dependency
static-libraries
fortumo
iron-router
jsprit
libtiff
google-static-maps
amazonsellercentral
physics-engine
csrf-protection
dxf
emgucv
smb
entitlements
linkerd
replaceall
windows-server-2000
newline
ecto
galsim
winrt-xaml-toolkit
wallpaper
revolution-slider
file-format
dosbox
retina-display
theano.scan
azure-ml
pdf-reactor
gulp-sourcemaps
eigenvalue
no-www
skeleton-css-boilerplate
azure-application-gateway
strptime
dds
fancybox-2
android-cursor
iso8601
titanium-android
dwscript
minimization
abcpdf9
color-picker
file-writing
autorest
qpid
gridview-sorting
fputcsv
bgp
netmq
maven-tomcat-plugin
intellij-14
django-unittest
wyam
sframe
map-projections
responsive-images
arcanist
myo
operation
vstest.console.exe
fluid-dynamics
javax.mail
facebook-graph-api-v2.4
typekit
jsonpickle
responsive-slides
reactfx
hyprlinkr
typo3-neos
fmod
mysqltuner
ccss
access-rights
spring-io
unc
isnullorempty
cisco-jtapi
newtonscript
bubble-chart
netbeans-6.9
coredump
django-tagging
xmemcached
inotifycollectionchanged
asp.net-mvc-areas
zend-translate
routedevent
vc90
iweb
javap
uimenucontroller
zune
data-acquisition

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