On Fri, Sep 23, 2011 at 3:51 AM, Gabriel Belingueres
<[email protected]> wrote:
> Hi,
>
> I'm using Maven 3.0.3.
>
> My current project pom.xml file uses a parent pom where is defined the
> maven-compiler-plugin configuration:
>
> <properties>
> <maven.compiler.source>1.6</maven.compiler.source>
> <maven.compiler.target>1.6</maven.compiler.target>
> <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
> <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
>
> <maven.compiler.debuglevel>lines,vars,source</maven.compiler.debuglevel>
> <maven.compiler.verbose>true</maven.compiler.verbose>
> </properties>
>
> <build>
> <pluginManagement>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>2.3.2</version>
> <configuration>
> <compilerArgument>-Xlint:all</compilerArgument>
> </configuration>
> </plugin>
> ...
> </plugins>
> </pluginManagement>
>
> <plugins>
> <!-- all projects inherites the compiler configuration -->
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> </plugin>
> </plugins>
>
>
> If in the actual project pom.xml I do not declare the compiler plugin,
> or if I declare it like this:
>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> </plugin>
> </plugins>
>
> or with the version number:
>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>2.3.2</version>
> </plugin>
> </plugins>
>
> then the .settings/org.eclipse.jdt.core.prefs file is NOT generated.
>
> However, it is generated if I redeclare it fully like this:
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>2.3.2</version>
> <configuration>
> <source>1.6</source>
> <target>1.6</target>
> <compilerArgument>-Xlint:all</compilerArgument>
> <showWarnings>true</showWarnings>
> <showDeprecation>true</showDeprecation>
> <debuglevel>lines,vars,source</debuglevel>
> <verbose>true</verbose>
> </configuration>
> </plugin>
>
> is there a bug with the eclipse plugin? or am I doing something wrong?
The answer is kind of.
There is no standard way (that I'm aware of) for a mojo to ask for the
metadata of another mojo.
That is, the maven-eclipse-plugin can't ask maven-compiler-plugin what
its configuration is.
So what we do is to scan the pom model file that Maven builds up
looking in both the build/plugins and pluginManagement sections for
the maven compiler.
Then look for the specific option of interest (i.e. the "source" property).
What you are doing is setting the source value by indirection.
You are setting the equivalent of -Dmaven.compiler.source on the
command line, which is not showing up in the model representation.
(This may be where the bug is)
I'm not sure what best practice is, but I think using properties to
set values in plugins indirectly is probably not the way to go.
Use the property definitions but then configure the plugin with that property.
You already have a pluginManagement section, so I would specify the
configuration values there:
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.showWarnings>true</maven.compiler.showWarnings>
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
<maven.compiler.debuglevel>lines,vars,source</maven.compiler.debuglevel>
<maven.compiler.verbose>true</maven.compiler.verbose>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerArgument>-Xlint:all</compilerArgument>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
etc...
</configuration>
</plugin>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]