Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sharing filesets between Checkstyle in Ant and Eclipse Plugin?

 
Sean Keane
Ranch Hand
Posts: 582
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know if it is possible to share filesets between the Checkstyle Ant task and the Checkstyle Eclipse plugin?

In the Checkstyle Eclipse plugin you configure filesets for files you want to include using the GUI in Eclipse and the results get stored in the .checkstyle file that is created in the same location as your .project file. An example of the output in the .checkstyle file is:

So this excludes all files from my "tests/java" folder when running Checkstyle from within Eclipse.

This .checkstyle file is obviously specific just to the Eclipse plugin. So when it comes to running Checkstyle as an Ant task in my build I don't think I can use it the settings from this .checkstyle file. I need to specify the filesets to exclude\include in a different way. So for example in my Ant task I have the following:

This will include all my Java files from my source directory and obviously it will not include the files from my test directory. So this works.

Now I have Eclipse and Ant set up to include (or exclude) the correct files for checking with Checkstyle. However I had to configure them both independently. Does anyone know of a way where I can specify which files to check in one location that will be shared between both the Eclipse plugin and the Ant task?
 
Sean Keane
Ranch Hand
Posts: 582
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas folks?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean,
I haven't tried it, but the Ant plugin page provides a config attribute that points to a config file. That config file contains filters. Is it the same format as the .checkstyle file?
 
Sean Keane
Ranch Hand
Posts: 582
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne. Yep, there's a config setting where you can point at a file that contains the configuration for Checkstyle. I could be wrong, but my understanding is that this configuration file is for specifying what checks will be carried out. I am indeed able to share this file between the Ant task and the Eclipse plugin.

So in my Ant task I have:

where the {dir.settings} is the .settings directory of my Eclipse project.

Then in my .checkstyle file for Eclipse I have the following:

So you can see that both the Ant task and the Eclipse plugin are referencing the same checkstyle.xml file.

However, my problem is that this checkstyle.xml file doesn't seem to allow you specify which files should be included when these checks are run. So I have to specify them separately in both my .checkstyle file and in my Ant target.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic