On 4/6/2010 5:23 PM, Jarek Gawor wrote:
I came up with one solution (committed in revision 931319).
In this solution I created a maven-property-plugin which executes in
the "validate" phase and sets "bootClassPath" system property. The
value of "bootClassPath" property is set to
-Xbootclasspath/p:<path><pathSeparator><path>... string where each
<path> is the jar file to prepend to boot classpath. The
"bootClassPath" property is then used in maven-compiler-plugin and
maven-surefire-plugin and passed as a java/javac argument.
This seems to work for me but I'm wondering if it works for other
people on different OSes and JVMs (especially on Windows and on
non-Sun JVMs).
What's driving the need for doing this? Generally, prepending something
to the bootstrap classpath is considered very bad form. The JVM
supported method for overriding bootstrap classes is the endorsed
directory path. I took another look at what Yoko does to get around
this problem, and it appears the mavan-compiler-plugin and surefire
plugins have all the support you need. Here are some snippets from the
Yoko core subproject. To compile this code, it requires the
yoko-corba-spec classes rather than the JVM provided ones. The build
contains the following build steps:
1) Get the required jars into an endorsed directory: This is done
using the dependency plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.yoko</groupId>
<artifactId>yoko-spec-corba</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
2) Compile the code with a specified endorsed dir. This is handled
using the maven-comiler-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.4</source>
<target>1.4</target>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
3) Run the unit tests with the same endorsed dir:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/org/apache/yoko/*Test.java</include>
</includes>
<systemProperties>
<property>
<name>java.endorsed.dirs</name>
<value>${basedir}/target/endorsed</value>
</property>
</systemProperties>
</configuration>
</plugin>
I knew about steps 1&3, but I just discovered step 2 when I double
checked after seeing your solution. This solution really should be used
rather than overriding the bootClasspath.
Rick
Jarek
On Fri, Apr 2, 2010 at 2:08 PM, Jarek Gawor<[email protected]> wrote:
Hi,
We need to find a way to make the compiler in Maven to load certain
libraries as endorsed libraries. I know this has been discussed before
but do we have some specific solutions for this problem? We will need
to deal with this fairly soon now - for example to implement the
@Resource.lookup support.
Jarek