Mercurial > hg > Blog
comparison content/Maven/default-jdk-for-cross-jdk-profiles.md @ 0:4cd9b65e10e4
initial import of the pelican based blog
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 28 Jun 2013 08:48:58 +0200 |
parents | |
children | 483a5f25ccb6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4cd9b65e10e4 |
---|---|
1 Title: Default JDK for cross JDK project profiles with Maven | |
2 Date: 2009-04-25 | |
3 Lang: en | |
4 | |
5 In my [previous blog post about Cross JDK project files with Maven](|filename|./cross-jdk-project-files-continued.md) I described a way to generate a custom JDK name into the Eclipse project files using the `maven-eclipse-plugin`. | |
6 | |
7 That approach still had one shortcoming: you would either have to rename your JDK to match the default configured in the POM or you would have to give the JDK name on the commandline. Now I stumbled over a [good tip on the maven user's list](http://n2.nabble.com/org.apache.maven.plugins%3Amaven-eclipse-plugin%3A2.7-SNAPSHOT-ignores--maven-compiler-plugin-tp2689287p2689425.html) that allows you to configure a sensible, cross platform default for the JDK. | |
8 | |
9 In short, the trick is not to use a concrete name of a JDK but to specify the name of a Java runtime environment. Eclipse automatically tries to match any configured JDK to an internal list of runtime environments. | |
10 | |
11 So if you put the following into your pom: | |
12 | |
13 :::xml | |
14 <properties> | |
15 <vmtype>org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType</vmtype> | |
16 <jdk5Name>J2SE-1.5</jdk5Name> | |
17 </properties> | |
18 ... | |
19 <plugin> | |
20 <groupId>org.apache.maven.plugins</groupId> | |
21 <artifactId>maven-eclipse-plugin</artifactId> | |
22 <version>2.5.1</version> | |
23 <configuration> | |
24 <downloadSources>true</downloadSources> | |
25 <classpathContainers> | |
26 <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER/${vmtype}/${jdk5Name}</classpathContainer> | |
27 </classpathContainers> | |
28 </configuration> | |
29 </plugin> | |
30 | |
31 Eclipse will assign a JDK5 runtime environment to the project (if it has a matching one configured, of course). |