Grrr argh! Ok, hmm I'll have a closer look at your code as you did not seem to be parsing the XML from my initial reading of the code
On Wed, Sep 3, 2008 at 3:15 PM, Brian E. Fox <[EMAIL PROTECTED]>wrote: > You can't, this is why in the enforcer rule, I have to walk and > interpolate the entire tree. If I could get the model from maven > unmolested, I could cut out 99% of that code. > > -----Original Message----- > From: Stephen Connolly [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 03, 2008 6:31 AM > To: Maven Developers List > Subject: Question: How to get the original model before the super-pom's > pluginManagement is injected? > > If I have the floowing pom.xml: > > <project> > <modelVersion>4.0.0</modelVersion> > > <groupId>org.codehaus.mojo.versions-maven-plugin.it</groupId> > <artifactId>parent</artifactId> > <version>2.0</version> > <packaging>pom</packaging> > > <build> > <pluginManagement> > <plugins> > <plugin> > <artifactId>maven-checkstyle-plugin</artifactId> > <version>2.1</version> > </plugin> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-javadoc-plugin</artifactId> > </plugin> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-compiler-plugin</artifactId> > <configuration> > <source>1.4</source> > <target>1.4</target> > </configuration> > </plugin> > <plugin> > <groupId>org.codehaus.mojo</groupId> > <artifactId>build-helper-maven-plugin</artifactId> > </plugin> > </plugins> > </pluginManagement> > <plugins> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-clean-plugin</artifactId> > <version>2.1</version> > </plugin> > </plugins> > </build> > </project> > > How do I detect in a mojo that the pluginManagement section has a entry > for > maven-compiler-plugin that *does not have the version specified*... > > If I look at mavenProject.getPluginManagement().getPlugins() I'll see > maven-compiler-plugin but with version set to 2.0.2 (from the super pom) > > If I look at > mavenProject.getModel().getBuild().getPluginManagement().getPlugins(), > same > thing (*But this should be ok as it's the interpolated model anyway*) > > If I look at > mavenProject.getOriginalModel().getBuild().getPluginManagement().getPlug > ins(), > same thing *isn't this supposed to be the original model... before > interpolation* > > Just to check I'm not going mad I logged the output of > mavenProject.writeOriginalModel which gives: > > <?xml version="1.0" encoding="UTF-8"?><project> > <modelVersion>4.0.0</modelVersion> > <groupId>org.codehaus.mojo.versions-maven-plugin.it</groupId> > <artifactId>parent</artifactId> > <packaging>pom</packaging> > <version>2.0</version> > <build> > <pluginManagement> > <plugins> > <plugin> > <artifactId>maven-antrun-plugin</artifactId> > <version>1.1</version> > </plugin> > <plugin> > <artifactId>maven-assembly-plugin</artifactId> > <version>2.2-beta-2</version> > </plugin> > <plugin> > <artifactId>maven-clean-plugin</artifactId> > <version>2.2</version> > </plugin> > <plugin> > <artifactId>maven-compiler-plugin</artifactId> > <version>2.0.2</version> > <configuration> > <source>1.4</source> > <target>1.4</target> > </configuration> > </plugin> > <plugin> > <artifactId>maven-dependency-plugin</artifactId> > <version>2.0</version> > </plugin> > <plugin> > <artifactId>maven-deploy-plugin</artifactId> > <version>2.3</version> > </plugin> > <plugin> > <artifactId>maven-ear-plugin</artifactId> > <version>2.3.1</version> > </plugin> > <plugin> > <artifactId>maven-ejb-plugin</artifactId> > <version>2.1</version> > </plugin> > <plugin> > <artifactId>maven-install-plugin</artifactId> > <version>2.2</version> > </plugin> > <plugin> > <artifactId>maven-jar-plugin</artifactId> > <version>2.2</version> > </plugin> > <plugin> > <artifactId>maven-checkstyle-plugin</artifactId> > <version>2.1</version> > </plugin> > <plugin> > <artifactId>maven-javadoc-plugin</artifactId> > <version>2.4</version> > </plugin> > <plugin> > <artifactId>maven-plugin-plugin</artifactId> > <version>2.4.1</version> > </plugin> > <plugin> > <artifactId>maven-rar-plugin</artifactId> > <version>2.2</version> > </plugin> > <plugin> > <artifactId>maven-release-plugin</artifactId> > <version>2.0-beta-7</version> > </plugin> > <plugin> > <artifactId>maven-resources-plugin</artifactId> > <version>2.2</version> > </plugin> > <plugin> > <artifactId>maven-site-plugin</artifactId> > <version>2.0-beta-6</version> > </plugin> > <plugin> > <artifactId>maven-source-plugin</artifactId> > <version>2.0.4</version> > </plugin> > <plugin> > <artifactId>maven-surefire-plugin</artifactId> > <version>2.4.2</version> > </plugin> > <plugin> > <artifactId>maven-war-plugin</artifactId> > <version>2.1-alpha-1</version> > </plugin> > <plugin> > <groupId>org.codehaus.mojo</groupId> > <artifactId>build-helper-maven-plugin</artifactId> > </plugin> > </plugins> > </pluginManagement> > <plugins> > <plugin> > <artifactId>maven-clean-plugin</artifactId> > <version>2.1</version> > </plugin> > </plugins> > </build> > </project> > > *oh look the super pom has been injected in before I can see it* > > I have not checked, but I suspect that maven-enforcer-plugin will have > the > same issue with Maven 2.0.9+ (given that I've pilfered a lot of the > logic > for missing versions from there) > > I really don't want to have to write my own ModelXpp3Reader, or have to > bury > in plugin code logic to find the pom.xml and read it in directly... > > So... any thoughts? > > -Stephen > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >