Continuous Integration - Maven

Properties for Maven

You can  reference a property value in pom.xml  using ${propertyName} notation.  The value can either be passed in command line as "mvn clean install -DpropertyName=value   or can be defined inside pom.xml  inside <properties><propertyName>value</propertyName></properties>  node.

If you are using Jenkins for CI, then you can also define properties either via Global Properties -> Environment Variables or by specifying settings.xml  under "Maven Configuration". These configurations are  available under "Manage Jenkins"  menu option.

How to reference dependencies from Parent project

The dependencies in parent project don't automatically get included in child project. You need to at least include <groupId> and <artifactId>  in the child project's pom file <dependency> element.

settings.xml 

The <localRepository>  value in settings.xml is very important.  So be careful while copying the settings.xml from one workstation to another.  Maven tries to create that structure if does not already exist. This becomes big issue especially if you copy settings.xml from windows to Mac or linux machines.  In my case, it was trying to create a folder /Users/glbairwa/Desktop/Eclipse.app/Contents/MacOS/C:/gopal/.m2/repository/com/......
because my localRepository was set to  C:/gopal/.m2/repository

Symbol not found - compilation error 
One or more jars in maven dependencies not included in compile classpath and you get "symbol not found" error or something similar.  Check the scope for dependency. If it is "test" it wont get included during executing "compile","install"  goals.

pom.xml shows error  for a element

At times this was due to the incorrect version specified so it is unable to download the dependencies. For example  following element was showing error in eclipse.   The error was resolved when I changed the version to 2.1.6-RELEASE and ran 'maven install'  again.

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>




Comments

Popular posts from this blog

SQL

Analytics

DBeaver