Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Build plugin and source-plugin from pre-built jar's and source folder

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>

Am 09.08.2017 um 16:51 schrieb 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
hst@xxxxxxxxxx | http://www.entimo.com/

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

Sitz der Gesellschaft: Berlin, Germany | Handelsregister: HRB Berlin-Charlottenburg 85073

Back to the top