You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Karr, David" <da...@wamu.net> on 2007/11/01 17:24:17 UTC

Ideas for integrating the code for a custom build step into project source code

I work on a large application that is built with Maven 1.  It has
numerous subproject directories.

At one point we realized that it would be handy to write a custom build
step that would utilize a custom PMD rule class, along with some Ant
code that uses the XMLTask library.  The Ant code parses all the Spring
context files to determine some candidate bean classes to process
through the PMD rule.

I tested this in an isolated environment, just using Ant.  It works
fine.  My problem is that I can't figure out the best way to integrate
this into Maven (1), with the assumption that the PMD custom rule class
has two roles, both project source code and compiled class.  I could
just punt and manually build a jar file with the compiled PMD rule class
and store that in the project dependencies, but that seems to have a
smell.

What I'd like is if there is a change to the PMD class (or perhaps a new
one added to the set), the build would first compile those, and then the
steps that process the normal project source code would reference that
PMD class.

Any ideas about how to best structure this?

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


RE: Ideas for integrating the code for a custom build step into project source code

Posted by Jeff Jensen <je...@upstairstechnology.com>.
Done "completely", I don't think it is a smell, but a good solution.  I
suggest:
 1. Make a "custom PMD" project that contains your Java rules and PMD rules
files, and its own POM.  The artifact type is a jar.

 2. Deploy/install the jar to your corporate repo (or local if not
available).

 3. Add the "custom PMD" jar as a dependency to each project as necessary.

 4. For any PMD rule changes, just increment the POM version and install
again.

Since Maven adds all deps to the classpath, you can refer to your PMD rules
files in the jar (use its package name and file name, just like a resource -
which it is).

I've done this for my current customer, and it works well.  Feel free to ask
further on any clarifications...


> -----Original Message-----
> From: Karr, David [mailto:david.karr@wamu.net]
> Sent: Thursday, November 01, 2007 11:33 AM
> To: Maven Users List
> Subject: RE: Ideas for integrating the code for a custom build step into
> project source code
> 
> To clarify one point, I would be integrating the PMD execution into all
> of the individual subproject builds, so it has to be available to all of
> them, but the compilation and "deployment" of the PMD custom rule class
> has to happen before any of the subprojects are processed.
> 
> > -----Original Message-----
> > From: Karr, David
> > Sent: Thursday, November 01, 2007 9:24 AM
> > To: Maven Users List
> > Subject: Ideas for integrating the code for a custom build
> > step into project source code
> >
> > I work on a large application that is built with Maven 1.  It
> > has numerous subproject directories.
> >
> > At one point we realized that it would be handy to write a
> > custom build step that would utilize a custom PMD rule class,
> > along with some Ant code that uses the XMLTask library.  The
> > Ant code parses all the Spring context files to determine
> > some candidate bean classes to process through the PMD rule.
> >
> > I tested this in an isolated environment, just using Ant.  It
> > works fine.  My problem is that I can't figure out the best
> > way to integrate this into Maven (1), with the assumption
> > that the PMD custom rule class has two roles, both project
> > source code and compiled class.  I could just punt and
> > manually build a jar file with the compiled PMD rule class
> > and store that in the project dependencies, but that seems to
> > have a smell.
> >
> > What I'd like is if there is a change to the PMD class (or
> > perhaps a new one added to the set), the build would first
> > compile those, and then the steps that process the normal
> > project source code would reference that PMD class.
> >
> > Any ideas about how to best structure this?
> >
> > ---------------------------------------------------------------------
> > 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
> 




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


RE: Ideas for integrating the code for a custom build step into project source code

Posted by "Karr, David" <da...@wamu.net>.
To clarify one point, I would be integrating the PMD execution into all
of the individual subproject builds, so it has to be available to all of
them, but the compilation and "deployment" of the PMD custom rule class
has to happen before any of the subprojects are processed.

> -----Original Message-----
> From: Karr, David 
> Sent: Thursday, November 01, 2007 9:24 AM
> To: Maven Users List
> Subject: Ideas for integrating the code for a custom build 
> step into project source code
> 
> I work on a large application that is built with Maven 1.  It 
> has numerous subproject directories.
> 
> At one point we realized that it would be handy to write a 
> custom build step that would utilize a custom PMD rule class, 
> along with some Ant code that uses the XMLTask library.  The 
> Ant code parses all the Spring context files to determine 
> some candidate bean classes to process through the PMD rule.
> 
> I tested this in an isolated environment, just using Ant.  It 
> works fine.  My problem is that I can't figure out the best 
> way to integrate this into Maven (1), with the assumption 
> that the PMD custom rule class has two roles, both project 
> source code and compiled class.  I could just punt and 
> manually build a jar file with the compiled PMD rule class 
> and store that in the project dependencies, but that seems to 
> have a smell.
> 
> What I'd like is if there is a change to the PMD class (or 
> perhaps a new one added to the set), the build would first 
> compile those, and then the steps that process the normal 
> project source code would reference that PMD class.
> 
> Any ideas about how to best structure this?
> 
> ---------------------------------------------------------------------
> 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