How to replace myproduct.exe with renamed eclipsec.exe - eclipse

I have an Eclipse RCP product.
I am (ab?)using the p2.inf file, located in the directory the .product file is located in, to remove the .exe file and rename the eclipsec.exe file to the .exe file. The content looks as follows:
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/eclipsec.exe, target:${installFolder}/myproductname.exe, overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/eclipsec.exe);
I need to build this product for windows and linux with maven tycho. For windows the p2.inf file instructions work fine. For linux this fails, which I am not surprised about (there is no .exe file).
Is there a way to execute those instructions for windows only / ignore the p2.inf file for linux builds when the product is built with tycho (for linux just 1 executable is generated anyway)?
Thanks in advance.
Tycho version: 1.0.0
Eclipse SDK version: 4.7.0

This can be done either:
with a fragment that contains the p2.inf file and that has the Platform Filter: (osgi.os=linux) or
by defining an installation unit (IU) similar to the example described here that contains a line like units.0.filter=(osgi.os=linux). (see also Customizing Metadata in Eclipse help and in the Eclipse wiki)
If possible, the first option is preferable, since the second option is more complex and requires more knowledge about p2.
Note, your root problem seems to be Eclipse bug 185205. Maybe you'd like to vote for it or comment on it. I suspect there is a better workaround than do a copy via p2 for that.

I have to solve it myself, posting complete solution here using windows filter.
Create file p2.inf in the "Product" project of your application
(or feature project).
Change MYPRODUCT to your own branding name.
When copying make sure there are no trailing spaces after backslashes in touchpoint actions or it won't work.
#create a requirement on the fragment we are creating
requires.22.namespace=org.eclipse.equinox.p2.iu
requires.22.name=MYPRODUCT.eclipsecoverride.config.win32.win32.x86_64
requires.22.range=[$version$,$version$]
requires.22.greedy=true
requires.22.filter=(osgi.os=win32)
#create a IU fragment with touchpoint action
units.0.id = MYPRODUCT.eclipsecoverride.config.win32.win32.x86_64
units.0.version = $version$
units.0.provides.1.namespace=org.eclipse.equinox.p2.iu
units.0.provides.1.name=MYPRODUCT.eclipsecoverride.config.win32.win32.x86_64
units.0.provides.1.version=$version$
units.0.filter=(osgi.os=win32)
units.0.instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(\
source:${installFolder}/eclipsec.exe,\
target:${installFolder}/MYPRODUCT_console.exe,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.remove(\
path:${installFolder}/eclipsec.exe);

How I moved eclipsec.exe to myproduct.exe (overwritten) without destroying the linux build
I added a myproduct.p2.inf file next to my myproduct.product file with the following content:
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/eclipsec.exe, target:${installFolder}/myproduct.exe, overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/eclipsec.exe);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../../linux/gtk/x86_64/myproduct/myproduct.exe);
With this state the copy instruction will fail for Linux builds because there is no eclipsec.exe file (FileNotFoundException). It's generated for Windows builds only.
Note that the copy instruction fails if specified files are not found while the remove instruction simply isn't executed in case the specified file does not exist.
Workaround
To work around this problem I added the empty file org.example.feature/filesToCopy/eclipsec.exe to my feature (which is included in my feature based product) and added the line root.linux.gtk.x86_64=filesToCopy to the build.properties of the feature project. This copies the empty eclipsec.exe file to the Linux build.
What happens for Windows:
The product is built with eclipsec.exe and myproduct.exe
eclipsec.exe is copied to myproduct.exe (which overrides myproduct.exe)
eclipsec.exe is deleted
--> myproduct.exe is the only executable (next to the myproduct.ini file). All brandings are lost though!
What happens for Linux:
The product is built with the myproduct executable and an empty eclipsec.exe file.
eclipsec.exe is copied to myproduct.exe
eclipsec.exe is deleted
myproduct.exe is deleted too
--> The linux archive looks exactly as it was built by tycho. All the copying and renaming of *.exe files have no other purpose than making it possible to execute the copy instruction in the p2.inf file which is required for the Windows build.

Related

Find Eclipse Version from Command prompt(cmd)

I'm doing Eclipse plugin development, and i need to find the version of the Eclipse IDE I have currently installed. In stead of opening the IDE, is there any cmd commands that I can execute to find the same?
Something like-
eclipse.exe --version
if that is possible?
Well in Windows I can do:
C:\dev\eclipse>type .eclipseproduct
name=Eclipse Platform
id=org.eclipse.platform
version=4.4.2
Or find the BuildID in config.ini under configuration folder:
C:\dev\eclipse\configuration>type config.ini | findstr /i BuildID
eclipse.buildId=4.4.2.M20150204-1700
(similar can be done in linux/unix with cat and grep of course.)
Blank Build ID/Version
Why your build id is blank is strange, could you upload a screenshot from your help -> about window.
Could you share your eclipse.ini and please refer to the installation bundle that has been used.
Eclipse version/build is based on the product (see your eclipse.ini, org.eclipse.epp.*)
In later versions (for example if using) JEE EPP there should be a file called about.mappings file, e.g.
C:\dev\eclipse\plugins\org.eclipse.epp.package.jee_4.6.2.20161208-0625\about.mappings
# about.mappings
# contains fill-ins for about.properties
# java.io.Properties file (ISO 8859-1 with "\" escapes)
# This file does not need to be translated.
0=MrSimpleMind-Null
1=Neon.2 Release (4.6.2)
I edited the file like shown above and the result below in screenshot:
But this is not the solution of the problem, I would like to know why your values are blank. Do you have conflict in your EPP, try to update your eclipse environment (?)

Avoid creating installation directory for patch installation

Today I need a solution to avoid creating a installation directory by install4j version 6.1.3 in a context of a patch installation. I wrote an installer which contains some files to install them to an existing application installation. The files should be bundled together with the patch installer. At the install files action i deactivated the install runtime selection point but the installer still created the installation directory containing a folder called .install4j. In this folder there are only some install4j files. When I deactivate the whole install files action the folder will not be created but the bundles files will also be not extracted to the temp-dircetory, right? I also marked the installation directory as an excluded file at the media-wizard. Do I missed something?
Thanks in advance
I would recommend to use the "Add-on installer" installer type on the "Installer->Update options" step.
If you need to update the version number, an alternative solution would be to remove the "Install files" action and add a ZIP file files.zip on the "Installer->Custom Code & resources" step that contains the new files. In the "Installation" screen, add an "Install content of a ZIP file" action with the "Zip file" property set to ${installer:sys.resourceDir}/files.zip.

Configure Eclipse IDE to move cache data out of eclipse installation direction

I believe this is normal user's behavior:
After downloading the eclipse IDE distribution, such as eclipse-jee-mars-2-win32-x86_64.zip file, you unzip it to a folder, e.g. C:. The eclipse executable is at C:\eclipse\eclipse.exe. (Here I'll refer C:\eclipse directory as eclipse home directory.)
When running, eclipse will write some temp or customization file under eclipse home directory, so the eclipse home directory became dirty. I wonder if there is any parameter or configuration file setting so eclipse will write those cache/temp/customized data to somewhere else.
I'm not talking about '-clean' parameter. From the help file, I think I should try -configuration configURL. However I don't know the format of the configuration file.
Here is the best I've got so far after some trial and errors:
Take C:\eclipse as my eclipse home directory, which is extracted from eclipse distribution zip file. My goal is to keep this home directory clean.
I created the following directories:
C:\eclipse-work.ws
C:\eclipse-work.home\user
C:\eclipse-work.home\configuration
Here is the command line I used to start eclipse, of course it's part of a script:
C:\eclipse\eclipse.exe -data C:\eclipse-work.ws -user C:\eclipse-work.home\user -configuration C:\eclipse-work.home\configuration
The trick is I need to make configuration directory to be a two level directory as eclipse will generate other cache or data under C:\eclipse-work.home dir.
This is the best I can get so far. All cache data, as well as plug-ins I installed, will be in the C:\eclipse-work.home directory. There is only one file generated under original eclipse home directory, that is a profile gz file under
p2\org.eclipse.equinox.p2.engine\profileRegistry\epp.package.jee.profile
directory. And this file won't be changed once it's created.
I'm using a ram disk. Using above approach I can setup the eclipse IDE in the ram disk image file. Now eclipse starts much faster.
For that -user directory, so far I didn't observe any file generated under it. Not sure if it can be omitted.

Move default config folder of eclipse

When Eclipse first start, it creates some config files and folders on my hard drive (contains information about work-space ...etc...). I don't like the position it creates config files because config files are all put in my C:\Users\Long folder and that's ugly. I want to put all those config files somewhere else (C:\Eclipse\ for example). This happens in Linux too.
Do you know how to put those files in somewhere else?
Just add the following to your eclipse.ini file (found at the root eclipse installation folder):
-Dosgi.configuration.area=file:/C:/Workspace/.eclipse
To change the default .eclipse folder location, go to ${eclipse.home}, open your eclipse.ini with a text editor and insert there one line more:
-Dosgi.configuration.area=/path_to_new_folder_location/.eclipse/
As someone already said, adding the property -Dosgi.configuration.area in the eclipse.ini file does the trick.
But in my opinion it would be better to rely on the user.home variable and set the destination like for the other variables.
Example with -Dosgi.instance.area.default:
-Dosgi.instance.area.default=#user.home/eclipse-workspace
In my case I just wanted another destination than the default #user.home/.eclipse which was still used by the Eclipse Mars that I keep for old projects and I just defined:
-Dosgi.configuration.area=#user.home/.eclipse-oygen-3
to have a specific destination for the Eclipse Oxygen 3 installation.
Note that syntax works for both Windows and Linux (I did not tested on OSX, but I guess it should).
Eclipse has some command line arguments you can use. One of those arguments is the flag -data which tells Eclipse where the workspace of Eclipse should be located.
So when I create a new workspace, I normally create a shortcut under Windows (or script file under Linux) with the following contents:
eclipse.exe -vm <JDK>\bin\javaw.exe" -data ws -nl en
This defines which JDK should be used, that the workspace is located under ws and that the english locale should be used.
IMHO parameter -configuration does the trick. It must point to a subdirectory named "config". Eclipse will fill this and the upper directory itself with files, e.g. for a JBoss server installation.
If you have more than one eclipse installation, then you should use a different directory for each eclipse installation.
Example how to keep everything in defined places:
"C:\Program Files (x86)\eclipse\eclipse48jee\eclipse.exe" -nl en_US -vm "C:\Program Files (x86)\Java\jdk1.8.0_212\bin" -configuration C:\EclipseData\eclipse48jee\config -data C:\Workspaces\SomeProject

Can an extra plugin directory be specified on command line

With Eclipse 3.4, is it possible to provide an ADDITIONAL plugin directory from command line? Something like:
eclipse -plugin_dir D:/myproduct/V1.1/plugins -clean
This is just to save copying of plugins everytime.
While copying can be done with script, it's possible that user may not have
write permissions to system install eclipse.
Follow up:
The solution given by #VonC is for reusing same plugins in multiple Eclipses.
I'm looking for a to use Multiple versions of plugins with Same Eclipse.
( If user has Version 1.1 and Vesion 1.2 of my plugin installed )
Resolved:
The directory pointed to by -Dorg.eclipse.equinox.p2.reconciler.dropins.directory
should end with a directory named 'eclipse'
Inside this eclipse where should be directory called plugins,
place all the jars at in the plugins directory
create a launcher , which launch eclipse with additional command line:
-vmargs
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=AbsolutePath\eclipse
One may want to add -clean also ..
As mentionned in Installing Eclipse (3.4+) plugins in a directory other than ECLIPSE_HOME/plugins, the right way is to define a bundle pools (also introduced here)
See my previous answer for more details.
It space is not a big issue, users can copy the system install of eclipse into a work directory and put additional plugins/features in the dropins/ directory.