Return-Path: Delivered-To: apmail-maven-users-archive@www.apache.org Received: (qmail 85010 invoked from network); 2 Oct 2009 11:19:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Oct 2009 11:19:03 -0000 Received: (qmail 55965 invoked by uid 500); 2 Oct 2009 11:19:01 -0000 Delivered-To: apmail-maven-users-archive@maven.apache.org Received: (qmail 55855 invoked by uid 500); 2 Oct 2009 11:19:00 -0000 Mailing-List: contact users-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Users List" Reply-To: "Maven Users List" Delivered-To: mailing list users@maven.apache.org Received: (qmail 51962 invoked by uid 99); 2 Oct 2009 11:13:14 -0000 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Message-ID: <4AC5E022.5060908@codehaus.org> Date: Fri, 02 Oct 2009 13:12:34 +0200 From: Werner Guttmann User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Maven Users List Subject: Re: How to add generated resources directory in a plugin References: <200910011420.57298.Roland.Asmann@cfc.at> <4AC4AB5F.8070702@gmx.net> <200910011524.15964.Roland.Asmann@cfc.at> In-Reply-To: <200910011524.15964.Roland.Asmann@cfc.at> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org That does not really match what I am observing .. :-(. If I generate Java sources and resources into target/generated-sources/castor and use project.addCompileSourceRoot("target/generated-sources/castor") within the Maven plugin for Castor, Maven will include the generated Java classes during compilation and put the class files in target/classes of the project. As a result of this, users of the Maven plugin for Castor currently have to add the following section to their project POMs. target/generated-sources/castor **/*.cdr src/main/resources to have those .castor.cdr Files copied to target/classes as well. As we all know, this is error-prone. As such, I tried to add code to the Maven plugin for Castor as follows: Resource resource = new Resource(); resource.setDirectory( getResourceDestination().getAbsolutePath() ); List includes = new LinkedList(); includes.add( "**/*.cdr" ); resource.setIncludes( includes ); project.addResource( resource ); Problem is that once I add that code, the Java source files start showing up in target/classes, which is not ideal. Any idea what's going wrong here ? Werner Roland Asmann wrote: > I believe this can work (not 100% sure, I generate into two different > directories for sources and resources), but you should probably ONLY use the > addCompileSourceRoot for your directory... > > The way I understand it, is that if you put sources & resources there, they > are compiled to the output dir. Java knows how to handle .java-files --> > convert them to classes, and how to handle anything else --> just copy. > If you use the resource-dir, maven will handle the copying and will copy > everything from the source to the target, without compiling. > > So, I presume you have used both calls I gave you, although you should only > use one. > > Hope this helps, > > > On Thursday 01 October 2009 15:15, Werner Guttmann wrote: >> Hi Roland, >> >> does this pattern/recipe change if both resources and Java classes would >> be generated in the same directory. I have tried this a few days ago >> (trying to automate a few things for the castor-maven-plugin), and it >> seems like this does not really work. >> >> Assume you have a directory where you'll find .... >> >> - A.java >> - B.java >> - .castor.cdr >> >> where the last is a resource file. If I use above code snippets, I can >> see in the target folder after a plugin run and subsequent compilation >> the compiled Java classes, the resource file and the source files. >> >> How can I avoid the source files to be copy across ? >> >> Regards >> Werner >> >> Roland Asmann wrote: >>> Assuming you already have the maven-project as a variable in your plugin >>> (if not, add it!): >>> >>> project.addCompileSourceRoot("your output directory here"); >>> >>> >>> And in the case of resources: >>> >>> Resource resource = new Resource(); >>> resource.setDirectory("your output directory here"); >>> resource.addInclude("**/*"); >>> project.addResource(resource); >>> >>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote: >>>> Hi >>>> >>>> I'm writing a plugin which generates resources and also test resources. >>>> How in my plugin can I add these directories to the sources paths and >>>> the test resources paths? (Except for using the build-helper plugin) >>>> >>>> Best regards, >>>> Eric >>>> >>>> --------------------------------------------------------------------- >>>> 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