You could add the test class to the main source, and make your junit
dependency optional, so it should not be included in transitive
dependencies.

Or you could distribute a separate test-jar with your project, and
have people depend on this if they need your base test classes.
See http://maven.apache.org/guides/mini/guide-attached-tests.html

Tom

On 11/18/06, mraible <[EMAIL PROTECTED]> wrote:

We're experiencing the following issue in AppFuse's migration to Maven 2:

http://issues.appfuse.org/browse/APF-478

For each artifact we're creating, we'd like to include the BaseTestCase
class from that project's test module.  It looks like other folks are
interested in doing this as well:

http://jira.codehaus.org/browse/MPJAR-34

The easiest way to do this seems to be to put the class in my "source" tree,
but then I have to add JUnit as a "compile" dependency and JUnit will end up
in any WARs that are created.  Seems simple enough, but the extra JAR in the
WAR seems ugly.

Another solution might be to post-process and add the class to the main JAR
before it's installed.  This seems possible, but I couldn't get it to work
with the following configuration:

                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <classesDirectory>
                        ${project.build.testOutputDirectory}
                    </classesDirectory>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

The 3rd solution I can think of is to create a new "test" module that
contains the base classes for all artifacts I'm creating.  This module can
then be referenced as a dependency in other modules.  The only problem with
this is this module will likely have a lot of dependencies, since my
BaseTestCase classes sometimes interact with Spring MVC, Tapestry, Struts
and JSF.  So I'll end up with a similar problem to the one spring-mock has.
The workaround is likely to make all those dependencies optional.

The last solution I can think of is to include these test classes in the
archetypes that we create for end users.  However, the whole archetype
system doesn't appear to be very robust (i.e. I can't prompt users for
input), so I don't know if archetypes will even be useable for our needs.
We're currently thinking creating a Plugin is a better option, but I'm not
sure if plugins support prompting.  Do they?  If not, I suppose we could use
an Ant-based plugin or just write some sort of installer.

Thanks for any advice,

Matt

--
View this message in context: 
http://www.nabble.com/How-do-I-include-base-tests-classes-in-main-JAR-tf2660727s177.html#a7421437
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to