blob: 04136e71a0fd7de6cb0a2dd9e9dcfb8c2979cc28 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta name="copyright"
content="Copyright (c) IBM Corporation and others 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.">
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1"
type="text/css">
<title>Setting the compilation environment</title>
</head>
<body style="background-color: rgb(255, 255, 255);">
<h1>Setting the Compilation Environment<br>
</h1>
<p>By default, your bundles will be compiled with whichever JRE is
being used to run the build and with source and target levels set to
1.3 and 1.2.<br>
</p>
<p>PDE build is capable of configuring the JRE used during compilation
on a per bundle basis.&nbsp; To take advantage of this, the first thing
to do is to tell PDE build which JREs you have available.&nbsp; In your
build configuration build.properties file, set properties to point to
each of your installed JREs.&nbsp; The template build.properties
provided in org.eclipse.pde.build/templates/headless-build has a list
of environments commented out.&nbsp; Simply uncomment the properties
for which you have JREs and set the value to be the set of jars that
belong on the boot classpath.&nbsp; For example, setting the property:<br>
</p>
<div style="text-align: center;"><tt>J2SE-1.5=C:/Java/1.5/jre/lib/rt.jar;C:/Java/1.5/jre/lib/jsse.jar</tt><br>
</div>
<p style="text-align: left;">will compile bundles requiring java 1.5
against rt.jar and jsse.jar.&nbsp; The names of the properties should
match the names of the environments that PDE Build knows
about.&nbsp;&nbsp;
PDE Build will automatically set the source and target levels for each
environment.&nbsp; The environments that PDE builds knows and their
associated source/target levels are as follows:<br>
</p>
<table
style="width: 60%; height: 54px; text-align: left; margin-left: auto; margin-right: auto;"
border="1" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;">Environment<br>
</td>
<td style="vertical-align: top;">Source<br>
</td>
<td style="vertical-align: top;">Target<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">CDC-1.0/Foundation-1.0<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">CDC-1.1/Foundation-1.1<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.2<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">OSGi/Minimum-1.0<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">OSGi/Minimum-1.1<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.2<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">JRE-1.1<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">J2SE-1.2<br>
</td>
<td style="vertical-align: top;">1.2<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">J2SE-1.3<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">J2SE-1.4<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.2<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">J2SE-1.5<br>
</td>
<td style="vertical-align: top;">1.5<br>
</td>
<td style="vertical-align: top;">1.5<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">JavaSE-1.6<br>
</td>
<td style="vertical-align: top;">1.6<br>
</td>
<td style="vertical-align: top;">1.6<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">PersonalJava-1.1<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">PersonalJava-1.2<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">CDC-1.0/PersonalBasis-1.0<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">CDC-1.0/PersonalJava-1.0<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.1<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">CDC-1.1/PersonalBasis-1.1<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.2<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">CDC-1.1/PersonalJava-1.1<br>
</td>
<td style="vertical-align: top;">1.3<br>
</td>
<td style="vertical-align: top;">1.2<br>
</td>
</tr>
</tbody>
</table>
<h2>Choosing the Environment for your Bundle</h2>
There are two settings that affect the environment used to compile your
bundle.&nbsp; One is the manifest header <span
style="font-weight: bold;">Bundle-RequiredExecutionEnvironment</span>.&nbsp;
This header is a list of environments on which your bundle is able to
run.&nbsp; Your bundle should only use methods that are in the proper
subset of all the environments listed.&nbsp; It is desirable to have
your compilation environment match your runtime environment as closely
as possible.<br>
<br>
The second setting is the property <span style="font-weight: bold;">jre.compilation.profile</span>
from your bundle's build.properties file.&nbsp; The value of this
property should be the prefered environment for compiling this bundle
if the Bundle-RequiredExecutionEnvironment list is not adequate.<br>
<br>
These two settings together form a list of environments,
jre.compilation.profile first, then the environments from
Bundle-RequiredExecutionEnvironment.&nbsp; The first
environment on this list that is available in your build configuration
(see above section) will be used to compile your bundle.<br>
<br>
Example:<br>
<pre style="margin-left: 40px;">&lt;buildDirectory&gt;/plugins/bundleA/<br> META-INF/manifest.mf: Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0, J2SE-1.3<br> build.properties:&nbsp; jre.compilation.profile=J2SE-1.4<br><br><span
style="font-weight: bold;"></span>&lt;buildConfiguration&gt;/<br> build.properties:&nbsp; J2SE-1.3=C:/Java1.3/jre/lib/rt.jar;C:/Java1.3/jre/lib/i18n.jar<br> J2SE-1.4=C:/Java1.4/jre/lib/rt.jar;C:/Java1.4/jre/lib/jsse.jar<br></pre>
<p style="margin-left: 40px;">In the above setup, the list of
environments considered (in order) is: J2SE-1.4,&nbsp;
CDC-1.0/Foundation-1.0, J2SE-1.3.&nbsp; The bundle can run on
CDC/Foundation and J2SE-1.3, but for some reason,&nbsp; it should be
compiled with J2SE-1.4.&nbsp; In this case, J2SE-1.4 is set in the
build configuration, and comes first in the list of environments, so it
is used to compile the bundle.&nbsp; The source and target levels used
in this case are 1.3 and 1.2.&nbsp; If instead, the build configuration
defined only J2SE-1.3 and not J2SE-1.4, then J2SE-1.3 would be the only
environment on the list for which a JRE is available, so it would be
used to compile the bundle.&nbsp; In that case, the source and target
levels would be 1.3 and 1.1.<br>
</p>
<h2>Explicitly Setting Compilation values</h2>
If, for some reason, using the enviroments as outlined above does not
result in the desired setup, then it is possible for a bundle to
explicitly list the settings it requires.&nbsp; For example, if you
have a bundle that uses J2SE-1.4 with asserts, then the source and
target levels would need to be 1.4, instead of the default 1.3 and 1.2.<br>
<br>
To explicitly set the java source and target levels, the bundle should
set the properties <tt style="font-weight: bold;">javacSource</tt> and
<tt style="font-weight: bold;">javacTarget</tt> in it's
build.properties
file.&nbsp; These properties will override the values derived from the
environment settings.<br>
<br>
Similarily, setting the property <tt>bootClasspath</tt> in the
bundle's build.properties file will override the set of
jars the bundle is compiled against.<br>
<br>
</body>
</html>