Thanks for the pointers, this approach worked well, setting the
maven.test.additionalClasspath property from the VALIDATE stage. The
value is split by surefire, so I modify it it exists.



For archival purposes, I did it as:

@Mojo(name = "dataInit", defaultPhase = LifecyclePhase.VALIDATE)
public class DataInitMojo extends AbstractConfiguredMojo {

    private static final String ADDITIONAL_CLASSPATH =
"maven.test.additionalClasspath";

    public void execute() throws MojoExecutionException {
        // Add the dataArchive to test classpath
        Properties props = project.getProperties();
        String classpath = dataArchive.getAbsolutePath();
        if (props.containsKey(ADDITIONAL_CLASSPATH)) {
            classpath += "," + props.getProperty(ADDITIONAL_CLASSPATH);
        }
        props.put(ADDITIONAL_CLASSPATH, classpath);
    }
}




On 7 October 2015 at 07:34, Tibor Digana <tibor.dig...@googlemail.com> wrote:
> I am not sure if additionalClasspathElement supports CSV but we can check
> it esily in the code.
> My idea is to have one parameterized parent POM with
> <additionalClasspathElement>${my.jars}</additionalClasspathElement>
> Then mu.jars can be whatever like POM property or system property.
> Then you don't need additional plugin, just setup different value in
> whatever POM as you like.
> You may want to find existing plugin, I guess helper-plugin or
> groovy-plugin, to set a value in property in validation phase.
>
> On Tue, Oct 6, 2015 at 6:07 PM, Stian Soiland-Reyes <st...@apache.org>
> wrote:
>
>> So I guess you mean
>>
>> https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html
>>
>> How can I modify the surefire configuration from a different plugin?
>>
>>
>> My aim with this plugin is for someone to be able to make a data
>> archive in a one-go plugin configuration, and then to be able to do
>> src/test/java type junit tests. (but also adding support for
>> additional scripting languages like jRuby and Jython)
>>
>> The Assembly plugin is a bit of a beast for non-Maven experts to deal
>> with, so it doesn't (on its own) achieve this goal. My plugin could
>> try to use it by stealth, of course.
>>
>> Is it possible for one plugin to inject configuration for a second
>> plugin?  I know I can activate a plugin goal from
>> plexus/components.xml, but how can I provide its configuration?
>>
>>
>> Within the tests I want to be able to do say
>> getClass().getResourceAsStream("data/my-artifact/data.csv") to access
>> resources from the ZIP file.
>>
>>
>> Here's an example of using the data-plugin with a unit tests:
>>
>> https://github.com/openphacts/ops-uniprot-linksets/tree/data-plugin
>>
>>
>> I used the additionalClassPathElement, but then I had to do things like:
>>
>> <configuration>
>>   <additionalClasspathElements>
>>
>>  
>> <additionalClasspathElement>${project.build.directory}/${project.artifactId}-${project.version}.data.zip</additionalClasspathElement>
>>   </additionalClasspathElements>
>> </configuration>
>>
>> I would love for my data-maven-plugin to be able to inject this kind of
>> magic.
>>
>> I know it can be put in a super-pom, but different projects that might
>> want to use this data plugins might have different super-poms.
>>
>>
>>
>> On 6 October 2015 at 10:11, Tibor Digana <tibordig...@apache.org> wrote:
>> > test classpath can be extended by extraordinary JAR.
>> > Did you see surefire documentation?
>> > It's described there.
>> >
>> > On Tue, Oct 6, 2015 at 11:06 AM, Stian Soiland-Reyes-2 [via Maven] <
>> > ml-node+s40175n5847294...@n5.nabble.com> wrote:
>> >
>> >> Hi!
>> >>
>> >> I'm developing a Maven plugin for a custom <packaging>
>> >>
>> >> https://github.com/stain/data-maven-plugin
>> >>
>> >> Is it possible for a plugin to add a JAR file to the test classpath?
>> I've
>> >> tried to modify project.getArtifacts() from the INITIALIZATION stage,
>> >> without luck.
>> >>
>> >> Catch: the JAR file is the project artifact, and is made during the
>> >> compile
>> >> stage as I want to test it during the test stage.
>> >>
>> >> (The reason for this is that this plugin supports making ZIP archives of
>> >> data files, which could be large and therefore I want to avoid copying
>> >> them
>> >> to target/classes.)
>> >>
>> >>
>> >> ------------------------------
>> >> If you reply to this email, your message will be added to the discussion
>> >> below:
>> >>
>> >>
>> http://maven.40175.n5.nabble.com/Modifying-test-classpath-from-Maven-plugin-tp5847294.html
>> >> To start a new topic under Maven Developers, email
>> >> ml-node+s40175n142166...@n5.nabble.com
>> >> To unsubscribe from Maven Developers, click here
>> >> <
>> http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=142166&code=dGlib3JkaWdhbmFAYXBhY2hlLm9yZ3wxNDIxNjZ8LTI4OTQ5MjEwMg==
>> >
>> >> .
>> >> NAML
>> >> <
>> http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>> >
>> >>
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://maven.40175.n5.nabble.com/Modifying-test-classpath-from-Maven-plugin-tp5847294p5847296.html
>> > Sent from the Maven Developers mailing list archive at Nabble.com.
>>
>>
>>
>> --
>> Stian Soiland-Reyes
>> Apache Taverna (incubating), Apache Commons RDF (incubating)
>> http://orcid.org/0000-0001-9842-9718
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
>> For additional commands, e-mail: dev-h...@maven.apache.org
>>
>>
>
>
> --
> Cheers
> Tibor



-- 
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718

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

Reply via email to