Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Generate "Ant build file" outside Eclipse
Re: Generate "Ant build file" outside Eclipse [message #603758 is a reply to message #493825] Wed, 02 December 2009 15:50 Go to previous messageGo to next message
Rothmans is currently offline RothmansFriend
Messages: 37
Registered: July 2009
Member
At last I have understood couple of basic pronciples that make possible using automated PDE build.

Apparently they considered obvious and therefore are not mentioned too often in docs and answers.

For those who is battleing to get automatic PDE build working here is what I have discovered.

There are basically two approaches to use automatic PDE build:

I. Using the build.xml exported from the IDE.

Get the plugin project working from withing Eclipse IDE and export the build.xml file.
Check that file in and call it's targets to build automatically.
You'll have to check in that build.xml every time you change anything in the plugin.
You can export the script only as "build.xml" (so, don't put your own build.xml to the project folder).
I am not sure whether this approach would always smoothly work for features.
Product builds won't work in that way I believe.
Anyway, most of my problems arose because I tried to use this approach from the beginning, sincerly believeing that building from inside IDE and using that script from outside should be the same for all kinds of PDE projects.

II. Using the right folder structure.

If you'd like to build any feature and any product you will have to obey to the folder structure the PDE build dictates.

You will need to get your sources (not binaries!!! as it may seem from the manuals) into the following directory structure:

${buildDirectory}/plugins/${your.plugin.id.as.specified.in.t he.META-INF.MANIFEST.MF.file}
${buildDirectory}/features/${your.feature.id.as.specified.in .the.META-INF.MANIFEST.MF.file}

You can put your plugin/feature projects into that folders and check them in. Or, if you want to fully rely on the SCM connection and copy all the stuff once more to your local drive, you can:
* use map files and "fetching" phase of the PDE build script to get your sources into the prescribed folders (didn't try by myself expecting further complications)
* set up your own script that copies the sources into the folder structure above.

Now you can launch the
${target.eclipse.pde.plugin.folder}/scripts/build.xml
for features or
${target.eclipse.pde.plugin.folder}/scripts/productBuild/pro ductBuild.xml
for products, where
${target.eclipse.pde.plugin.folder} is the PDE Eclipse plugin folder usually in the Eclipse distribution you build with. In my case it is
${target.eclipse.platform}/plugins/org.eclipse.pde.build_3.5 .1.R35x_20090820

You must launch these build scripts from under Eclipse and specify some directory locations before doing that.
To build a feature:

<target name="build-feature">
<!-- Input: feature.id -->
<java jar="${target.eclipse.ant.launcher}" fork="true" failonerror="true">
<arg value="-application" />
<arg value="org.eclipse.ant.core.antRunner" />
<arg value="-buildfile" />
<arg value="${target.eclipse.pde.plugin}/scripts/build.xml" />
<arg value="-DbaseLocation=${target.eclipse.platform}" />
<arg value=" -DpluginPath=${builder.dir}/plugins${path.separator}${target .eclipse.platform}/plugins${path.separator}${target.eclipse. deltapack}/plugins " />
<arg value="-DbuildDirectory=${projects.root.dir}" />
<arg value="-Dbuilder=${builder.dir}" />
<arg value="-DbuildTempFolder=${temp.build.dir}" />
<arg value="-Dp2.category.definition=file:${category.xml.location} " />
<arg value="-DtopLevelElementType=feature" />
<arg value="-DtopLevelElementId=${feature.id}" />
<arg value="-Dp2.build.repo=file:${path.to.local.update.site}" />
</java>
</target>

To build a product:

<target name="build-product">
<java jar="${target.eclipse.ant.launcher}" fork="true" failonerror="true">
<arg value="-application" />
<arg value="org.eclipse.ant.core.antRunner" />
<arg value="-buildfile" />
<arg value=" ${target.eclipse.pde.plugin}/scripts/productBuild/productBui ld.xml " />
<arg value="-DbaseLocation=${target.eclipse.platform}" />
<arg value=" -DpluginPath=${builder.dir}/plugins${path.separator}${target .eclipse.platform}/plugins${path.separator}${target.eclipse. deltapack}/plugins " />
<arg value="-DbuildDirectory=${project.root.dir}" />
<arg value="-Dbuilder=${builder.dir}" />
<arg value="-DbuildTempFolder=${temp.build.dir}" />
<arg value="-Dp2.category.definition=file:${category.xml.location} " />
<arg value="-Dproduct=${product.file.location}" />
<arg value="-Dp2.build.repo=file:${path.to.update.site}" />
<arg value="-DarchivePrefix=${archive.prefix}" />
</java>
</target>

Important properties here are:
target.eclipse.platform - path to the Eclipse installation you are building with;
target.eclipse.deltapack - path to the Eclipse deltapack you'd need to build products;
projects.root.dir - the path to the folder containgin plugins/.. and features/... folders with your project sources.
builder.dir -- The build.properies and probably other template files copied from the PDE plugin folder files must be located here.
temp.build.dir - the directory you can clean after build if will be used by PDE build to store some of the temporary files it generates. You'll still need to clean up your projects and builder folders from the numerous files generated by the build.
feature.id -- id of the feature you want to build as specified in the feature.xml file of the feature project and in its folder name.
path.to.local.update.site - path where the resulting update site containing built feature will be stored.
category.xml.location and product.file.location are the pathes to the category.xml and product file correspondingly.

You don't need to put version numbers to the folder names if you use second approach.
You do have to update feature.xml and product files with the automatically changing versions.

Since eclipse.idReplacer works only once (requires specification of the original version) and is implemented without any use of an XML parser or regular expressions, I simply use usual <replaceregexp> task from the antcontrib package to update changing versions related files.

Hope that this info saves at least a bit time to the next PDE build beginner.
Re: Generate "Ant build file" outside Eclipse [message #676727 is a reply to message #603758] Mon, 06 June 2011 10:45 Go to previous message
Charu Sharma is currently offline Charu SharmaFriend
Messages: 17
Registered: May 2011
Location: Pune
Junior Member
Hi,

I also want to do headless build, but my requirement is to do without workspace because, i have created a batch file wherein my sources i.e. plugins, features, RCP and product.. Every thing will get copied from SVN to a folder.

I followed the de vogella's tutorial and took his product build.xml file. His way worked good till i have projects in the workspace and are build. But once I take out raw unbuild sources from CVS and give the location of my product in build.xml, export fails.

Can anybody guide me how my problem can be solved.

-Charu
Previous Topic:Including Java Project in Plugin development
Next Topic:Building two features from one build.xml file
Goto Forum:
  


Current Time: Thu Mar 28 10:25:40 GMT 2024

Powered by FUDForum. Page generated in 0.02486 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top