Mercurial > hg > Blog
view content/Maven/default-jdk-for-cross-jdk-profiles.md @ 71:6e8d97e43bd7
Automated merge with ssh://xanthippe//home/dirk/Projekte/Blog
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sat, 02 Jan 2016 03:18:12 +0100 |
parents | 483a5f25ccb6 |
children |
line wrap: on
line source
Title: Default JDK for cross JDK project profiles with Maven Date: 2009-04-25 Lang: en 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`. 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://maven.40175.n5.nabble.com/org-apache-maven-plugins-maven-eclipse-plugin-2-7-SNAPSHOT-ignores-maven-compiler-plugin-td120284.html#a120285) that allows you to configure a sensible, cross platform default for the JDK. 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. So if you put the following into your pom: :::xml <properties> <vmtype>org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType</vmtype> <jdk5Name>J2SE-1.5</jdk5Name> </properties> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.5.1</version> <configuration> <downloadSources>true</downloadSources> <classpathContainers> <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER/${vmtype}/${jdk5Name}</classpathContainer> </classpathContainers> </configuration> </plugin> Eclipse will assign a JDK5 runtime environment to the project (if it has a matching one configured, of course).