You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gabriel Belingueres <be...@gmail.com> on 2011/09/22 20:21:25 UTC

eclipse plugin does not generate org.eclipse.jdt.core.prefs file

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?

Thanks in advance,
Gabriel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: eclipse plugin does not generate org.eclipse.jdt.core.prefs file

Posted by Gabriel Belingueres <be...@gmail.com>.
Hi Barrie!

Finally, I had some time to checkout the eclipse plugin and do some
modifications to make it work.

If the explicit configuration is not found for the compiler
source/target, it searches for the
maven.compiler.source/maven.compiler.target properties. Even if the
properties are not found, if the compiler plugin version is >= 2.3,
then it defaults to "1.5" (as documented in the maven compiler
plugin).

I attached the patch for the IdeUtils.java class.

Regards,
Gabriel

2011/9/23 Barrie Treloar <ba...@gmail.com>:
> On Sat, Sep 24, 2011 at 12:43 AM, Gabriel Belingueres
> <be...@gmail.com> wrote:
>> Thanks Barrie!
>> That modification made the trick.
>>
>> I also don't actually know if configuring the plugin using the command
>> line properties is a best practice.
>> But seeing the source code of the eclipse plugin, I traced it to the
>> IdeUtils.java [1], and it seems that the properties are not tacked
>> into account.
>>
>> [1] http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
>
> Yup.
> I guess we could take the properties into account, we hard code the
> configuration setting already...
> It would mean that we'd need to look up the property settings for each
> plugin/configuration combination to include the property as well.
>
> Your the first person I'm aware of that has noticed this as a problem.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


Re: eclipse plugin does not generate org.eclipse.jdt.core.prefs file

Posted by Barrie Treloar <ba...@gmail.com>.
On Sat, Sep 24, 2011 at 12:43 AM, Gabriel Belingueres
<be...@gmail.com> wrote:
> Thanks Barrie!
> That modification made the trick.
>
> I also don't actually know if configuring the plugin using the command
> line properties is a best practice.
> But seeing the source code of the eclipse plugin, I traced it to the
> IdeUtils.java [1], and it seems that the properties are not tacked
> into account.
>
> [1] http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java

Yup.
I guess we could take the properties into account, we hard code the
configuration setting already...
It would mean that we'd need to look up the property settings for each
plugin/configuration combination to include the property as well.

Your the first person I'm aware of that has noticed this as a problem.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: eclipse plugin does not generate org.eclipse.jdt.core.prefs file

Posted by Gabriel Belingueres <be...@gmail.com>.
Thanks Barrie!
That modification made the trick.

I also don't actually know if configuring the plugin using the command
line properties is a best practice.
But seeing the source code of the eclipse plugin, I traced it to the
IdeUtils.java [1], and it seems that the properties are not tacked
into account.

[1] http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java

2011/9/22 Barrie Treloar <ba...@gmail.com>:
> On Fri, Sep 23, 2011 at 3:51 AM, Gabriel Belingueres
> <be...@gmail.com> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: eclipse plugin does not generate org.eclipse.jdt.core.prefs file

Posted by Barrie Treloar <ba...@gmail.com>.
On Fri, Sep 23, 2011 at 3:51 AM, Gabriel Belingueres
<be...@gmail.com> 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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org