You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Marie Sauvage <ma...@ebmwebsourcing.com> on 2006/11/21 11:01:51 UTC

[Fwd: building project for Eclipse and compiling generated sources]

Hi !

I'm new in maven and have a problem with the building of my project for 
Eclipse.
The compilation is in two phases : first, an ant task takes the sources, 
process annotations with spoon and generates new and complete sources, 
then maven compiles those sources.
Original sources are in ${basedir}/src/java
Ant generated sources are in ${basedir}/target/spooned

Here is the interesting part of our original pom.xml :

        <build>
            <sourceDirectory>${basedir}/target/spooned</sourceDirectory>

            <resources>
                <resource>
                    <directory>${basedir}/target/spooned</directory>
                    <includes>
                        <include>**/*.fractal</include>
                    </includes>
                </resource>
                /[... other <resource> declarations ... ]/
            </resources>

            <plugins>
                <!-- ANT PLUGIN -->
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>fraclet-generation</id>
                            <phase>generate-sources</phase>
                            <configuration>
                                <tasks>
                                    <ant antfile="./build.xml"
                                        inheritRefs="true">
                                        <target name="fraclet-processing" />
                                    </ant>
                                </tasks>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
              /[...]/


Problem is when we try to build the Eclipse project : source directory 
isn't the good directory, it's "target/spooned", which isn't our working 
directory.
I found documentation on "generated-sources" but (as long as I 
understood...) it doesn't suit : we don't work in target/spooned, it's 
just a temporary location in compile process.

I try to use profiles : one for eclipse building, one for maven 
compiling. I obtain the same result with just one profile for Eclipse, 
defining the good resource directory ; after that, sourceDirectory 
indicates the generated-sources directory for compile :

        <profiles>
            <profile>
                <id>eclipse</id>
                <build>
                <resources>
                    <resource>
                    <directory>${basedir}/src/java</directory>
                    <includes>
                        <include>**/*.fractal</include>
                    </includes>
                    </resource>
                </resources>
                </build>
            </profile>
        </profiles>

        <build>
            <sourceDirectory>${basedir}/target/spooned</sourceDirectory>

            <resources>
                <resource>
                    <directory>${basedir}/src/jmx-console</directory>
                    <includes>
                        <include>**</include>
                    </includes>
                </resource>

                <resource>
                    <directory>${basedir}/src/resources</directory>
                    <includes>
                        <include>**</include>
                    </includes>
                </resource>
            </resources>

            <plugins>
                <!-- ANT PLUGIN -->
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>fraclet-generation</id>
                            <phase>generate-sources</phase>
                            <configuration>
                                <tasks>
                                    <ant antfile="./build.xml"
                                        inheritRefs="true">
                                        <target name="fraclet-processing" />
                                    </ant>
                                </tasks>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>


Compiling is good : it generates sources and takes them for the jar 
construction.

For building Eclipse project I use the following command line :
mvn -Peclipse eclipse:eclipse

It's almost good : src/java is in build path... but target/spooned 
appears in project too, so there is conflicts between classes (each 
class is duplicated in both src and spooned) and there is hundreds of 
errors.
Is there a way to exclude some directories of the path ? or to make 
Eclipse taking only the explicitly given directory and not all ${basedir} ?

I tried to be complete, I hope I have been clear and not too long... 
thanks for your help :)

Marie Sauvage.


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