You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gautham Pamu <ga...@gmail.com> on 2006/02/19 07:04:02 UTC

m2 compiler plugin and adding additional gen/src folder

Hi,

I have an EJB project created using RAD6 and I have used annotation features
for the session and entity beans. So it created
additional gen/src folder for the generated code. Could you tell me how to
add this additional source to the compilation
path. There was posting on previously, they recommended Ant task but it was
clear what task I should use to
add the source to the classpath. Are they just recommending to compile the
generated source using the ant task and
copying the classes to the same folder target/classes so that packaging
phase of the maven can package these classes ?
If anyone already ran in this situation and already wrote the ant task,
could you share what task you used ?

>m2 compiler plugin and generated
source<http://www.nabble.com/forum/ViewPost.jtp?post=1032097&framed=y>
On 10/5/05, Robert Biernat
<robertb@...<http://www.nabble.com/user/SendEmail.jtp?type=post&post=1037099&i=0>>
wrote:
>> I'm thinking the only way to do this is to write a java based plugin that

>> programmatically plugs in the new directory.
 >
>Yes, or to write an Ant task in antrun to do it...
 >
>- Brett

Thanks in advance

--
-Gautham Pamu

Re: m2 compiler plugin and adding additional gen/src folder

Posted by Cyrille Le Clerc <cy...@pobox.com>.
   Hello Gautham,

   I will reword what you said to be sure I clearly understood. You want to :
1) integrate the websphere ejb code generation task in the
"generate-sources" phase of your maven2 project
2) ensure that these previously generated sources are included in the
"compile" phase of the project (ie : the "gen/src" is added to the
list of surce folders")

   I did this (playing with JAXB instead of Websphere EJBs) thanks to
the <sourceRoot> element of the <plugin> declaration. Extract from
Maven doc :
"<sourceRoot/> adds a single folder to the list of folders that get
compiled with the program source code (compile)."

   Here is the official doc :
http://maven.apache.org/plugins/maven-antrun-plugin/usage.html

   I added to my post the fragment of my pom.xml that runs
"ant-jaxb-xjc" task during the "generate-sources" phase and add the
generated source folders to my project classpath.

   Hope this helps,

   Cyrille
--
Cyrille Le Clerc
cyrille.leclerc@pobox.com
cyrille.leclerc@fr.ibm.com

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <configuration>
        <tasks>
          <taskdef name="xjc"
            classname="com.sun.tools.xjc.XJCTask"
            classpathref="maven.compile.classpath" />
          <mkdir
            dir="target/generated-sources/main/java" />
          <xjc
            schema="src/main/xsd/j2eeLesson.xsd"
            target="target/generated-sources/main/java"
            package="com.mycompany.xml.jaxb">
            <classpath
              refid="maven.compile.classpath" />
          </xjc>
        </tasks>
        <sourceRoot>
          ${project.build.directory}/generated-sources/main/java
        </sourceRoot>
        <testSourceRoot>
          ${project.build.directory}/generated-sources/test/java
        </testSourceRoot>

      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>


On 2/19/06, Gautham Pamu <ga...@gmail.com> wrote:
> Hi,
>
> I have an EJB project created using RAD6 and I have used annotation features
> for the session and entity beans. So it created
> additional gen/src folder for the generated code. Could you tell me how to
> add this additional source to the compilation
> path. There was posting on previously, they recommended Ant task but it was
> clear what task I should use to
> add the source to the classpath. Are they just recommending to compile the
> generated source using the ant task and
> copying the classes to the same folder target/classes so that packaging
> phase of the maven can package these classes ?
> If anyone already ran in this situation and already wrote the ant task,
> could you share what task you used ?
>
> >m2 compiler plugin and generated
> source<http://www.nabble.com/forum/ViewPost.jtp?post=1032097&framed=y>
> On 10/5/05, Robert Biernat
> <robertb@...<http://www.nabble.com/user/SendEmail.jtp?type=post&post=1037099&i=0>>
> wrote:
> >> I'm thinking the only way to do this is to write a java based plugin that
>
> >> programmatically plugs in the new directory.
>  >
> >Yes, or to write an Ant task in antrun to do it...
>  >
> >- Brett
>
> Thanks in advance
>
> --
> -Gautham Pamu

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