2008/9/12 Brad Cox <[EMAIL PROTECTED]>
> Stuart McCulloch wrote:
>
>> On 11/09/2008, Brad Cox, Ph.D. <[EMAIL PROTECTED]> wrote:
>>
>>> Here's one of the key poms.
>>>
>>
>> I noticed something else in this pom that would cause issues
>> with Eclipse/PDE - the dependencies are embedded inside a
>> "target/dependency" directory inside the bundle.
>>
>> when the bundle is unpacked (<unpackBundle> is enabled)
>> under target/classes, this directory will actually end up as:
>>
>> <project>/target/classes/target/dependency
>>
>> however, Eclipse/PDE expects to see them in this location
>>
>> <project>/target/dependency
>>
>
> Didn't follow you here. Are you describing a mistake I made in
> <Embed-Directory>target/dependency</Embed-Directory>, or a
> bug/incompatibility in the various plugins?
>
I wasn't sure if you were copying the jars to "target/dependency" using
the dependency plugin or if you expected the <unpackBundle> option
to do this - so I wanted to clarify it unpacks under target/classes which
is different to where Eclipse/PDE expects to see the jars
longer description of what's going on, feel free to skip it :)
===================================================
<Embed-Directory>target/dependency</Embed-Directory> will embed
the various dependencies under "target/dependency" inside the bundle,
- for example if you do a "jar tvf" on the bundle you should see:
target/dependency/<artifactId>-<version>.jar
...etc...
and the generated Bundle-ClassPath will also reference this path:
Bundle-ClassPath: ., target/dependency/<artifactId>-<version>.jar,
...etc...
the problem is that when you load this manifest into Eclipse/PDE
it will expect to see the jarfiles mentioned in the bundle classpath
in the filesystem directly under the project root, for example:
<project-root>/target/dependency/<artifactId>-<version>.jar
( where <project-root> is the directory containing the pom.xml )
but unless you've used the maven-dependency-plugin to copy
your dependencies to this directory it won't exist, and therefore
Eclipse/PDE will report several errors about missing jarfiles
you do enable the <unpackBundle> feature of the bundleplugin
but this will unpack the bundle under "target/classes", so you'll
find the unpacked dependencies are actually in:
<project-root>/target/classes/target/dependency/<artifactId>-<version>.jar
which is not where Eclipse/PDE expects them - also when you
ask Eclipse to rebuild the project, it will most likely clear out the
target/classes (because the .classpath generated by the eclipse
plugin marks this as an output folder) so they'll go missing again
===================================================
By Eclipse/PDE, do you mean one of the various "Java Builder" options?
yes - basically Project -> Build Project
> Never really understood those but in flailing about I dragged "Maven
> Incremental Builder" to the top and left it there lately. There's also a
> "Maven Project Builder" in there too (bottom), a "Java Builder", a "Plugin
> Manifiest Builder" and an "Extension Point Schema Builder", in slots 2-4.
> All checked currently.
>
hmm, that mix of builders could be causing some of your problems
- if you're using the maven builders I don't think you need the plugin
or schema builders (as Peter says, often it's simpler to use JDT for
building, rather than try to satisfy all the demands of PDE)
>
> ie. relative to the project - also, because Eclipse can clean
>> the classes directory itself (when doing a rebuild) you might
>> find these dependencies go missing - which would explain
>> why you have issues building in Eclipse but not in Maven
>>
>
> I've been using mvn dependency:copy-dependencies to copy stuff to
> dependencies after cleans, but don't necessarily use them. That just gave me
> other options to try when nothing else would work.
>
ah, right - and they'll be copied to target/dependency under the project
where Eclipse/PDE expects them - you might want to add this to the
build to save you from having to remember to run it after a clean:
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
>
>
> FWIW I have a modified version of the maven-eclipse-plugin
>> that properly handles embedded dependencies by munging
>> the classpath in the Eclipse/PDE manifest - so the jars will
>> be found, and won't be accidentally removed by Eclipse
>>
>> just try using:
>>
>> mvn org.ops4j:maven-pax-plugin:eclipse
>>
>> it will create .project, .classpath and MANIFEST.MF files
>>
>> this plugin is part of the Pax-Construct tools that attempt
>> to remove some of the pain in creating OSGi projects that
>> work in both Maven and Eclipse
>>
>> another approach is to use the maven-dependency-plugin
>> to copy dependencies to the correct path expected by the
>> PDE tooling...
>>
>
> The path its expecting is target/dependencies, right? So
> <Embed-Directory>target/dependency</Embed-Directory> and mvn
> dependency:copy-dependencies should suffice to use maven+eclipse, once I fix
> the other problems? Hope so.
>
yes, that should match things up correctly
--
Cheers, Stuart