Jason Dillon wrote:
How does a test repository help? I still need to configure in my src/it/*/pom.xml the version of the plugin I'm testing.

The latest plugin will be used, which is usually what you're testing.
If the test repository does not contain other versions of the plugin,
the one you're testing will be used.


Maybe I don't understand what you mean by "test repositories".

It's basically -Dmaven.repo.local=/tmp/foo/ - an empty repository
only used for the build.

I just want my src/it/*/pom.xml to *always* use the right version of the plugin (ie. that which was just compiled). I don't want to have to go updating poms each time I make a new release to use the new version.

This has nothing to do with versions, actually. See below.


And even more important... the "install" phase happens *before* the "integration-test" phase, so I still need a way to get the artifacts into the repository before my integration-tests fire.

No, install happens AFTER the integration test phase. Maven is very careful
not to make artifacts available that have failing tests.
If test fails, package won't run.
If integration-test fails (after package), install won't run.

Even if you were able to supply/override that testing version,
the tests will fail since the artifact is not yet in the local repository.
If you run again (and have a previous testing version in the local repo),
the version from the local repo will be tested, not the version in target/.

The problem here is MNG-2677 (originally MNG-870): maven can't resolve plugins
from the reactor.

I wrote the maven-it-plugin a while ago (at the time of writing MNG-870),
which will run an embedded maven on src/it/*/pom.xml (which was later turned
into the embedder). This embedded maven would recognize the just built plugin
from the reactor, and not use the version from the local repository.

So even with proper versions you still have a problem, since install is NOT run
before integration-test, and hence the plugin is NOT available in the local
repository.

If you can explain a better way to achieve the desired result I'm all ears... but so far this is the only solution I can think of which will work 100% of the time.

The proper way would be to explicitly run the tests against target/${artifact},
and not let it poms resolve it from the local or remote repositories.

So, versions for plugins are not needed in src/it/*/pom.xml. And even if you do
specify one, you can't be certain that the version matches the artifact being
built, and even worse, you can't be certain the artifact just built is being 
used.

When MNG-870 was resolved (which later regressed), I succesfully ran integration
tests on the current artifact with the maven-it-plugin, so I think the easiest
and best solution here is to just fix MNG-2677.

-- Kenney

Specifically what I mean is to add an execution of the maven-install-plugin:install w/forceVersion=testing to the "integration-tests" profile in the pre-integration-test phase. So this can be used with `mvn -Dit` to build and run integration tests, kinda like this:

    http://svn.codehaus.org/mojo/trunk/mojo/groovy-maven-plugin/pom.xml

Though ^^^ does not have any install bits. This works, but will fail if you don't `mvn install` first to get something into the local repo... and requires all src/it/*/pom.xml files to have the version of the plugin. I suppose this could be avoided with parent poms etc... but these are supposed to be simple stand-along poms... and adding parents into the mix just complicates things way too much. Much better to simple get know "testing" versions of the artifacts into the local repo _before_ the integration-test phase.

--jason


On Mar 14, 2007, at 5:29 PM, Jason van Zyl wrote:


On 3 Mar 07, at 11:06 PM 3 Mar 07, Jason Dillon wrote:

Any comments on adding a 'forceVersion' param to the maven-install-plugin, which will for all artifacts (including attached) to be installed with the given version?


Why not just use test repositories? You can hack this with a settings but is now easy to do in 2.1 expressly for the purpose of making testing easier. Do you need to force a version if using test repositories was simple?

Jason.

I'm thinking this would be really helpful for testing maven plugins, so that in the pre-integration-test phase, one could use the m-install-p to force all artifacts to be installed with a 'testing' version, then in the 'integration-test' phase run the m-invoker-p to execute a set of maven projects to test/validate the plugin works as expected, and then once that passes, the normal m-install-p execution will install the real versions of the artifacts into the repository.

This would allow the src/it/**/pom.xml files to use <version>testing</version> for all of the plugin artifacts, and would prevent broken artifacts (which don't pass tests) from making it into the local repo cache (and thus available to other projects).

For example:

----8<----
    <build>
        <plugins>
          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <forceVersion>testing</forceVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
<projectsDirectory>${pom.basedir}/src/it</projectsDirectory>
                            <pomIncludes>
<pomInclude>**/pom.xml</pomInclude> <!-- all of these poms use <version>testing</version> -->
                            </pomIncludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
---->8----

I've been digging around trying to figure out how to test my plugins... so far I have not found a single example that just works out of the box... I've gotten the groovy-maven-plugin ( http://svn.codehaus.org/mojo/trunk/mojo/mojo-sandbox/groovy-maven-plugin/ ) to work *almost* as I'd like... the only exception is that right now I have to hard-code the version of the plugin being tested in each src/it/**/pom.xml... which I would really like to avoid.

I've seen a few other plugins use the maven-plugin-management-plugin... but I've no idea what it does... same thing with maven-plug-it-plugin... both look like they might do something along the lines to allow src/it/**/pom.xml to not need hardcoded plugin versions... but I really can't tell.

Anyways... I think simply adding a 'forceVersion' to the maven-install-plugin should solve this... and not introduce more plugins to support/maintain.

--jason

---------------------------------------------------------------------
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]



---------------------------------------------------------------------
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