You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by hamdard <hs...@tiscali.co.uk> on 2006/05/22 23:22:24 UTC

Re: [m2]How to get files into test classpath?

Hi 

I have a similar issue where I want to add a jar to the test classpath,
before running the tests.
The jar is generated dynamically (at runtime), so I can't make a static
declaration in the pom.

I need to do something like:

<testResources>
        <testResource>
                <directory>lib/</directory>
                <includes>
                        <include>*.jar</include>
                </includes>
        </testResource>
</testResources>


But it doesn't work when I try. 

Thanks
--
View this message in context: http://www.nabble.com/-m2-How+to+get+files+into+test+classpath--t987507.html#a4512885
Sent from the Maven - Users forum at Nabble.com.


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


Re: [m2]How to get files into test classpath?

Posted by RonnyN <ro...@bouvet.no>.
I have artifacts that I also build test jars from. The test jars is then
referenced by other artifacts.

The artifact (ansattportal-commons) that also should exist as test jar
(tests and test resources):
<build>
       <plugins>
               <plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>test-jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
            </plugins>
</build>


The artifact that depends is configured like this:
             <dependencies> 
                <dependency>
			<groupId>no.avinor</groupId>
			<artifactId>ansattportal-commons</artifactId>
			<version>1.0-SNAPSHOT</version>     
		</dependency>
		<dependency>
			<groupId>no.avinor</groupId>
			<artifactId>ansattportal-commons</artifactId>
			<version>1.0-SNAPSHOT</version>
			<type>test-jar</type>
			<scope>test</scope>
		</dependency>
	</dependencies>

-Ronny


Trygve Laugst?l-5 wrote:
> 
> hamdard wrote:
>> My problem is that I don't have the jar available in advance to add it to
>> the
>> maven's dependency section with scopt test.
>> 
>> The jar is generated as part of a maven lifecycle prior to test
>> ()generate-sources. I need the ability to add a  a directory to the test
>> classpath with a filter *.jar
> 
> Make the plugin attach the generated (test) source directory to the 
> project and the compile plugin will compile the sources and include them 
> in the test class path automatically.
> 
> --
> Trygve
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-m2-How-to-get-files-into-test-classpath--tf987507.html#a6635942
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: [m2]How to get files into test classpath?

Posted by hamdard <hs...@tiscali.co.uk>.
Thanks Trygve 

The workaround works! Here's my configuration that binds the generated
sources and the test sources to the compiler plugin. This way maven compiles
them and put the .classes to the executable (target) directory. 

<sourceDirectory>.</sourceDirectory>
<testSourceDirectory>.</testSourceDirectory>
<plugins>
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<configuration>
		<source>1.5</source>
		<target>1.5</target>
		<includes>
			<include
implementation="java.lang.String">dod/deployments/src/java/**/*.java</include>
		</includes>
		<testIncludes>
			<testInclude
implementation="java.lang.String">src/test/java/**/*.java</testInclude> 
		</testIncludes>
	</configuration>
</plugin>
....
--
View this message in context: http://www.nabble.com/-m2-How+to+get+files+into+test+classpath--t987507.html#a4635367
Sent from the Maven - Users forum at Nabble.com.


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


Re: [m2]How to get files into test classpath?

Posted by Trygve Laugstøl <tr...@apache.org>.
hamdard wrote:
> My problem is that I don't have the jar available in advance to add it to the
> maven's dependency section with scopt test.
> 
> The jar is generated as part of a maven lifecycle prior to test
> ()generate-sources. I need the ability to add a  a directory to the test
> classpath with a filter *.jar

Make the plugin attach the generated (test) source directory to the 
project and the compile plugin will compile the sources and include them 
in the test class path automatically.

--
Trygve

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


Re: [m2]How to get files into test classpath?

Posted by hamdard <hs...@tiscali.co.uk>.
My problem is that I don't have the jar available in advance to add it to the
maven's dependency section with scopt test.

The jar is generated as part of a maven lifecycle prior to test
()generate-sources. I need the ability to add a  a directory to the test
classpath with a filter *.jar

Is this possible?


Thanks
--
View this message in context: http://www.nabble.com/-m2-How+to+get+files+into+test+classpath--t987507.html#a4565660
Sent from the Maven - Users forum at Nabble.com.


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


Re: [m2]How to get files into test classpath?

Posted by John Casey <ca...@gmail.com>.
Can you define a series of dependencies that have <scope>test</scope>? That
would be ideal, since it'll use Maven's artifact resolution code to retrieve
and manage them for you.

HTH,

-john

On 5/22/06, hamdard <hs...@tiscali.co.uk> wrote:
>
>
> Hi
>
> I have a similar issue where I want to add a jar to the test classpath,
> before running the tests.
> The jar is generated dynamically (at runtime), so I can't make a static
> declaration in the pom.
>
> I need to do something like:
>
> <testResources>
>         <testResource>
>                 <directory>lib/</directory>
>                 <includes>
>                         <include>*.jar</include>
>                 </includes>
>         </testResource>
> </testResources>
>
>
> But it doesn't work when I try.
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/-m2-How+to+get+files+into+test+classpath--t987507.html#a4512885
> Sent from the Maven - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>