This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 104974 - Maven2 projects can't specify Java Platform
Summary: Maven2 projects can't specify Java Platform
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: David Simonek
URL:
Keywords:
: 117097 148916 149615 154490 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-28 17:09 UTC by henriklynggaard
Modified: 2009-02-19 22:42 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description henriklynggaard 2007-05-28 17:09:31 UTC
In a standard Netbeans project I can choose which Java version to use, by
selecting one of the installed "Java Platform"'s

In a maven2 based project I do not have this option and maven is allways
executed by the java version used to start the IDE. 

This causes problems for some of the tasks I am using. These does some form of
code generation/compilation, but fails because the standard libraries (e.g.
rt.jar) is not the version they expect.
Comment 1 Milos Kleint 2007-05-30 08:04:30 UTC
maven itself will always be executed by the IDE's JVM because it's embedded and
executed within the same JVM. Having external execution of maven is a possible
workaround, however that one has it's own set of problems (like poorer parsing
of output etc). It could be implemented in the future, but not in the immediate
plans for 6.0.

Selecting a JDK to use with a project shall always just influence the
configuration of various plugins used by the build. Eg. compiler, surefire,
pmd... There is currently no support in maven to have a different JDK used for
plugins in a unified manner. A maven 2.1 feature called "toolchains" shall
address that issue. Then  the IDE integration will plug into that system. Until
then there are no plans to solve the issue on netbeans side only. Consider
tweaking the affected plugin's configuration (if possible).

Comment 2 Milos Kleint 2007-06-27 07:57:15 UTC
this maven 2.1 feature is closely related http://jira.codehaus.org/browse/MNG-468
Comment 3 Milos Kleint 2007-10-02 09:35:56 UTC
as a workaround for 6.0 I introduced this mechanism:

the IDE will look for the "netbeans.hint.jdkPlatform" property in the resolved POM. The value contains the name of the
java platform to use with the project(s). The format is the same as the "platform.active" property in Ant-based
projects. (Easiest way to figure out the name is to create a sample j2se project, change it's platform and look for the
property in nbproject/project.properties file)
If the property is found and matches existing java platform, that one is used, if not the default platform is used as
fallback.


The proeprty can be in the project's pom.xml, any of the parent poms or also in the profiles.xml file within profile
named "netbeans-private". The last option has the advantage of not polluting your version control shareable pom.xml with
private IDE content.

works in 6.0 beta2 or the daily builds starting with number #194
http://deadlock.netbeans.org/hudson/job/mevenide
Comment 4 Milos Kleint 2007-10-02 09:37:27 UTC
*** Issue 117097 has been marked as a duplicate of this issue. ***
Comment 5 wbabachan 2007-10-02 15:48:40 UTC
Thanks a lot, the workaround is working fine.
Comment 6 athompson 2007-10-04 15:52:27 UTC
works ok here as well for the editor, although i still have to compile with external Maven.
Comment 7 athompson 2007-10-04 16:08:23 UTC
why not use the existing 'project.build.plugins.configuration.target' as the hint and match it to the first platform
that meets the target exactly, or fall back to the default?  that way, people would only need to specify the
'netbeans.hint.jdkPlatform' hint to disambiguate between multiple JDKs with the same target level, which is probably
relatively rare.
Comment 8 Milos Kleint 2007-10-05 07:45:38 UTC
people who use the hint are aware of the fact that they are using a given jdk in the IDE. The automated setting based on
target/source can cause "magic" behaviour when something seems to work in the IDE's editor, but doesn't compile and vice
versa without any visual clues about what is happening
Comment 9 athompson 2007-10-05 14:23:39 UTC
oh, that makes sense.
Comment 10 Milos Kleint 2008-08-13 18:38:02 UTC
the netbeans.hint.jdkPlatform property is now used to set the JAVA_HOME environment property when building with external
command line maven. That should ensure the right jdk is used for compilation. The command line builds are now the
default and the embedded builds are only a fallback for cases when no maven home is set in Tools/Options or no maven
executable is on PATH.
Comment 11 Milos Kleint 2008-08-13 18:39:20 UTC
However the said procedure might not work on MacOSX, see http://jira.codehaus.org/browse/MNG-3707
Comment 12 Milos Kleint 2008-10-02 11:29:14 UTC
*** Issue 148916 has been marked as a duplicate of this issue. ***
Comment 13 Milos Kleint 2008-10-09 13:59:19 UTC
*** Issue 149615 has been marked as a duplicate of this issue. ***
Comment 14 tomzi 2008-10-09 16:07:31 UTC
I think there should be selector for the JRE used for maven in the global options and in the project's option.
Comment 15 Milos Kleint 2008-11-18 09:46:10 UTC
ui to be implemented for the current jdk approach in 7.0.
any alternate setups (eg. maven toolchains - MNG-468) might get in once mainstream.
Comment 16 Milos Kleint 2008-11-19 13:47:46 UTC
replanning to 7.0 M2
Comment 17 Milos Kleint 2008-12-03 18:43:01 UTC
*** Issue 154490 has been marked as a duplicate of this issue. ***
Comment 18 David Simonek 2008-12-19 17:20:01 UTC
Working on it...
Comment 19 David Simonek 2009-01-06 09:38:04 UTC
UI for specifying Java platform is done hopefully. In Project properties of Maven projects, in Compile section, there is
new UI similar to Ant projects. Additionally, user is warned if external Maven is not set.

Comment 20 athompson 2009-01-06 15:45:13 UTC
w00t!
Comment 21 Quality Engineering 2009-01-07 05:38:07 UTC
Integrated into 'main-golden', will be available in build *200901070201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/532dd5325ee1
User: Dafe Simonek <dsimonek@netbeans.org>
Log: #104974: Initial implementation of Java Platform selection from UI