You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tim Foster <tf...@akorri.com> on 2007/05/17 19:46:30 UTC

How to share a common checkstyle config across modules?

Newbie here.  We have a checkstyle config file that we would like for
all modules within the project hierarchy to use.  Our plan was to store
the config file in a 'buildtools' subdirectory at the top of the project
hierarchy and reference it from the top-level pom.xml file as such:

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

The problem is that I don't know how to specify the path so that it is
always computed correctly for the current level of the hierarchy.  That
is, this setup only works for the top-level POM, while the
<configLocation> path is wrong for the lower-level ones.  I tried using
the ${basedir} variable, but the value of it changes depending upon the
level of the hierarchy.  What I would like is a variable with a value of
the relative path to the top-level directory.

The only way we've been able to get this to work is to store the file in
our internal repository and reference by an absolute url as such:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <configuration>
<configLocation>http://mavenrepo:8080/internal/checkstyle/checkstyle.xml
</configLocation>
    </configuration>
</plugin>

But, I would rather manage this config file in the source control
system.  Of course this problem is not unique to checkstyle as the same
issue exists for any file that needs to be shared across the hierarchy.
Is there a way compute a variable to contain the value of the path
relative to the top-level pom directory?  Or is there a better way to
achieve what I'm trying to do?

Thanks,

Tim


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to share a common checkstyle config across modules?

Posted by Wayne Fay <wa...@gmail.com>.
A few comments:
1. There are numerous software packages available (many free) that
allow you to access a file in SCM with a web url. So you could install
ViewVC or another and still access the file in SCM from a HTTP URL.

2. You can package your Checkstyle configuration in a Jar which you
then reference as a dependency in this project. So you'd make another
Maven2 project, assign it a version, package and install/deploy it,
and then reference it in your other projects with <plugin>...
checkstyle... <dependencies><dependency>your jar here</>.

Wayne

On 5/17/07, Tim Foster <tf...@akorri.com> wrote:
> Newbie here.  We have a checkstyle config file that we would like for
> all modules within the project hierarchy to use.  Our plan was to store
> the config file in a 'buildtools' subdirectory at the top of the project
> hierarchy and reference it from the top-level pom.xml file as such:
>
> <plugin>
>    <groupId>org.apache.maven.plugins</groupId>
>    <artifactId>maven-checkstyle-plugin</artifactId>
>    <configuration>
>        <configLocation>./buildtools/checkstyle.xml</configLocation>
>    </configuration>
> </plugin>
>
> The problem is that I don't know how to specify the path so that it is
> always computed correctly for the current level of the hierarchy.  That
> is, this setup only works for the top-level POM, while the
> <configLocation> path is wrong for the lower-level ones.  I tried using
> the ${basedir} variable, but the value of it changes depending upon the
> level of the hierarchy.  What I would like is a variable with a value of
> the relative path to the top-level directory.
>
> The only way we've been able to get this to work is to store the file in
> our internal repository and reference by an absolute url as such:
>
> <plugin>
>    <groupId>org.apache.maven.plugins</groupId>
>    <artifactId>maven-checkstyle-plugin</artifactId>
>    <configuration>
> <configLocation>http://mavenrepo:8080/internal/checkstyle/checkstyle.xml
> </configLocation>
>    </configuration>
> </plugin>
>
> But, I would rather manage this config file in the source control
> system.  Of course this problem is not unique to checkstyle as the same
> issue exists for any file that needs to be shared across the hierarchy.
> Is there a way compute a variable to contain the value of the path
> relative to the top-level pom directory?  Or is there a better way to
> achieve what I'm trying to do?
>
> Thanks,
>
> Tim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How to share a common checkstyle config across modules?

Posted by Chris Helck <Ch...@us.icap.com>.
Hi Tim,

I recently did something like this (with PMD instead). I used
<extensions> then someone suggested I not use it -- it seems
<extensions> is headed towards deprecation. Instead under
build/plugins/plugin add you stuff as a dependency. Something like this:

     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>     <!- I'm
guessing at the name ->
        <dependencies>
          <dependency>
            <groupId>com.xxx</groupId>
            <artifactId>xxxx-checkstyle</artifactId>
            <version>1.0.o</version>
          </dependency>
        </dependencies>
      </plugin>

Regards,
Chris
 

-----Original Message-----
From: Tim Foster [mailto:tfoster@akorri.com] 
Sent: Friday, May 18, 2007 11:51 AM
To: Maven Users List
Subject: RE: How to share a common checkstyle config across modules?

Thanks, Gerald.  This is exactly what I wanted and it worked just as you
described.  This mechanism will be useful for many other applications.

Tim

-----Original Message-----
From: Nunn, Gerald [mailto:Gerald.Nunn@CIBC.com]
Sent: Thursday, May 17, 2007 1:52 PM
To: Maven Users List
Subject: RE: How to share a common checkstyle config across modules?

I jar my checkstyle configuration and then store it in an intranet Maven
repository. Projects can then declare a dependency on this jar using the
extensions tag in the build section of pom.xml. For example:

	<build>
        <extensions>
            <extension>
              <groupId>com.xxxx</groupId>
              <artifactId>xxxx-checkstyle</artifactId>
              <version>1.0.0</version>
            </extension>
        </extensions>
	</build>

	<reporting>
		<plugins>

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

		</plugins>
	</reporting>

The configLocation is the classpath location in the xxxx-checkstyle.jar.

Hope this helps.

Gerald

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


**********************************************************************
This communication and all information (including, but not limited to,
 market prices/levels and data) contained therein (the "Information") is
 for informational purposes only, is confidential, may be legally
 privileged and is the intellectual property of ICAP plc and its affiliates
 ("ICAP") or third parties. No confidentiality or privilege is waived or
 lost by any mistransmission. The Information is not, and should not
 be construed as, an offer, bid or solicitation in relation to any
 financial instrument or as an official confirmation of any transaction.
 The Information is not warranted, including, but not limited, as to
 completeness, timeliness or accuracy and is subject to change
 without notice. ICAP assumes no liability for use or misuse of the
 Information. All representations and warranties are expressly
 disclaimed. The Information does not necessarily reflect the views of
 ICAP. Access to the Information by anyone else other than the
 recipient is unauthorized and any disclosure, copying, distribution or
 any action taken or omitted to be taken in reliance on it is prohibited. If
 you receive this message in error, please immediately delete it and all
 copies of it from your system, destroy any hard copies of it and
 notify the sender.
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How to share a common checkstyle config across modules?

Posted by Tim Foster <tf...@akorri.com>.
Thanks, Gerald.  This is exactly what I wanted and it worked just as you
described.  This mechanism will be useful for many other applications.

Tim

-----Original Message-----
From: Nunn, Gerald [mailto:Gerald.Nunn@CIBC.com] 
Sent: Thursday, May 17, 2007 1:52 PM
To: Maven Users List
Subject: RE: How to share a common checkstyle config across modules?

I jar my checkstyle configuration and then store it in an intranet Maven
repository. Projects can then declare a dependency on this jar using the
extensions tag in the build section of pom.xml. For example:

	<build>
        <extensions>
            <extension>
              <groupId>com.xxxx</groupId>
              <artifactId>xxxx-checkstyle</artifactId>
              <version>1.0.0</version>
            </extension>
        </extensions>
	</build>

	<reporting>
		<plugins>

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

		</plugins>
	</reporting>

The configLocation is the classpath location in the xxxx-checkstyle.jar.

Hope this helps.

Gerald

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How to share a common checkstyle config across modules?

Posted by "Nunn, Gerald" <Ge...@CIBC.com>.
I jar my checkstyle configuration and then store it in an intranet Maven repository. Projects can then declare a dependency on this jar using the extensions tag in the build section of pom.xml. For example:

	<build>
        <extensions>
            <extension>
              <groupId>com.xxxx</groupId>
              <artifactId>xxxx-checkstyle</artifactId>
              <version>1.0.0</version>
            </extension>
        </extensions>
	</build>

	<reporting>
		<plugins>

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

		</plugins>
	</reporting>

The configLocation is the classpath location in the xxxx-checkstyle.jar.

Hope this helps.

Gerald

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org