We use maven+checkstyle on a multi-project.
We have defined our checks (mycheckstyle.xml) for one of the component. The xml file is stored right at the root of the component (next to the src and target folders)
in the top pom file we have:

  <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-checkstyle-plugin</artifactId>
     <configuration>
        <configLocation>mycheckstyle.xml</configLocation>
     </configuration>
  </plugin>

So we have a structure like this

  topProject
  --- pom.xml

  --- subComponent1
  --- --- src
  --- --- target
  --- --- pom.xml
  --- --- mycheckstyle.xml
  --- --- ...

  --- subComponent2
  --- --- src
  --- --- target
  --- --- pom.xml
  --- --- ...

  --- --- subsubComponent2.1
  --- --- --- src
  --- --- --- target
  --- --- --- pom.xml
  --- --- --- ...

This works fine. But now, we would like to use the same configuration file for ALL our component. So, we would like to have our (single) mycheckstyle.xml file stored only once, right under the topProject, next to the top pom.xml file.

How can we define that in the pom file. I tried using relative path (../mycheckstyle.xml), full url (file:../mycheckstyle.xml), using maven variables ($project.dir/mycheckstyle.xml) but without success, always with one or another error message from maven such as

  Unable to find location '../mycheckstyle.xml' as URL, File or Resource.

Is there any way to combine maven's knowledge of the project/components tree so that each individual component knwos the top level and use it to locate the mycheckstyle.xml. Even better: is there a way to support component with different level in the tree (as subComponent2 and subComponent2.1 in the example above)

Thanks,
Olivier


Reply via email to