Discussion:
[tycho-user] Build plugin and source-plugin from pre-built jar's and source folder
Andreas Pakulat
2017-08-09 14:51:41 UTC
Permalink
Hi,

I'm including a thirdparty jar file in my Eclipse plugin. Currently I'm doing
this by simply copying the jar into the plugin and adding it as a Runtime
class path entry in the plugin meta information. This works fine, but the jar
lacks source code, so stepping into that code is not possible. I do have the
source code though and I can manually connect the jar with the local
directory on disk. This however stores a local path in the plugin project
which is not really a good idea on a shared project. The alternative of using
a workspace path would work, but require that I also place the source code
into the plugin and version control it which I find a little ugly.

I thought I could leverage the Eclipse source bundle support to let Tycho
build an eclipse plugin carrying the jar's and generate a source bundle that
carries the source code and allows Eclipse to make the connection between
class file and source 'automatically'.

Essentially I had an eclipse plugin which referrenced the jar files via
bin.includes and the source directories via src.includes. Then used
tycho-source-plugin to get a source plugin built out of that and assembled a
feature and p2 repository carrying both. However this did not work out,
Eclipse was not able to figure out the correct place of the sources.

Looking at the generated source plugin and some reading led me to believe
that the EclipseSourceBundle entry would require some different values for
the root=. part. This in turn let me find this old thread
https://dev.eclipse.org/mhonarc/lists/tycho-user/msg01991.html which suggests
this is not possible at the moment.

Is that still correct or am I overlooking something?

Andreas
--
Andreas Pakulat ***@froglogic.com
froglogic GmbH - Automated UI and Web Testing
Henrik Steudel
2017-08-10 08:54:42 UTC
Permalink
Hi,

this is a working approach for us:

We assume that source archives are packaged as either zip or jar in a
folder "lib-src" (${lib.src.folder}) located beneath the bundle root.
If such a folder exists, a profile gets activated:

* The source archives are unzipped into a surrogate "srcroot"
(${src.root.folder}) folder by an ANT script.
* The standard source bundle plugin settings are extended to include
this surrogate folder as additional sources.

Then you will get a ordinary source bundle which looks and feels just
like your own source bundles.

Hints: You need to make sure that the source archive contains the
sources at the archive's root level, i.e. the package folders need to
start at root. I had to manually change some archives to adhere to this
structure.
Also, the below definition excludes archives with an "all" part which
are often containing a lot of non-source-related files.

Hope this helps.
Kind regards
Henrik


Maven Parent POM:

<properties>
<!--folder name to extract ext sources from -->
<lib.src.folder>lib-src</lib.src.folder>
<src.root.folder>srcroot</src.root.folder>
</properties>


<profile>
<id>unzip-src</id>
<activation>
<file>
<exists>${lib.src.folder}</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<failOnError>true</failOnError>
<target>
<echo message="Preparing source
bundle creation for plugin." />
<unzip
dest="${basedir}/${src.root.folder}" overwrite="false">
<fileset
dir="${basedir}/${lib.src.folder}">
<include name="**/*.jar" />
<include name="**/*.zip" />
<exclude
name="**/*javadoc*" />
<!--a 'all' part in
archive name indicates that this archive contains more than sources,
e.g. testdata, compiled binaries. -->
<exclude name="**/*all*" />
</fileset>
</unzip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<additionalFileSets>
<fileSet>
<directory>${project.basedir}/${src.root.folder}/</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</additionalFileSets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Post by Andreas Pakulat
Hi,
I'm including a thirdparty jar file in my Eclipse plugin. Currently
I'm doing this by simply copying the jar into the plugin and adding it
as a Runtime class path entry in the plugin meta information. This
works fine, but the jar lacks source code, so stepping into that code
is not possible. I do have the source code though and I can manually
connect the jar with the local directory on disk. This however stores
a local path in the plugin project which is not really a good idea on
a shared project. The alternative of using a workspace path would
work, but require that I also place the source code into the plugin
and version control it which I find a little ugly.
I thought I could leverage the Eclipse source bundle support to let
Tycho build an eclipse plugin carrying the jar's and generate a source
bundle that carries the source code and allows Eclipse to make the
connection between class file and source 'automatically'.
Essentially I had an eclipse plugin which referrenced the jar files
via bin.includes and the source directories via src.includes. Then
used tycho-source-plugin to get a source plugin built out of that and
assembled a feature and p2 repository carrying both. However this did
not work out, Eclipse was not able to figure out the correct place of
the sources.
Looking at the generated source plugin and some reading led me to
believe that the EclipseSourceBundle entry would require some
different values for the root=. part. This in turn let me find this
old thread
https://dev.eclipse.org/mhonarc/lists/tycho-user/msg01991.html which
suggests this is not possible at the moment.
Is that still correct or am I overlooking something?
Andreas
--
Entimo AG
Stralauer Platz 33 - 34 | 10243 Berlin | Germany
Tel: +49.30.52 00 24 133 | Fax: +49.30.52 00 24 101
***@entimo.com | http://www.entimo.com/

Vorstand: JÃŒrgen Spieler (Vors.), Marianne Neumann
Aufsichtratsvorsitzender: Erika Tannenbaum

Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB Berlin-Charlottenburg 85073
Andreas Pakulat
2017-08-10 10:05:35 UTC
Permalink
Hi,

thanks for that idea. I did not see a particular reason to keep the sources
packed, so I simply went with unpacked sources in a srcroot folder in the
plugin project that also carries the (packed) jar. Unfortunately the
resulting source bundle is not being used by Eclipse when using these bundles
as part of the target platform.

I'm attaching a small sample project showing what I've tried. It carries a
plugin with the jar file and a srcroot folder thats being added to the source
bundle (I stripped the sources down to reduce the size). In addition a
feature and p2 repository are created so the plugins can be used in a target
platform definition. I've added that repository into my target platform and
as a dependency of a plugin. I can now use code like

import org.restlet.resource.ClientResource;
ClientResource resource = new ClientResource( URI.create("") );

but I cannot jump to the code of the ClientResource class in Eclipse.

Anybody can spot where I'm misunderstanding how this should work?

Andreas
Hi,
We assume that source archives are packaged as either zip or jar in a folder
"lib-src" (${lib.src.folder}) located beneath the bundle root.
* The source archives are unzipped into a surrogate "srcroot"
(${src.root.folder}) folder by an ANT script.
* The standard source bundle plugin settings are extended to include this
surrogate folder as additional sources.
Then you will get a ordinary source bundle which looks and feels just like
your own source bundles.
Hints: You need to make sure that the source archive contains the sources at
the archive's root level, i.e. the package folders need to start
at root. I had to manually change some archives to adhere to this structure.
Also, the below definition excludes archives with an "all" part which are
often containing a lot of non-source-related files.
Hope this helps.
Kind regards
Henrik
<properties>
<!--folder name to extract ext sources from -->
<lib.src.folder>lib-src</lib.src.folder>
<src.root.folder>srcroot</src.root.folder>
</properties>
<profile>
<id>unzip-src</id>
<activation>
<file>
<exists>${lib.src.folder}</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<failOnError>true</failOnError>
<target>
<echo message="Preparing source
bundle creation for plugin." />
<unzip
dest="${basedir}/${src.root.folder}" overwrite="false">
<fileset
dir="${basedir}/${lib.src.folder}">
<include name="**/*.jar" />
<include name="**/*.zip" />
<exclude name="**/*javadoc*"
/>
<!--a 'all' part in archive
name indicates that this archive contains more than sources, e.g.
testdata, compiled binaries. -->
<exclude name="**/*all*" />
</fileset>
</unzip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<additionalFileSets>
<fileSet>
<directory>${project.basedir}/${src.root.folder}/</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</additionalFileSets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Post by Andreas Pakulat
Hi,
I'm including a thirdparty jar file in my Eclipse plugin. Currently I'm
doing this by simply copying the jar into the plugin and adding it
as a Runtime class path entry in the plugin meta information. This works
fine, but the jar lacks source code, so stepping into that code is
not possible. I do have the source code though and I can manually connect
the jar with the local directory on disk. This however stores a
local path in the plugin project which is not really a good idea on a
shared project. The alternative of using a workspace path would work,
but require that I also place the source code into the plugin and version
control it which I find a little ugly.
I thought I could leverage the Eclipse source bundle support to let Tycho
build an eclipse plugin carrying the jar's and generate a source
bundle that carries the source code and allows Eclipse to make the
connection between class file and source 'automatically'.
Essentially I had an eclipse plugin which referrenced the jar files via
bin.includes and the source directories via src.includes. Then used
tycho-source-plugin to get a source plugin built out of that and assembled
a feature and p2 repository carrying both. However this did not
work out, Eclipse was not able to figure out the correct place of the
sources.
Looking at the generated source plugin and some reading led me to believe
that the EclipseSourceBundle entry would require some different
values for the root=. part. This in turn let me find this old thread
https://dev.eclipse.org/mhonarc/lists/tycho-user/msg01991.html which
suggests this is not possible at the moment.
Is that still correct or am I overlooking something?
Andreas
--
Entimo AG
Stralauer Platz 33 - 34 | 10243 Berlin | Germany
Tel: +49.30.52 00 24 133 | Fax: +49.30.52 00 24 101
Vorstand: JÃŒrgen Spieler (Vors.), Marianne Neumann
Aufsichtratsvorsitzender: Erika Tannenbaum
Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB
Berlin-Charlottenburg 85073
--
Andreas Pakulat ***@froglogic.com
froglogic GmbH - Automated UI and Web Testing
Andreas Pakulat
2017-08-10 10:50:37 UTC
Permalink
Hi,

just after sending that mail I realized I did not yet try to unpack the jar
file into my plugin.
It turns out that does work - but really only when putting the
packages/classes at the root of the plugin. It does not work to keep things
in a subfolder and use the Bundle-ClassPath option in the manifest - the
resulting plugin will not expose the classes it appears (dependent plugins
show compile errors for those classes loaded from the
third-party-library-plugin).

Thats going to get a bit messy when wanting to update the thirdparty jars or
even just when a given thirdparty dependency consists of multiple jars.

Andreas
Post by Andreas Pakulat
Hi,
thanks for that idea. I did not see a particular reason to keep the sources
packed, so I simply went with unpacked sources in a srcroot folder
in the plugin project that also carries the (packed) jar. Unfortunately the
resulting source bundle is not being used by Eclipse when using
these bundles as part of the target platform.
I'm attaching a small sample project showing what I've tried. It carries a
plugin with the jar file and a srcroot folder thats being added to
the source bundle (I stripped the sources down to reduce the size). In
addition a feature and p2 repository are created so the plugins can be
used in a target platform definition. I've added that repository into my
target platform and as a dependency of a plugin. I can now use code
like
import org.restlet.resource.ClientResource;
ClientResource resource = new ClientResource( URI.create("") );
but I cannot jump to the code of the ClientResource class in Eclipse.
Anybody can spot where I'm misunderstanding how this should work?
Andreas
Post by Henrik Steudel
Hi,
We assume that source archives are packaged as either zip or jar in a
folder "lib-src" (${lib.src.folder}) located beneath the bundle root.
* The source archives are unzipped into a surrogate "srcroot"
(${src.root.folder}) folder by an ANT script.
* The standard source bundle plugin settings are extended to include
this surrogate folder as additional sources.
Then you will get a ordinary source bundle which looks and feels just like
your own source bundles.
Hints: You need to make sure that the source archive contains the sources
at the archive's root level, i.e. the package folders need to start
at root. I had to manually change some archives to adhere to this structure.
Also, the below definition excludes archives with an "all" part which are
often containing a lot of non-source-related files.
Hope this helps.
Kind regards
Henrik
<properties>
<!--folder name to extract ext sources from -->
<lib.src.folder>lib-src</lib.src.folder>
<src.root.folder>srcroot</src.root.folder>
</properties>
<profile>
<id>unzip-src</id>
<activation>
<file>
<exists>${lib.src.folder}</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<failOnError>true</failOnError>
<target>
<echo message="Preparing source
bundle creation for plugin." />
<unzip
dest="${basedir}/${src.root.folder}" overwrite="false">
<fileset
dir="${basedir}/${lib.src.folder}">
<include name="**/*.jar" />
<include name="**/*.zip" />
<exclude
name="**/*javadoc*" />
<!--a 'all' part in archive
name indicates that this archive contains more than sources, e.g.
testdata, compiled binaries. -->
<exclude name="**/*all*" />
</fileset>
</unzip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<additionalFileSets>
<fileSet>
<directory>${project.basedir}/${src.root.folder}/</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</additionalFileSets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Post by Andreas Pakulat
Hi,
I'm including a thirdparty jar file in my Eclipse plugin. Currently I'm
doing this by simply copying the jar into the plugin and adding it
as a Runtime class path entry in the plugin meta information. This works
fine, but the jar lacks source code, so stepping into that code is
not possible. I do have the source code though and I can manually connect
the jar with the local directory on disk. This however stores a
local path in the plugin project which is not really a good idea on a
shared project. The alternative of using a workspace path would work,
but require that I also place the source code into the plugin and version
control it which I find a little ugly.
I thought I could leverage the Eclipse source bundle support to let Tycho
build an eclipse plugin carrying the jar's and generate a source
bundle that carries the source code and allows Eclipse to make the
connection between class file and source 'automatically'.
Essentially I had an eclipse plugin which referrenced the jar files via
bin.includes and the source directories via src.includes. Then used
tycho-source-plugin to get a source plugin built out of that and assembled
a feature and p2 repository carrying both. However this did not
work out, Eclipse was not able to figure out the correct place of the
sources.
Looking at the generated source plugin and some reading led me to believe
that the EclipseSourceBundle entry would require some different
values for the root=. part. This in turn let me find this old thread
https://dev.eclipse.org/mhonarc/lists/tycho-user/msg01991.html which
suggests this is not possible at the moment.
Is that still correct or am I overlooking something?
Andreas
--
Entimo AG
Stralauer Platz 33 - 34 | 10243 Berlin | Germany
Tel: +49.30.52 00 24 133 | Fax: +49.30.52 00 24 101
Vorstand: Jürgen Spieler (Vors.), Marianne Neumann
Aufsichtratsvorsitzender: Erika Tannenbaum
Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB
Berlin-Charlottenburg 85073
_______________________________________________
tycho-user mailing list
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-user
--
Andreas Pakulat ***@froglogic.com
froglogic GmbH - Automated UI and Web Testing
DELHELLE Anthony
2017-08-23 12:00:25 UTC
Permalink
Hi,

I think I did what you want in my project using the Eclipse-SourceBundle
instruction in the manifest of the source plugin.

I bundled my jar in a plugin org.pluginId, declaring 2 jar (jar1.jar et
jar2.jar) in Bundle-ClassPath of Manifest and exposing it using
Export-Package. I also used the Eclipse-BundleShape: dir instruction (don't
know if it was necessary).
I bundled the sources in another plugin and I used the Eclipse-SourceBundle:
org.pluginId;version="1.0.0";roots:=" jar1, jar2". I also used the
Eclipse-BundleShape: dir instruction (don't know if it was necessary).
I bundled all in a feature and update site which works perfectly.

Anthony


-----Message d'origine-----
De : tycho-user-***@eclipse.org [mailto:tycho-user-***@eclipse.org]
De la part de Andreas Pakulat
Envoyé : jeudi 10 août 2017 12:51
À : Tycho user list
Objet : Re: [tycho-user] Build plugin and source-plugin from pre-built jar's
and source folder

Hi,

just after sending that mail I realized I did not yet try to unpack the jar
file into my plugin.
It turns out that does work - but really only when putting the
packages/classes at the root of the plugin. It does not work to keep things
in a subfolder and use the Bundle-ClassPath option in the manifest - the
resulting plugin will not expose the classes it appears (dependent plugins
show compile errors for those classes loaded from the
third-party-library-plugin).

Thats going to get a bit messy when wanting to update the thirdparty jars or
even just when a given thirdparty dependency consists of multiple jars.

Andreas
Post by Andreas Pakulat
Hi,
thanks for that idea. I did not see a particular reason to keep the
sources packed, so I simply went with unpacked sources in a srcroot
folder in the plugin project that also carries the (packed) jar.
Unfortunately the resulting source bundle is not being used by Eclipse
when using these bundles as part of the target platform.
I'm attaching a small sample project showing what I've tried. It
carries a plugin with the jar file and a srcroot folder thats being
added to the source bundle (I stripped the sources down to reduce the
size). In addition a feature and p2 repository are created so the
plugins can be used in a target platform definition. I've added that
repository into my target platform and as a dependency of a plugin. I
can now use code like
import org.restlet.resource.ClientResource;
ClientResource resource = new ClientResource( URI.create("") );
but I cannot jump to the code of the ClientResource class in Eclipse.
Anybody can spot where I'm misunderstanding how this should work?
Andreas
Post by Henrik Steudel
Hi,
We assume that source archives are packaged as either zip or jar in a
folder "lib-src" (${lib.src.folder}) located beneath the bundle root.
* The source archives are unzipped into a surrogate "srcroot"
(${src.root.folder}) folder by an ANT script.
* The standard source bundle plugin settings are extended to
include this surrogate folder as additional sources.
Then you will get a ordinary source bundle which looks and feels
just like your own source bundles.
Hints: You need to make sure that the source archive contains the
sources at the archive's root level, i.e. the package folders need to
start at root. I had to manually change some archives to adhere to
this structure.
Also, the below definition excludes archives with an "all" part which
are often containing a lot of non-source-related files.
Hope this helps.
Kind regards
Henrik
<properties>
<!--folder name to extract ext sources from -->
<lib.src.folder>lib-src</lib.src.folder>
<src.root.folder>srcroot</src.root.folder>
</properties>
<profile>
<id>unzip-src</id>
<activation>
<file>
<exists>${lib.src.folder}</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<failOnError>true</failOnError>
<target>
<echo message="Preparing
source bundle creation for plugin." />
<unzip
dest="${basedir}/${src.root.folder}" overwrite="false">
<fileset
dir="${basedir}/${lib.src.folder}">
<include name="**/*.jar" />
<include name="**/*.zip" />
<exclude
name="**/*javadoc*" />
<!--a 'all' part in
archive name indicates that this archive contains more than sources,
e.g.
testdata, compiled binaries. -->
<exclude name="**/*all*" />
</fileset>
</unzip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<additionalFileSets>
<fileSet>
<directory>${project.basedir}/${src.root.folder}/</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</additionalFileSets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Post by Andreas Pakulat
Hi,
I'm including a thirdparty jar file in my Eclipse plugin. Currently
I'm doing this by simply copying the jar into the plugin and adding
it as a Runtime class path entry in the plugin meta information.
This works fine, but the jar lacks source code, so stepping into
that code is not possible. I do have the source code though and I
can manually connect the jar with the local directory on disk. This
however stores a local path in the plugin project which is not
really a good idea on a shared project. The alternative of using a
workspace path would work, but require that I also place the source
code into the plugin and version control it which I find a little ugly.
I thought I could leverage the Eclipse source bundle support to let
Tycho build an eclipse plugin carrying the jar's and generate a
source bundle that carries the source code and allows Eclipse to
make the connection between class file and source 'automatically'.
Essentially I had an eclipse plugin which referrenced the jar files
via bin.includes and the source directories via src.includes. Then
used tycho-source-plugin to get a source plugin built out of that
and assembled a feature and p2 repository carrying both. However
this did not work out, Eclipse was not able to figure out the
correct place of the sources.
Looking at the generated source plugin and some reading led me to
believe that the EclipseSourceBundle entry would require some
different values for the root=. part. This in turn let me find this
old thread
https://dev.eclipse.org/mhonarc/lists/tycho-user/msg01991.html which
suggests this is not possible at the moment.
Is that still correct or am I overlooking something?
Andreas
--
Entimo AG
Stralauer Platz 33 - 34 | 10243 Berlin | Germany
http://www.entimo.com/
Vorstand: Jürgen Spieler (Vors.), Marianne Neumann
Aufsichtratsvorsitzender: Erika Tannenbaum
Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB
Berlin-Charlottenburg 85073
_______________________________________________
tycho-user mailing list
To change your delivery options, retrieve your password, or
unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-user
--
Andreas Pakulat ***@froglogic.com
froglogic GmbH - Automated UI and Web Testing
_______________________________________________
tycho-user mailing list
tycho-***@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit https://dev.eclipse.org/mailman/listinfo/tycho-user
--
232 avenue Napoleon BONAPARTE 92500 RUEIL MALMAISON
Capital EUR 219 300,00 - RCS Nanterre B 408 832 301 - TVA FR 09 408 832 301
Andreas Pakulat
2017-09-07 18:46:50 UTC
Permalink
Post by DELHELLE Anthony
Hi,
I think I did what you want in my project using the Eclipse-SourceBundle
instruction in the manifest of the source plugin.
I bundled my jar in a plugin org.pluginId, declaring 2 jar (jar1.jar et
jar2.jar) in Bundle-ClassPath of Manifest and exposing it using
Export-Package. I also used the Eclipse-BundleShape: dir instruction (don't
know if it was necessary).
org.pluginId;version="1.0.0";roots:=" jar1, jar2". I also used the
Eclipse-BundleShape: dir instruction (don't know if it was necessary).
I bundled all in a feature and update site which works perfectly.
Thanks for that idea, unfortunately it did not work out for me - I did get a
source bundle that looked ok but for some reason Eclipse was still not able
to figure out the location. However googling a bit for Eclipse-SourceBundle
made me find an Eclipse project having essentially the same 'problem'.
org.eclipse.pde.core include pde-ant.jar inside a subdirectory and the
corresponding - generated - source bundle includes the sources. I didn't
verify wether the sources can be accessed, but I'd assume someone would've
noticed it does not.

Inspecting the setup it appears the Eclipse/PDE folks worked around the lack
of support for configuring those roots-entries in Tycho by letting Tycho
build the sources as part of the build but then not include the resulting
class files in the bundle. Instead the pre-built jar is included, but since
Tycho has seen and built the sources it'll generate the necessary
Eclipse-BundleSource entry with the additional root path.

So I'll try that route now as well (though the sources seem to not build out
of the box).

Andreas
--
Andreas Pakulat ***@froglogic.com
froglogic GmbH - Automated UI and Web Testing
Andreas Pakulat
2017-09-08 08:53:10 UTC
Permalink
Post by Andreas Pakulat
Inspecting the setup it appears the Eclipse/PDE folks worked around the lack
of support for configuring those roots-entries in Tycho by
letting Tycho build the sources as part of the build but then not include
the resulting class files in the bundle. Instead the pre-built jar
is included, but since Tycho has seen and built the sources it'll generate
the necessary Eclipse-BundleSource entry with the additional root
path.
So I'll try that route now as well (though the sources seem to not build out
of the box).
That also did not work out and at this point this experiment has taken enough
time. I have a solution (keeping jar and sources into the actual plugin thats
going to make use of the code) for now.

I've zipped up my experiments and since they're a little over 2MB that way
uploaded them here:

https://send.firefox.com/download/d7da848e54/#55evHqFymD3yY0tGbRUQAw

In case anybody wants to have a look and point out my mistakes. This is the
last version where I attempted to follow the example of
org.eclipse.pde.core.

Andreas
--
Andreas Pakulat ***@froglogic.com
froglogic GmbH - Automated UI and Web Testing
Henrik Steudel
2017-08-10 10:29:38 UTC
Permalink
Hi,

are you generating a source feature? I just had a brief look at your
category.xml and could not find the according entry.

https://wiki.eclipse.org/Tycho/Reference_Card#Source_Features

Rough example:

<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/my.feature_0.0.0.qualifier.jar"
id="my.feature" version="0.0.0">
<category name="my.category"/>
</feature>
<feature url="features/my.feature-sources-feature.jar"
id="my.feature.source" version="0.0.0">
<category name="my.category"/>
</feature>
<category-def name="my.category" label="Components"/>
</site>

Hope this helps
Henrik
Post by Andreas Pakulat
Hi,
thanks for that idea. I did not see a particular reason to keep the
sources
packed, so I simply went with unpacked sources in a srcroot folder in the
plugin project that also carries the (packed) jar. Unfortunately the
resulting source bundle is not being used by Eclipse when using these
bundles
as part of the target platform.
I'm attaching a small sample project showing what I've tried. It
carries a
plugin with the jar file and a srcroot folder thats being added to the
source
bundle (I stripped the sources down to reduce the size). In addition a
feature and p2 repository are created so the plugins can be used in a
target
platform definition. I've added that repository into my target
platform and
as a dependency of a plugin. I can now use code like
import org.restlet.resource.ClientResource;
ClientResource resource = new ClientResource( URI.create("") );
but I cannot jump to the code of the ClientResource class in Eclipse.
Anybody can spot where I'm misunderstanding how this should work?
Andreas
Post by Henrik Steudel
Hi,
We assume that source archives are packaged as either zip or jar in a
folder
"lib-src" (${lib.src.folder}) located beneath the bundle root.
* The source archives are unzipped into a surrogate "srcroot"
(${src.root.folder}) folder by an ANT script.
* The standard source bundle plugin settings are extended to
include this
surrogate folder as additional sources.
Then you will get a ordinary source bundle which looks and feels
just like
your own source bundles.
Hints: You need to make sure that the source archive contains the
sources at
the archive's root level, i.e. the package folders need to start
at root. I had to manually change some archives to adhere to this
structure.
Also, the below definition excludes archives with an "all" part which
are
often containing a lot of non-source-related files.
Hope this helps.
Kind regards
Henrik
<properties>
<!--folder name to extract ext sources from -->
<lib.src.folder>lib-src</lib.src.folder>
<src.root.folder>srcroot</src.root.folder>
</properties>
<profile>
<id>unzip-src</id>
<activation>
<file>
<exists>${lib.src.folder}</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<failOnError>true</failOnError>
<target>
<echo message="Preparing source
bundle creation for plugin." />
<unzip
dest="${basedir}/${src.root.folder}" overwrite="false">
<fileset
dir="${basedir}/${lib.src.folder}">
<include
name="**/*.jar" />
<include
name="**/*.zip" />
<exclude
name="**/*javadoc*"
/>
<!--a 'all' part in
archive
name indicates that this archive contains more than sources, e.g.
testdata, compiled binaries. -->
<exclude
name="**/*all*" />
</fileset>
</unzip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<additionalFileSets>
<fileSet>
<directory>${project.basedir}/${src.root.folder}/</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</additionalFileSets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Post by Andreas Pakulat
Hi,
I'm including a thirdparty jar file in my Eclipse plugin. Currently I'm
doing this by simply copying the jar into the plugin and adding it
as a Runtime class path entry in the plugin meta information. This
works
fine, but the jar lacks source code, so stepping into that code is
not possible. I do have the source code though and I can manually
connect
the jar with the local directory on disk. This however stores a
local path in the plugin project which is not really a good idea on a
shared project. The alternative of using a workspace path would work,
but require that I also place the source code into the plugin and
version
control it which I find a little ugly.
I thought I could leverage the Eclipse source bundle support to let Tycho
build an eclipse plugin carrying the jar's and generate a source
bundle that carries the source code and allows Eclipse to make the
connection between class file and source 'automatically'.
Essentially I had an eclipse plugin which referrenced the jar files via
bin.includes and the source directories via src.includes. Then used
tycho-source-plugin to get a source plugin built out of that and
assembled
a feature and p2 repository carrying both. However this did not
work out, Eclipse was not able to figure out the correct place of the
sources.
Looking at the generated source plugin and some reading led me to believe
that the EclipseSourceBundle entry would require some different
values for the root=. part. This in turn let me find this old thread
https://dev.eclipse.org/mhonarc/lists/tycho-user/msg01991.html which
suggests this is not possible at the moment.
Is that still correct or am I overlooking something?
Andreas
--
Entimo AG
Stralauer Platz 33 - 34 | 10243 Berlin | Germany
Tel: +49.30.52 00 24 133 | Fax: +49.30.52 00 24 101
Vorstand: Jürgen Spieler (Vors.), Marianne Neumann
Aufsichtratsvorsitzender: Erika Tannenbaum
Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB
Berlin-Charlottenburg 85073
--
froglogic GmbH - Automated UI and Web Testing
CONFIDENTIALITY NOTICE This message and any included attachments are
from Cerner Corporation and are intended only for the addressee. The
information contained in this message is confidential and may
constitute inside or non-public information under international,
federal, or state securities laws. Unauthorized forwarding, printing,
copying, distribution, or use of such information is strictly
prohibited and may be unlawful. If you are not the addressee, please
promptly delete this message and notify the sender of the delivery
error by e-mail or you may call Cerner's corporate offices in Kansas
City, Missouri, U.S.A at (+1) (816)221-1024.
--
Entimo AG
Stralauer Platz 33 - 34 | 10243 Berlin | Germany
Tel: +49.30.52 00 24 133 | Fax: +49.30.52 00 24 101
***@entimo.com | http://www.entimo.com/

Vorstand: Jürgen Spieler (Vors.), Marianne Neumann
Aufsichtratsvorsitzender: Erika Tannenbaum

Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB Berlin-Charlottenburg 85073
Andreas Pakulat
2017-08-10 10:52:11 UTC
Permalink
Hi,

I opted for packaging the source plugin into the single feature. The
generated repository contains both plugins. Also see my other mail I just
sent: It works when I unpack the jars in my plugin.

Andreas
Post by Henrik Steudel
Hi,
are you generating a source feature? I just had a brief look at your
category.xml and could not find the according entry.
https://wiki.eclipse.org/Tycho/Reference_Card#Source_Features
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/my.feature_0.0.0.qualifier.jar" id="my.feature"
version="0.0.0">
<category name="my.category"/>
</feature>
<feature url="features/my.feature-sources-feature.jar"
id="my.feature.source" version="0.0.0">
<category name="my.category"/>
</feature>
<category-def name="my.category" label="Components"/>
</site>
Hope this helps
Henrik
Post by Andreas Pakulat
Hi,
thanks for that idea. I did not see a particular reason to keep the sources
packed, so I simply went with unpacked sources in a srcroot folder in the
plugin project that also carries the (packed) jar. Unfortunately the
resulting source bundle is not being used by Eclipse when using these
bundles
as part of the target platform.
I'm attaching a small sample project showing what I've tried. It carries a
plugin with the jar file and a srcroot folder thats being added to the
source
bundle (I stripped the sources down to reduce the size). In addition a
feature and p2 repository are created so the plugins can be used in a
target
platform definition. I've added that repository into my target platform and
as a dependency of a plugin. I can now use code like
import org.restlet.resource.ClientResource;
ClientResource resource = new ClientResource( URI.create("") );
but I cannot jump to the code of the ClientResource class in Eclipse.
Anybody can spot where I'm misunderstanding how this should work?
Andreas
Post by Henrik Steudel
Hi,
We assume that source archives are packaged as either zip or jar in a
folder
"lib-src" (${lib.src.folder}) located beneath the bundle root.
* The source archives are unzipped into a surrogate "srcroot"
(${src.root.folder}) folder by an ANT script.
* The standard source bundle plugin settings are extended to
include this
surrogate folder as additional sources.
Then you will get a ordinary source bundle which looks and feels just
like
your own source bundles.
Hints: You need to make sure that the source archive contains the sources
at
the archive's root level, i.e. the package folders need to start
at root. I had to manually change some archives to adhere to this
structure.
Also, the below definition excludes archives with an "all" part which are
often containing a lot of non-source-related files.
Hope this helps.
Kind regards
Henrik
<properties>
<!--folder name to extract ext sources from -->
<lib.src.folder>lib-src</lib.src.folder>
<src.root.folder>srcroot</src.root.folder>
</properties>
<profile>
<id>unzip-src</id>
<activation>
<file>
<exists>${lib.src.folder}</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<failOnError>true</failOnError>
<target>
<echo message="Preparing source
bundle creation for plugin." />
<unzip
dest="${basedir}/${src.root.folder}" overwrite="false">
<fileset
dir="${basedir}/${lib.src.folder}">
<include name="**/*.jar" />
<include name="**/*.zip" />
<exclude
name="**/*javadoc*"
/>
<!--a 'all' part in
archive
name indicates that this archive contains more than sources, e.g.
testdata, compiled binaries. -->
<exclude name="**/*all*" />
</fileset>
</unzip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<additionalFileSets>
<fileSet>
<directory>${project.basedir}/${src.root.folder}/</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</additionalFileSets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Post by Andreas Pakulat
Hi,
I'm including a thirdparty jar file in my Eclipse plugin. Currently I'm
doing this by simply copying the jar into the plugin and adding it
as a Runtime class path entry in the plugin meta information. This works
fine, but the jar lacks source code, so stepping into that code is
not possible. I do have the source code though and I can manually connect
the jar with the local directory on disk. This however stores a
local path in the plugin project which is not really a good idea on a
shared project. The alternative of using a workspace path would work,
but require that I also place the source code into the plugin and version
control it which I find a little ugly.
I thought I could leverage the Eclipse source bundle support to let Tycho
build an eclipse plugin carrying the jar's and generate a source
bundle that carries the source code and allows Eclipse to make the
connection between class file and source 'automatically'.
Essentially I had an eclipse plugin which referrenced the jar files via
bin.includes and the source directories via src.includes. Then used
tycho-source-plugin to get a source plugin built out of that and
assembled
a feature and p2 repository carrying both. However this did not
work out, Eclipse was not able to figure out the correct place of the
sources.
Looking at the generated source plugin and some reading led me to believe
that the EclipseSourceBundle entry would require some different
values for the root=. part. This in turn let me find this old thread
https://dev.eclipse.org/mhonarc/lists/tycho-user/msg01991.html which
suggests this is not possible at the moment.
Is that still correct or am I overlooking something?
Andreas
-- Entimo AG
Stralauer Platz 33 - 34 | 10243 Berlin | Germany
Tel: +49.30.52 00 24 133 | Fax: +49.30.52 00 24 101
Vorstand: Jürgen Spieler (Vors.), Marianne Neumann
Aufsichtratsvorsitzender: Erika Tannenbaum
Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB
Berlin-Charlottenburg 85073
froglogic GmbH - Automated UI and Web Testing
CONFIDENTIALITY NOTICE This message and any included attachments are from
Cerner Corporation and are intended only for the addressee. The information
contained in this message is confidential and may constitute inside or
non-public information under international, federal, or state securities
laws. Unauthorized forwarding, printing, copying, distribution, or use of
such information is strictly prohibited and may be unlawful. If you are not
the addressee, please promptly delete this message and notify the sender of
the delivery error by e-mail or you may call Cerner's corporate offices in
Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
--
Andreas Pakulat ***@froglogic.com
froglogic GmbH - Automated UI and Web Testing
Loading...