OK, Benjamin & I have been brainstorming:

17:45 <SteveC> what about new JarFile( new File(
System.getProperty("maven.home"), "lib/whatever jars are here" )
).getManifest() and
               look for the implementation version corresponding to the
"Maven Distribution" Implementation Title
17:46 <bentmann> system.getProperty("maven.home"), breaks embedding
17:46 <SteveC> dang
17:47 <SteveC> whatabout @parameter expression="${maven.home}"
17:47 <bentmann> an embedder does not need to have a home
17:47  * SteveC doesn't like depending on Implementation-Title: Maven
Distribution
17:48 <SteveC> and I guess scanning the classpath of MavenProject is out too
17:48 <SteveC> MavenProject.getClass().getResource("/META-INF/MANIFEST.MF");
17:49 <bentmann> hm, that could actually work, maybe not look at the
manifest but the /META-INF/maven/... pom.properties
17:49 <SteveC> yes...
17:50 <bentmann> and loading some resource looks kinda safe
17:50 <bentmann> as long as we use the core loader
17:50 <SteveC> the only issue is if core/plexus decided that because I asked
for maven-project:2.0.6
17:51 <SteveC> as long as core says that for class XYZ (hopefully
MavenProject) I will always get the one from the core classloader
17:51 <bentmann> well, MavenProject belongs to the core API, how is that
ever supposed to be loaded from a different class loader/JAR
                 then the core version?

Thoughts?

2009/10/20 Stephen Connolly <[email protected]>

> What is the recommended way to retrieve the current Maven version from
> within a plugin?
>
> Use case: I want to add a maven version selector to maven-invoker-plugin.
> Thus invoker tests which are for 3.x features only will not even try to run
> on 2.x, and we can keep the same suite of tests.
>
> I was implementing something like this:
>
>     /**
>      * @component
>      * @since 1.5
>      */
>     private RuntimeInformation runtimeInformation;
>
> and then calling runtimeInformation.getApplicationVersion() to get the
> version
>
> However, this requires adding a dependency on maven-core, and it is my
> understanding that this API (RuntimeInformation) is being deprecated/removed
> for 3.x.
>
> So what is the way we should use to determine the Maven version from within
> a plugin?
>
> -Stephen
>
>

Reply via email to