That worked.  Thanks Justin.

Now my problem is that I can't seem to get my test resource directories
to be added to the test classpath.

Thoughts?



<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>
        
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.gentiva.example</groupId>
        <artifactId>person-schema</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <name>Example Person Schema</name>
        <packaging>pom</packaging>
        
        <properties>
                <testSourceDir>src/test/unit/java</testSourceDir>
                <testOutputDir>target/test/unit/classes</testOutputDir>
        
<testResourceDir>src/test/unit/resources</testResourceDir>
        </properties>
        
        <build>
                
        
<testSourceDirectory>${testSourceDir}</testSourceDirectory>
        
<testOutputDirectory>${testOutputDir}</testOutputDirectory>
                <testResources>
                        <testResource>
        
<directory>${testResourceDir}</directory>
                        </testResource>
                </testResources>
                
                <plugins>
                
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
        
<artifactId>build-helper-maven-plugin</artifactId>
                                <executions>
                                        <execution>
                                                <id>add-test-source</id>
        
<phase>generate-test-sources</phase>
                                                <goals>
        
<goal>add-test-source</goal>
                                                </goals>
                                                <configuration>
                                                        <sources>
        
<source>target/generated-sources/jaxb</source>
                                                        </sources>
                                                </configuration>
                                        </execution>
                                        <execution>
        
<id>add-test-resource</id>
        
<phase>generate-test-resources</phase>
                                                <goals>
        
<goal>add-test-resource</goal>
                                                </goals>
                                                <configuration>
                                                        <resources>
        
<resource>
        
<directory>${testResourceDir}</directory>
        
</resource>
        
<resource>
        
<directory>src/test/unit/data</directory>
        
</resource>
                                                        </resources>
                                                </configuration>
                                        </execution>

                                        <execution>
        
<id>attach-artifacts</id>
                                                <phase>package</phase>
                                                <goals>
        
<goal>attach-artifact</goal>
                                                </goals>
                                                <configuration>
                                                        <artifacts>
        
<artifact>
        
<file>src/main/resources/Person.xsd</file>
        
<type>xsd</type>
        
</artifact>
                                                        </artifacts>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>


            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                                <configuration>
 
<packageName>com.example.vo</packageName>
 
<schemaDirectory>src/main/resources</schemaDirectory>
 
<schemaFiles>Person.xsd</schemaFiles>
                                </configuration>
                    </execution>
               </executions>
           </plugin>

                        <plugin>
        
<groupId>org.apache.maven.plugins</groupId>
        
<artifactId>maven-compiler-plugin</artifactId>
                                <executions>
                                        <execution>
                                                <id>test-compile</id>
        
<phase>test-compile</phase>
                                                <goals>
        
<goal>testCompile</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>

                        <plugin>
        
<groupId>org.apache.maven.plugins</groupId>
        
<artifactId>maven-surefire-plugin</artifactId>
                                <version>2.5</version>
                                <executions>
                                        <execution>
                                                <id>test-run</id>
                                                <phase>test</phase>
                                                <goals>
        
<goal>test</goal>
                                                </goals>
                                                <configuration>
        
<systemPropertyVariables>
        
<log4j.configuration>test-log4j.xml</log4j.configuration>
        
</systemPropertyVariables>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>

                </plugins>
        </build>

        <reporting>
        
                <plugins>
                
                        <plugin>
        
<groupId>org.apache.maven.plugins</groupId>
        
<artifactId>maven-surefire-report-plugin</artifactId>
                                <version>2.5</version>
                        </plugin>
                        
                        <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
 
<artifactId>maven-project-info-reports-plugin</artifactId>
                        <version>2.1.2</version>
                                <reportSets>
                                        <reportSet>
                                                <reports>
                                                </reports>
                                        </reportSet>
                                </reportSets>
                </plugin>
                
                </plugins>
                
        </reporting>


        <dependencies>

                <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>2.2</version>
                        <scope>test</scope>
                </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2</version>
            <scope>test</scope>
        </dependency>
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>4.6</version>
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                        <version>1.5.6</version>
                        <scope>test</scope>
                </dependency>

        </dependencies>
        
</project>






-----Original Message-----
From: Justin Edelson [mailto:justinedel...@gmail.com] 
Sent: Wednesday, March 10, 2010 11:12 AM
To: Maven Users List
Subject: Re: How do I add phases to a lifecycle that normally skips
them?

Steven-
The phases in a lifecycle have nothing to do with the packaging of a
project. pom-packaged projects just don't have anything bound BY DEFAULT
to the compile, test-compile, etc. phases. You need to configure the
compiler plugin to bind the testCompile goal to the test-compile phase
and the surefire plugin to bind it to the test phase. In the pom below,
you have surefire configure, but it's not bound to a lifecycle phase.

That said, it seems to me that this is a lot of work which you could
avoid by using a separate test project.

Running "mvn compiler:testCompile" just runs a goal, not a lifecycle
phase.

HTH,

Justin


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

Reply via email to